Jump to content

Depth Buffer


havenphillip

1,014 views

 Share

Note: In my last post shaders 36 and 37 weren't working correctly so I replaced them. If you got the old ones you can throw those out and re-download the new ones on the same links.

These shaders are based on the Leadwerks soft  particle shader, which I was directed to by Marcousik, and which I noobalyzed into a model shader. What the soft particle shader does is create a soft falloff in opacity depending on how close objects are behind it. To clarify, imagine looking down at a water plane, and a terrain beneath it. Depending on how far away the terrain is from the water plane determines how much of the effect you see. If the water plane is near the ground along the shore it is invisible. But on the deep end, where the ground and the water surface are far apart you get more opacity in the effect.

The core of what's going on is you're getting the distance from the eye or camera to the water plane, and the distance from the eye to the terrain surface, and then you're finding the difference between the two.

This shader makes nice fog effects. Just make a plane and set the shader on it, and adjust the height to your liking:

1759337402_groundfog.thumb.jpg.88739723732101a54e2c4ecec26e96dd.jpg

39_ground fog.zip

 

If you invert the effect using  "1-diff" you get a strong opacity near objects which then fades to alpha the more space there is between its surface and the surface behind it. That's how I was able to make this forcefield shader:

forcefield.thumb.jpg.21cbb29d495344ca3c46c0530668ffeb.jpg

40_forcefield.zip

 

Happy shading!

 

Next: Tessellation...

 

  • Like 7
 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...