Material alpha blending

Started by
3 comments, last by Arex 18 years, 10 months ago
Hey, I'm currently trying to rebuild Blitz myself - little by little. I have got texture and per vertex alpha blending working, but I can't get material alpha blending working (if thats possible). What I am trying to achieve is so I can just do something like meshCube.Material.Alpha = .5f to make all of the mesh half transparent. Surely I don't have to tweak the vertex alpha of all verts?
Ollie"It is better to ask some of the questions than to know all the answers." ~ James Thurber[ mdxinfo | An iridescent tentacle | Game design patterns ]
Advertisement
In DirectX you'll have to setup RenderState flags for material blending, first of all enable the alpha blending then setup the source and dest blending flags, example of mixed blending:

D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
Sincerely,Arto RuotsalainenDawn Bringer 3D - Tips & Tricks
I don't know about using materials in that manner. I have always assumed (but I could be wrong) that they only change how the light reflects off the object.

There are two ways to do it without using the material. With DX 9, you can use the D3DTA_CONSTANT value in the texture stage state. With older versions, you can use the TFACTOR render state.

Basically, in the texture stage state you would modulate the original vertex (or texture if you so choose, or you could go into texture stage state 1 and use the result from 0 say if you modulated texture and vertex in stage 0) alpha value with the D3DTSS_CONSTANT value, set by calling SetTextureStageState(0, D3DTSS_CONSTANT, SomeValue). SomeValue is the alpha intensity.
Chris ByersMicrosoft DirectX MVP - 2005
I can confirm that light alpha will work in a vertex shader. But in that type of situation, DirectX has little control over what colors get output to the processed vertex. Are you using a vertex shader?

Anyway, I'm almost positive that I did manage to make objects transparent using materials or lights before I got into shaders. I set up a "matrix" type invironment where the walls were all see-through. I can't help much to explain how to do it, but I wanted to make sure you knew it was possible.
I think it's same in vertex shaders do you use light alpha or material alpha, because it will blend the object either of em. Well with light alpha all objects are blended, if we are talking about the same thing. :)

Fixed-T&L lights in DirectX doesn't support alpha value, only materials do.
Sincerely,Arto RuotsalainenDawn Bringer 3D - Tips & Tricks

This topic is closed to new replies.

Advertisement