• Advertisement
Sign in to follow this  

SOLVED Clear Color leaking into render target texture

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

So I'm trying to generate dynamic cloud layers using perlin noise. I can generate the cloud texture fine, but when I try to try to create a cloud layer, the clear color for the render target I'm using is leaking into my texture wherever the alpha channel is not 1. Here's the shader:
float2 TexCoordShift = float2(LayerIndex * Shift, 0);
float4 textureColor = tex2D(sTextureClouds, input.TexCoord);
float4 outputColor;
	
if (LayerIndex == 0) // first layer is unicolor
    outputColor = float4(CloudColor, textureColor.r); 
	
else // layer are derived from previous layer
{
   // Not important until problem is fixed
}

return outputColor;


I'm only concerned when LayerIndex = 0 for now. textureColor.r is the grayscale value from the generated cloud map, so it represents the cloud's alpha value. The problem is that if textureColor.r != 1, I get the render target's clear color in the output texture which I map on a cloud layer. Alpha blending is disabled, separate alpha channel blending is disabled. I tried storing textureColor.r in another channel of the output texture and that fixed the problem, but it caused problems later so I have to store it in outputColor.a. Any ideas on how to get store a non-1 alpha value without the clear color replacing it? [Edited by - diginerd on March 3, 2010 5:58:01 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by diginerd
Alpha blending is disabled, separate alpha channel blending is disabled.


Are you sure? Have you used PIX to inspect the device state at the time of the Draw call?

Share this post


Link to post
Share on other sites
I ran it through pix and it's disabled when the draw call is made. I got it to work but I had to set the clear color to 0,0,0,0.

Share this post


Link to post
Share on other sites
I'm dumb. AlphaBlend was false but AlphaTest was true and it was always taking the higher alpha. Thanks for the PIX idea, MJP!

Share this post


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

  • Advertisement