This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

OpenGL ES 2.0 Emulator: Strange behavior when using a varying

Hi there!

I'm kinda new to the OpenGL land, so this might just be a stupid mistake. First of all, I need my shaders to cross-compile with HLSL, so there is some macro-foo in my shaders, but I don't think these are getting me into this trouble here.

We didn't get the shaders to run properly on AMD-Hardware (Vertices messed up), but only when I accessed some varyings for Texture-Coordinates and Normals. However, I've come to a similar problem on my Nvidia GTX570, which seems really strange.

The following happens:

I have this vertex-shader here (stripped some #defines and stuff, but you should get the idea):

// [...]

attribute float3 in_Position;

attribute float3 in_Normal;

attribute float2 in_TexCoord;

attribute float2 in_LightmapCoord;

uniform float4x4 Model;

uniform float4x4 View;

uniform float4x4 Projection;

uniform float4x4 ModelViewProj;

uniform float2 LightmapPos;

uniform float2 LightmapPatchSize;

varying float3 v_WorldPos;

varying float3 v_Normal;

varying float2 v_TexCoord;

varying float2 v_LightmapCoord;

// [...]

void main()

{ 

    v_WorldPos = mul(float4(in_Position.xyz, 1.0f), Model);

    gl_Position = mul(float4(in_Position.xyz, 1.0f), ModelViewProj);

    //v_Normal = in_Normal;

    v_Normal= float3(0.0f, 0.0f, 0.1f);

 

    v_TexCoord = IN_TexCoord;

    v_LightmapCoord = in_LightmapCoord * LightmapPatchSize + LightmapPos;

}


This shader messes up the texture-coordinates (Both v_TexCoord and v_LightmapCoord) in the fragment shader, but only, when I assign the float3(0.0f, 0.0f, 0.1f); to v_Normal. When I uncomment the line above instead, they are working just fine.



So it comes down to this:

v_Normal = IN_Normal;  // Works fine

v_Normal= float3(0.0f, 0.0f, 0.1f); // Messes up texture-coordinates

Can someone please explain what is happening there? I would really appreciate a solution, since I have no idea what is going wrong there...

Parents Reply Children