Texture Blending Lighting Problem

Started by
3 comments, last by sled 17 years, 7 months ago
I'm trying to blend to textures together in a cg shader, which seems to be working. However, the lighting on the result is not. It appears that the lighting calculations are being applied to one texture and not the other. The shader isn't currently performing any lighting calculations, I'm just using diffuse lighting in opengl. Any ideas where I should look to fix this problem? lighting problem
Advertisement
a pixelshader would override the fixed function pipeline, then you have to perform the lighting by yourself. are you using texture stages to light the terrain and can you post the shader?
I am still learning about both texturing and shaders. Could you explain a little more about texturing stages? I don't quite understand them yet.

Thanks.

struct fragment{	float4 position  : POSITION;	float4 color0    : COLOR0;	float2 texcoord0 : TEXCOORD0;	float2 texcoord2 : TEXCOORD2;};struct pixel{	float4 color : COLOR;};//-----------------------------------------------------------------------------// IN             - incoming fragment to be processed// testTexture    - a texture for the pixel shader to use// checkerTexture - a second texture for the pixel shader to use//-----------------------------------------------------------------------------pixel main( fragment IN,            uniform sampler2D testTexture,            uniform sampler2D checkerTexture,            uniform sampler2D height ){	pixel OUT;    float4 texelColor0 = tex2D( testTexture, IN.texcoord0 );    float4 texelColor1 = tex2D( checkerTexture, IN.texcoord0 );    float4 amount = clamp(tex2D( height, IN.texcoord2 ) * 4 - 2, 0, 1);    OUT.color  = texelColor0 * IN.color0 * (1 - amount);    OUT.color += texelColor1 * amount;    return OUT;}
try something more like

OUT.color = ((texelColor0 * (1 - amount) + (texelColor1 * amount)) * IN.color0;

that should fix the problem

Thanks. It's easy to miss the little things.

This topic is closed to new replies.

Advertisement