Commit dd8e4aa4 by apatrick@chromium.org

Fix vertex texture fetch.

The texture v coordinate was still being flipped. Fixes http://code.google.com/p/chromium/issues/detail?id=136650. Review URL: https://codereview.appspot.com/6345095 git-svn-id: https://angleproject.googlecode.com/svn/trunk@1214 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 2fe20a86
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1213 #define BUILD_REVISION 1214
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -423,25 +423,11 @@ void OutputHLSL::header() ...@@ -423,25 +423,11 @@ void OutputHLSL::header()
out << uniforms; out << uniforms;
out << "\n"; out << "\n";
// The texture fetch functions "flip" the Y coordinate in one way or another. This is because textures are stored
// according to the OpenGL convention, i.e. (0, 0) is "bottom left", rather than the D3D convention where (0, 0)
// is "top left". Since the HLSL texture fetch functions expect textures to be stored according to the D3D
// convention, the Y coordinate passed to these functions is adjusted to compensate.
//
// The simplest case is texture2D where the mapping is Y -> 1-Y, which maps [0, 1] -> [1, 0].
//
// The texture2DProj functions are more complicated because the projection divides by either Z or W. For the vec3
// case, the mapping is Y -> Z-Y or Y/Z -> 1-Y/Z, which again maps [0, 1] -> [1, 0].
//
// For cube textures the mapping is Y -> -Y, which maps [-1, 1] -> [1, -1]. This is not sufficient on its own for the
// +Y and -Y faces, which are now on the "wrong sides" of the cube. This is compensated for by exchanging the
// +Y and -Y faces everywhere else throughout the code.
if (mUsesTexture2D) if (mUsesTexture2D)
{ {
out << "float4 gl_texture2D(sampler2D s, float2 t)\n" out << "float4 gl_texture2D(sampler2D s, float2 t)\n"
"{\n" "{\n"
" return tex2Dlod(s, float4(t.x, 1 - t.y, 0, 0));\n" " return tex2Dlod(s, float4(t.x, t.y, 0, 0));\n"
"}\n" "}\n"
"\n"; "\n";
} }
...@@ -450,7 +436,7 @@ void OutputHLSL::header() ...@@ -450,7 +436,7 @@ void OutputHLSL::header()
{ {
out << "float4 gl_texture2DLod(sampler2D s, float2 t, float lod)\n" out << "float4 gl_texture2DLod(sampler2D s, float2 t, float lod)\n"
"{\n" "{\n"
" return tex2Dlod(s, float4(t.x, 1 - t.y, 0, lod));\n" " return tex2Dlod(s, float4(t.x, t.y, 0, lod));\n"
"}\n" "}\n"
"\n"; "\n";
} }
...@@ -459,12 +445,12 @@ void OutputHLSL::header() ...@@ -459,12 +445,12 @@ void OutputHLSL::header()
{ {
out << "float4 gl_texture2DProj(sampler2D s, float3 t)\n" out << "float4 gl_texture2DProj(sampler2D s, float3 t)\n"
"{\n" "{\n"
" return tex2Dlod(s, float4(t.x / t.z, 1 - t.y / t.z, 0, 0));\n" " return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, 0));\n"
"}\n" "}\n"
"\n" "\n"
"float4 gl_texture2DProj(sampler2D s, float4 t)\n" "float4 gl_texture2DProj(sampler2D s, float4 t)\n"
"{\n" "{\n"
" return tex2Dlod(s, float4(t.x / t.w, 1 - t.y / t.w, 0, 0));\n" " return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, 0));\n"
"}\n" "}\n"
"\n"; "\n";
} }
...@@ -473,12 +459,12 @@ void OutputHLSL::header() ...@@ -473,12 +459,12 @@ void OutputHLSL::header()
{ {
out << "float4 gl_texture2DProjLod(sampler2D s, float3 t, float lod)\n" out << "float4 gl_texture2DProjLod(sampler2D s, float3 t, float lod)\n"
"{\n" "{\n"
" return tex2Dlod(s, float4(t.x / t.z, 1 - t.y / t.z, 0, lod));\n" " return tex2Dlod(s, float4(t.x / t.z, t.y / t.z, 0, lod));\n"
"}\n" "}\n"
"\n" "\n"
"float4 gl_texture2DProjLod(sampler2D s, float4 t, float lod)\n" "float4 gl_texture2DProjLod(sampler2D s, float4 t, float lod)\n"
"{\n" "{\n"
" return tex2Dlod(s, float4(t.x / t.w, 1 - t.y / t.w, 0, lod));\n" " return tex2Dlod(s, float4(t.x / t.w, t.y / t.w, 0, lod));\n"
"}\n" "}\n"
"\n"; "\n";
} }
...@@ -487,7 +473,7 @@ void OutputHLSL::header() ...@@ -487,7 +473,7 @@ void OutputHLSL::header()
{ {
out << "float4 gl_textureCube(samplerCUBE s, float3 t)\n" out << "float4 gl_textureCube(samplerCUBE s, float3 t)\n"
"{\n" "{\n"
" return texCUBElod(s, float4(t.x, -t.y, t.z, 0));\n" " return texCUBElod(s, float4(t.x, t.y, t.z, 0));\n"
"}\n" "}\n"
"\n"; "\n";
} }
...@@ -496,7 +482,7 @@ void OutputHLSL::header() ...@@ -496,7 +482,7 @@ void OutputHLSL::header()
{ {
out << "float4 gl_textureCubeLod(samplerCUBE s, float3 t, float lod)\n" out << "float4 gl_textureCubeLod(samplerCUBE s, float3 t, float lod)\n"
"{\n" "{\n"
" return texCUBElod(s, float4(t.x, -t.y, t.z, lod));\n" " return texCUBElod(s, float4(t.x, t.y, t.z, lod));\n"
"}\n" "}\n"
"\n"; "\n";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment