Blending multipass shader 3ds max

Hi there.

I’m have now reworked my shaderFX shader by hand as I’m used to write hlsl a lot more now.

Anyhow… I’m not sure why the blending result is as it is. The passes are still like shaderFX had created them.
The result looks strange though.

I have a basic understanding of source and destination blend modes but this result makes no sense imo.

For the final result I want to blend the ambient together with 3 light passes but the lights are burning out as you can see.
For the example the ambient pass (p0) is pure black and the first light pass (p1) is just LdotN

That would mean: (whiteLightSpotSource x Blend.SourceAlpha) + (blackAmbientDestination x Blend.One)-> still black
So black + lightspot should be lightspot and not ueberlightspot.

It looks like my alpha is summing up over time… Is this the case and can I prevent it?
Or should I dump it and do it singlepass instead?

Using max 2010 32bit btw.

Which FX parser are you using? (The FX parser is specified at the top of the shader with string ParamID - for example: string ParamID = “0x000001”;). Some of the effects parsers have the nasty side effect of getting multi-pass blending wrong.

hi ben!

I’m using the newer dxsas compiler!

string ParamID = “0x003”;

I tested this and I get the same result when using the dxsas compiler with multiple passes. It’s a bug. You’ve got two options. The first is to use the standard Max compiler. It has it’s own set of bugs, so whether or not you want to use it will depend on what you’re doing. The second option is to do both of your lights in one pass using the dxsas compiler. That’s the one I recommend.

cheers for testing!

I’ll go the singlepass way.

haha… ok not as easy as I thought… every shadow call needs 4 sampler right?
thats 12 for 3 lights… + 11 for all my maps… -> 23 jihaa (max 16)

so I’ll have to pack all shadows (and light colors of course) into an 2nd pass… no way around with an max of 16 sampler

I’ll see how this turns out. I hope the bug won’t hit that hard if I just multiply-blend the 2nd pass