   Mulitpass rendering - noob question
  I'm investigating multi-pass rendering using DX9/HLSL.  I'd like to render a simple object using two different materials.  Each material has its own index buffer meaning there will be one DIP call per material - the materials will blend with each other if they share vertices.  After a bit of research on the subject I'm a bit confused about the second pass:I have a brand new blank back buffer.  In the first pass, I render the first part of the object in a DIP call using material A.  At the edges of the shape, I blend the material out to zero.  What then happens with the second/third DIP call for material B/C, etc?Do I need to render each part/material to a render target and pass that on to the next DIP call?orIn a pixel shader, can I get at what is currently in the back buffer in order to blend the second material with the first?  Is this done with some kind of alpha blending pass state?I know you can draw subsets in meshes but this is a little different because of the blending between materials - plus I'm not using meshes, just a straight forward vertex buffer and two (or more) index buffers.Thanks   
  Generally you do this by setting the blending render states.  When AlphaBlendEnable is set to true, your blending equation works like this:final.rgb = (output.rgb * SrcBlend) [BlendOp] (backbuffer.rgb * DestBlend);final.a = (output.a * AlphaSrcBlend) [AlphaBlendOp] (backbuffer.a * AlphaDestBlend);So how it works is the output (the value returned by your pixel shader) is multipled by some value, the current backbuffer value is multiplied by some value, and then some mathematical operation is used to combine these two products.  The default for BlendOp and AlphaBlendOp is "ADD", which ill add the two products.  For your case, what you probably want is this:final.rgb = (output.rgb * 1) + (backbuffer.rgb * 1);final.a = (output.a * 1) + (backbuffer.a * 1);This is because with multipass lighting, what you're doing is accumulating the contribution from multiple light sources.  Therefore you want to sum the contributions.  To get that that blending equation, you'd use the following effect states:AlphaBlendEnable = true;SrcBlend = ONE;DestBlend = ONE;BlendOp = ADD;AlphaSrcBlend = ONE;AlphaDestBlend = ONE;AlphaBlendOp = ADD;You can also do other things for you want... for instance with transparencies it's common to set SrcBlend to "SRCALPHA", and DestBlend to "INVSRCALPHA".  This allows the alpha channel of your pixel shader output to control the opacity of what you're rendering.   ;  Thanks, Matt, that explains it perfectly.I'm probably going to be using deferred shading/lighting, so I think the backBuffer in this case will actually be a texture after all which will serve as the diffuse buffer.  I'll then store the normals in another buffer and so on, so the lighting will be done at a later stage.Out of curiousity, what does the ONE enumeration actually mean on the xBlend states?Thanks   ;Quote:Original post by RobMaddisonOut of curiousity, what does the ONE enumeration actually mean on the xBlend states?It means "multiply the value by 1".  So since you just want to add the incoming value and the framebuffer value, you multiply them by one so that they stay the same.