2 pass rendering

Posted By: Matt_Aufderheide

2 pass rendering - 11/17/03 22:56

Anyone know how to blend or multiply the result of the first pass with the 2nd pass?
Posted By: Matt_Aufderheide

Re: 2 pass rendering - 11/18/03 07:04

i assume its done right after the second pass starts..before you assign the constants... does anyone know how to use the d3d fixed function stuff? maybe thast how multiply the passes
Posted By: ventilator

Re: 2 pass rendering - 11/18/03 07:11

i would also be interested in this. how can the results from the first pass be accessed in the second pass?
Posted By: Matt_Aufderheide

Re: 2 pass rendering - 11/18/03 07:23

i found some relevant d3d texture state code..
g_App.GetDevice()->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_ZERO); //blend factors
g_App.GetDevice()->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_SRCCOLOR);
but i dont know how the translates to gamestudio,.. Jcl? are you out there?
Posted By: mss

Re: 2 pass rendering - 11/18/03 16:30

You can set renderstates in the effectfile, for instance
Code:
 
pass p1
{
...
AlphaBlendEnable = True;
SrcBlend = Zero;
DestBlend = SrcColor;
...

}



Posted By: jcl

Re: 2 pass rendering - 11/18/03 19:22

You can normally only use blending operations for multiple passes. However, by inverse blending with inverted textures you can also achieve effects that are not, but look like multiplication. For instance, lightmap rendering normally requires a multiplication, but the A4 engine used two-pass-blending with an inverted lightmap for the lightmap rendering on weak 3D cards.
Posted By: Matt_Aufderheide

Re: 2 pass rendering - 11/18/03 20:36

Thnx mss, thats the syntax i needed..
for future refernce.. where do you guys figure out the way the translate the d3d texture state code to the gamestudio syntax..
Posted By: mss

Re: 2 pass rendering - 11/18/03 21:29

Try this.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndrive/html/directx04152003.asp
Posted By: jcl

Re: 2 pass rendering - 11/18/03 21:37

Matt: If you have the DirectX8 Documentation, it's under DirectX Graphics -> Reference -> Effect Files Reference -> Effect File States.
Posted By: Matt_Aufderheide

Re: 2 pass rendering - 11/18/03 22:18

ok thnx
Posted By: ventilator

Re: 2 pass rendering - 04/23/04 08:51

i still don't understand how this works.

i have an effect which uses 3 texture stages:

colormap
detailmap
shadowmap

the shadow map does only contain shadows and no lighting information (white = no shadow, black = shadow). so i use modulate and not modulate2x.

for older cards i would like to render the shadow map in a second pass.

i enabled alpha blending and tried all

SrcBlend
DestBlend

combinations but nothing worked properly. what exactly is the source and what the destination? what do i have to set as colorop in the second pass? how does rendering such an effect in two passes work? do i need an alpha channel?
Posted By: Steempipe

Re: 2 pass rendering - 04/23/04 10:36

I have been screwing with this a little too. To see Pass p0 an p1 you will
need to look at the fixed-function multitex at my site/





The basic way I am adding a shadow map is this way, and it is happening
in Pass p2:

Pass p0
{
.... lay down the base skin
.... using tex[0]
}

Pass p1
{
.... Add a second texture using an alphamap
.... Using Texture 0,1
}

Pass p2
{

alphaop[0]=disable; // Frame buffer is filled, but no alphaops wanted

alphablendenable=true;

SRCBLEND=ZERO; // <<<<<<<<<<<<<
DESTBLEND=SRCCOLOR; // <<<<<<<<<<<<<

zenable=true;
zwriteenable=true;
ditherenable=true;

Texture[1] = <mtlSkin2>;

magFilter[1]=linear;
minFilter[1]=linear;
mipFilter[1]=linear;

TextureTransformFlags[1] = disable;

texcoordindex[1]=1;

}
Posted By: ventilator

Re: 2 pass rendering - 04/23/04 22:13

thanks! i got it to work. the reason for the problem was this:

first pass:

colormap
detailmap

second pass:

shadowmap
disable

if you don't disable the second texture stage of the second pass it uses the same settings as in the first pass which leads to strange results!
Posted By: Steempipe

Re: 2 pass rendering - 04/24/04 10:03

I see...

Your note about disabling the pass 2/ stage 2 operations made sense.

I made a new project, did not do any masking of textures and disabled the 2nd stage of pass 2. In the earlier reply I think I had to disable AlphaOp because I was using alphamap in the previous passes. I suppose I could have done that in the 2nd stage as well.

Here are some shots for comparing shadow, diffuse light, and just a detail map.
web page
© 2024 lite-C Forums