Sign in to follow this  

Soft shoreline w/ pixel shader....how to blend with render target?

This topic is 2851 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 am slowly learning HLSL, mostly by repeated blows to the head, so forgive me if this seems dumb. I have a terrain. I'm using a grey scale mask to determine where the water needs to be. I'm rendering the water very typically with a second render call to the same render target and using a fresnel term in the pixel shader to determine the water color. What I'm trying to do is soften the hard shoreline that this produces by blending the final water color with the already exiting terrain diffuse color....so I'm trying to blend a new color with the color that already exists in the same render target, using the grey scale mask to determine the amount of each color, so that (obviously) I get more terrain diffuse color and less water color on the edges of the water, resulting in a smoothly fading shoreline. Alpha blending doesn't look like it will do this....am I wrong? And multi-texturing using the grey scale value as the weight factor looks good, but I don't see how to indicate the existing value of the current render target as the second texture, short of rendering the terrain to a texture and sampling the texture, which seems like a waste. Is something that can be done, or am I way offbase, or am I typically making this a lot more complicated than it really is? I general, I'd like to know ALL of the reasonable techniques that I can use to accomplish this, and which would be the best. THANKS!

Share this post


Link to post
Share on other sites
danromeo,

Essentially, what you want to accomplish can be done by using an alpha blend based on pixel depth differences in the pixel shader. You'll need to scene depth (terrain) by the time you do the comparision (to the water). Increase the alpha of the resulting pixel as the pixel depths converge. This isn't a canned and complete answer, but it should point you in the right direction. Check out how soft particles function, as a pointer in a right direction.

Share this post


Link to post
Share on other sites

This topic is 2851 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.

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

Sign in to follow this