Hi guys,
right now I'm having a program which is supposed to render multiple passes. So my theory was as following:
Shader Pass Color Alpha = 1.0f/AmountOfPasses
And this would be true for all shaders. But the problem is that it doesn't really work. It it like e.g. two passes, first.alpha: 0.5 second.alpha:1 or something like that?
Well my method doesn't really seem to work as the second pass isn't visible for some reason. But no matter if my shaders are somehow wrong, what is the correct way to render multiple passes to get one image?
My Shader:
cbuffer ConstantObjectBuffer
{
float4x4 final;
float4x4 rotation;
float4 ambientcol;
float3 space;
float alpha;
}
cbuffer ConstantFrameBuffer
{
float4 lightvec;
float4 lightcol;
}
struct VOut
{
float4 position : SV_POSITION;
float4 normal : NORMAL;
float4 color : COLOR;
};
VOut VShader(float4 position : POSITION, float4 normal : NORMAL)
{
VOut output;
output.position = mul(final, position);
// set the ambient light
output.color = ambientcol;
// calculate the diffuse light and add it to the ambient light
float4 norm = normalize(mul(rotation, normal));
float diffusebrightness = saturate(dot(norm, lightvec));
output.color += lightcol * diffusebrightness;
output.color.a = alpha;
return output;
}
float4 PShader(VOut input) : SV_TARGET
{
return input.color;
}
The alpha amount is calculated in c++, like this:
ObjectBuffer.Alpha = 1.0f/(float)(Passes.getAlpha()); // .getAlpha = get all passes except lighting (e.g. texture, bump mapping...)
if (Passes.Lighting)
ObjectBuffer.Alpha += Lights.Directional.size();
Thank You