Texture Blending

Started by
4 comments, last by RPTD 22 years, 5 months ago
I try to make my question better. In Quake 3 (I heard) they used up to 10 passes for one single object in the scene. I noticed also (looking at q3ase) that they have support for blending modes like add, modulate, premodulate and so on. In D3D I couldn''t create an effect like this because in looks like there is no way to get d3d to use the texels on the screen as the second blending argument for the first stage. Is this only a functionality that opengl has? And do I have then to blend my textures in software to get the desired effects? This would slow down the whole shit a lot (uhhhhh).

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

Advertisement
The key word here is "PASSES", *multiple* pass rendering means to do something like:

Set base texture
DrawPrimitive() // draw the object
Set light map texture
Set lightmap blending
DrawPrimitive() // draw the object AGAIN

i.e. drawing of the SAME object takes place multiple times. You can do as many passes as you want. The only consequence is the time it takes to re-render each pass.

D3DRS_SRCBLEND, D3DRS_DESTBLEND and D3DRS_BLENDOP renderstates are the main things you use for multiple pass rendering.



What I think you''re thinking of is *single pass multitexture*, where all of the blending is done in one pass using multiple texture stages. This is also possible in D3D, but how many textures can be used simultaneously depends on your hardware.

The texture stage states [SetTextureStageState()] are what you use to control single pass multiple texturing.


You can also combine the two.

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

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

I'', sorry but I can''t find the the render states you are talking about in my directx sdk documentation (using dx7 sdk). Is this a functionality which was introduced later?

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

They had different names in DX 7...

D3DRS_ used to be D3DRENDERSTATE_


The SRCBLEND and DESTBLEND render states allow the following type of operation with the frame buffer:

RESULTrgb = (SRCBLEND * SRCrgb) + (DESTBLEND * DESTrgb)

The DESTrgb is the RGB value of the pixel which is already in the frame buffer (i.e. the result of the previous pass).

The SRCrgb is the RGB value of the pixel from the draw call (e.g. DrawPrimitive).

The SRCBLEND and DESTBLEND states allow different operations. Some examples of the kind of flexibility of operations you can do are:

a)
SRCBLEND = D3DBLEND_ONE
DESTBLEND = D3DBLEND_ONE

The operation performed is:
RESULTrgb = (1 * SRCrgb) + (1 * DESTrgb)


b)
SRCBLEND = D3DBLEND_SRCALPHA
DESTBLEND = D3DBLEND_INVSRCALPHA

The operation performed is:
RESULTrgb = (SRCa * SRCrgb) + ((1-SRCa) * DESTrbg)


c)
SRCBLEND = D3DBLEND_DESTCOLOR
DESTBLEND = D3DBLEND_ZERO

The operation performed is:
RESULTrgb = (DESTrgb * SRCrgb) + (0 * DESTrgb)


D3DRS_BLENDOP is a new state which was introduced in DX8 which extends it to:

RESULTrgb = (SRCBLEND * SRCrgb) BLENDOP (DESTBLEND * DESTrgb)

The new OPs let you replace the + with things like -, min/max operations, reverse subtracts etc.


The SetTextureStageState() values are all present in DX7. (Although a few new ones have been added in DX8).




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

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

Dear S1CA, can you explain me the method to create light map? Otherwise can you tell me where I can find some tutorial?
About that new state, D3DRS_BLENDOP. Is there a way with Direct3D 7 to do the same as D3DBLENDOP_REVSUBTRACT? I am trying to do subtractive blending of a textured poly over the frame buffer.

This topic is closed to new replies.

Advertisement