Translucency

Started by
3 comments, last by walkingcarcass 21 years, 2 months ago
As far as i know, a pixel shader can''t read the existing colour/depth value. So how do you do translucency? ******** A Problem Worthy of Attack Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...
Advertisement
Using AlphaBlending: AlphaBlendEnable, SrcBlend and DestBlend (which affect what’s rendered).

As far as I know, pixel shaders operate on textures and vertex color data, not on the framebuffer (You can render scenes to texture and operate on it if you like).

Reading from the depth-buffer directly isn't possible in the pixel shader, because different IHVs have different Z-buffer compression techniques.

You can also render the z buffer to a texture I think.

[edited by - Coder on February 9, 2003 6:43:19 AM]

How do you do translucency *in a shader engine* ?

********


A Problem Worthy of Attack
Proves It''s Worth by Fighting Back
spraff.net: don't laugh, I'm still just starting...
Visit the nVidia and ATI websites and download the demos and source code from either which demonstrates translucency with pixel shaders.

How? Render to texture, read the pixels in the shader during the second pass with the texture coordinates slightly offset so that you can access the neighbouring pixels for the colour averaging used to simulate the light scattering.

Like I said though, source code and documentation is definately on the IHV sites. IIRC there''s also one in ShaderX too.



--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Your pixel shader output is R0. R0.a is the alpha. It mixes just like the fixed pipe. Fog, specular add, and alpha blending all take place AFTER the pixel shader has run.

A pixel shader is a replacement for your colorop and alphaops only.

This topic is closed to new replies.

Advertisement