Jump to content
  • Advertisement
Sign in to follow this  
sled

OpenGL Texture Blending Lighting Problem

This topic is 4480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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;
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!