Jump to content
  • Advertisement
Sign in to follow this  
LevyDee

Alpha splatting and unexpected behavior

This topic is 996 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

My issue is explained in the attached images. I am attempting to texture splat by adjusting alpha values on seperate layers. The problem is when the alpha map runs through the shader multiple times, it affects previous alpha adjustments adversly. The shader is very simple and is as follows:

void psPPAlphaPaint(float2 iUV : TEXCOORD0,
                  out float4 color : COLOR0)

{
    color = tex2D(AlphaMap, iUV);    

    float2 distance = float2(0.0f, 0.0f);
    distance.x = uCoordinate - iUV.x;
    distance.y = vCoordinate - iUV.y;    

    float dist = sqrt(pow(uCoordinate - iUV.x, 2) + pow(vCoordinate - iUV.y, 2));
    if(dist < 0.05)
    {
        color.a = 1.0;
    }

}

Older alpha adjustments begin to blur and adust their position in the texture.

 

Any thoughts or clarifying questions?

 

Thank you

 

Edit: I am running the shader using a full screen quad to make adjustments to the alpha map as a render target

Edited by Slig Commando

Share this post


Link to post
Share on other sites
Advertisement

What Hodgman said, sounds like the most probable reason!

 

Also: I would do your shader like this:

void psPPAlphaPaint(float2 iUV : TEXCOORD0,
                  out float4 color : COLOR0)

{
    color = tex2D(AlphaMap, iUV);    

    float2 distance = float2(uCoordinate - iUV.x, vCoordinate - iUV.y);
//    float2 distance = float2(0.0f, 0.0f);
//    distance.x = uCoordinate - iUV.x;
//    distance.y = vCoordinate - iUV.y;    

    float dist = (distance.x * distance.x) + (distance.y * distance.y);
    if (dist < 0.0025)    // 0.05 * 0.05  =  0.0025
//    float dist = sqrt(pow(uCoordinate - iUV.x, 2) + pow(vCoordinate - iUV.y, 2));
//    if(dist < 0.05)
    {
        color.a = 1.0;
    }

}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!