Hello together,
inspired by the Blog-Snapshoot cooktorrence-(ex9.effect)-help-renderer last Week, I am currently porting @dottore two Pass CookTorranceMultiTexFresnel-Shader from DX9 to DX11. At the moment the Shader is rendering only the Fresnel–Pass or the CookTorrance-Pass depending on direction.
I have implemented the Depth, Blend and Rasterizer States for the Passes so I know the fundamental techniques I am using is working.
Is it possible to do two or more Passes in DX11? I see in DX9 we have a Technique Pass Pin, but he exists not in the DX11 Layout.
DX9 Technique
technique CookTorranceMultiTextureFresnel <string Script = "Pass=p0; Pass=p1;";>
{
// shared lighting: ambient, environment, and Z
pass p0 <string Script = "Draw=geometry;";>
{
VertexShader = compile vs_1_1 fresVS();
ZEnable = true;
ZWriteEnable = true;
CullMode = None;
PixelShader = compile ps_1_1 fresPS_t();
}
// pass for each lamp (repeat for multiple lamps)
pass p1 <string Script = "Draw=geometry;";>
{
VertexShader = compile vs_1_1 cookTorrMultVS();
ZEnable = true;
ZWriteEnable = false;
ZFunc = LessEqual;
CullMode = None;
AlphaBlendEnable = true;
SrcBlend = One;
DestBlend = One;
PixelShader = compile ps_1_1 cookTorrMultPS_t()
}
}
DX11 Technique
// Depth-Stencil State /////////////////////////////////////////////////////////////////////////// /////
DepthStencilState Depth_Fresnel
{
DepthEnable = TRUE;
DepthWriteMask = ALL;
DepthFunc = LESS_EQUAL;
StencilEnable = TRUE;
};
DepthStencilState Depth_CookTorrance
{
DepthEnable = TRUE;
};
// Blend State /////////////////////////////////////////////////////////////////////////// /////
BlendState Blend_Fresnel
{
};
BlendState Blend_CookTorrance
{
AlphaToCoverageEnable = TRUE;
BlendEnable[0](0) = TRUE;
SrcBlend = ONE;
DestBlend = ONE;
BlendOp = ADD;
BlendOpAlpha = ADD;
RenderTargetWriteMask[0](0) = 0x0F;
};
// Rasterizer State /////////////////////////////////////////////////////////////////////////// /////
RasterizerState Rasterizer_Fresnel
{
CullMode = NONE;
};
RasterizerState Rasterizer_CookTorrance
{
CullMode = NONE;
};
/////////////////////////////////////////////////////////////////////////// /////
technique10 CookTorranceFresnel <string Script = "Pass=p0;Pass=p1";>
{
pass p0 <string Script = "Draw=geometry;"; >
{
SetVertexShader( CompileShader( vs_4_0, Fresnel_VS() ) );
SetRasterizerState(Rasterizer_Fresnel);
SetBlendState(Blend_Fresnel, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetDepthStencilState(Depth_Fresnel, 0); SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, Fresnel_PS() ) );
}
pass p1 <string Script = "Draw=geometry;";>
{
SetVertexShader( CompileShader( vs_4_0, CookTorrance_VS() ) ); SetRasterizerState(Rasterizer_CookTorrance);
SetBlendState(Blend_CookTorrance, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetDepthStencilState(Depth_CookTorrance, 0);
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, CookTorrance_PS() ) );
}
}
For the Test I write a single Fresnel and a CookTorrance-Shader and combine these Layers in a Extra Patch.
Thanks for tips!