Translucency (NOT TRANSPARENCY!!!)

Started by
4 comments, last by Kryptus 20 years, 11 months ago
how do i do translucency? is it hard to do? or where can i find out how to do it?
Advertisement
It's very easy: you use alpha-blending.
Device->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );Device->SetRenderState( D3DRS_SRCBLEND, SrcBlendValue );Device->SetRenderState( D3DRS_DESTBLEND, DestBlendValue ); 

More info is on MSDN. For additive blending (like a light) SrcBlendValue = D3DBLEND_ONE and DestBlendValue = D3DBLEND_ONE. The formula is:

DrawColor = (TexelColor * SrcBlend) + (ScreenPixelColor * DestBlend);

So if they're both one, you get:

DrawColor = (TexelColor * 1) + (PixelColor * 1)

which is

DrawColor = TexelColor + PixelColor

The kind of blending you want is src=D3DBLEND_DESTCOLOR, dest=D3DBLEND_ZERO. That multiplies ("modulates") them together.

To draw something opaque using alpha-blending (kinda pointless) you use this values:

DrawColor = (Texel * D3DBLEND_ONE) + (Pixel * D3DBLEND_ZERO);

which is

DrawColor = Texel

~CGameProgrammer( );
DevImg.net - Post screenshots, comment on others.
Town 3D Engine - A city-rendering 3D engine. Download the demo.

[edited by - CGameProgrammer on April 29, 2003 6:06:09 AM]
~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
[Waits for Kryptus to rant on the definition of translucency in response to the above ]


Translucency (i.e. looking at light through things like tracing paper and frosted glass) is really just "scattering" of the light within the surface you''re viewing through.

In the world of realtime computer graphics hackery scatter==blur.

So you want the surface of the translucent object to blur what''s underneath it. Which indicates:

- Render the scene without the translucent object to a texture (or use an environment map if that''s all that is behind)

- Apply that texture to the translucent object and blur (multipass/multistage with texture coordinate offsets, or pixel shader, or bilinear filtering - each has its own tradeoffs/issues)


If you visit the ATI and nVidia developer websites you can download sample source code and papers describing the technique in more detail.


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

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

Ah. Webster''s says:
quote:Translucence \Trans*lu"cence\, Translucency \Trans*lu"cen*cy\, n. The quality or state of being translucent; clearness; partial transparency. --Sir T. Browne.


Other dictionaries also offer:
quote:Transmitting light but causing sufficient diffusion to prevent perception of distinct images.


So there are different definitions. Clarification please

~CGameProgrammer( );
DevImg.net - Post screenshots, comment on others.
Town 3D Engine - A city-rendering 3D engine. Download the demo.
~CGameProgrammer( );Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
You should also check out the RGB encoded depth part of Nvidia's GDC2003 presentation on DirectX special effects. They initially used it for volume fog, but it looks pretty cool for translucent objects.

D3DTutorial_EffectsNV.pdf

Pinz

[edited by - Pinzmon on April 29, 2003 3:06:57 PM]


Oxford English Dictionary offers something in between:

translucent /tranz-loo-suhnt, trahnz-loo-suhnt / - adj. allowing light to pass through partially.

ORIGIN: Latin translucere ''shine through''


The 1913 edition of Websters seems to differ from the modern one too :
http://machaut.uchicago.edu/cgi-bin/WEBSTER.page.sh?PAGE=1530

"1. Transmitting rays of light without permitting objects to be distinctly seen; partially transparent.

Syn. -- Translucent, Transparent. A thing is translucent when it merely admits the passage of light, without enabling us to distinguish the color and outline of objects through it; it is transparent when we can clearly discern objects placed on the other side of it. Glass, water, etc., are transparent; ground glass is translucent; a translucent style. "


Yay, we''ve found something the dictionaries aren''t so clear on.


So I guess it''s over to Kryptus to specify what he considers "translucency (NOT TRANSPARENCY!!!)" to mean


[A quick warning: don''t Google for things in Latin or you may get unexpected matches - eek ooer!]

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

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

This topic is closed to new replies.

Advertisement