Jump to content

[Help] Creating a shader for Light mapping


Einheit-101

Recommended Posts

Hello! I have a little shader that should apply a lightmap (texture Tex;) to a world texture.
However, the object gets fully transparent as soon as the shader gets applied to it. It seems the lightmap alpha channel completely overwrites the original diffuse color, which is not what i want, i only want the stuff that is not fully transparent to blend over the original texture to make it look like light. Any idea whats wrong there?

texture Tex;

//-------------------------------------------
// Variables
//-------------------------------------------

sampler SamplerTex = sampler_state
{
    Texture = (Tex);
};

//-------------------------------------------
// Returns light transform
//-------------------------------------------

float4 PSFunction(float4 TexCoord : TEXCOORD0, float4 Diffuse : COLOR0) : COLOR0
{
    float4 Tex = tex2D(SamplerTex, float2(TexCoord.x, TexCoord.y));
	Tex.a = Tex.a *= Diffuse.a;
    return Tex;
}

technique tec0
{
    pass p0
    {
       AlphaBlendEnable = TRUE;
       AlphaRef = 1;
       PixelShader = compile ps_2_0 PSFunction();
    }
}

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...