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

Started by
0 comments, last by ShaunPeoples 14 years, 1 month ago
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!
Advertisement
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.

This topic is closed to new replies.

Advertisement