How do multiple shaders work in HLSL?

I'm new to shaders and HLSL, having done enough with the BasicEffect class. I understand how the pipeline works, especially for shaders in just 1 pass. However, if you use shaders with 2 or N passes, I don’t quite understand how the results of two (or N) shader outputs are combined.

Could you explain how the combination is combined? And, if possible, an example where you would prefer to use a multi-pass shader rather than multiple single-pass shaders?

+5
source share
2 answers

Multipass shaders simply add results to previous passes. They can be used to support multiple light sources, especially when the GPU shader model does not have enough instructions to support the required number of lights in a single pass.

If you really don't need it, I would not recommend using more than one pass, as it complicates things like alpha blending and fog. You will need to configure your blending states differently in the first pass to the subsequent passes.

[EDIT] AS Melchior Blausand, , , . ADD . , - .

+5

, , BeginPass, . , .

, , () .

0

All Articles