📄 d3dclearbuffer.fx
字号:
/*----------------------------------------------------------------------------*\
|
| Module Details:
|
| Name: D3DFixedFuncShaders.fx
|
| Purpose: Effect file containing all techniques to do window background
| clear
|
| History:
|
| Date Release Name Ver. Comments
| --------- ------- ----- ----- --------------------------------------------
| 13-Feb-09 L-03-27 rds $$1 Created
|
\*----------------------------------------------------------------------------*/
Texture2D TxBackground; /* Background texture image */
float BGAlpha = 1.0f; /* alpha used for blended background clear */
/* Projection matrix */
matrix BGMatrixWorldViewProj;
struct VS_OUTPUT_COLOR
{
float4 cPosition : SV_POSITION; // vertex position in clip space
float4 color : COLOR0; // vertex color
// (note that COLOR0 is clamped from 0..1)
};
struct VS_OUTPUT_TEXTURE
{
float4 cPosition : SV_POSITION; // vertex position in clip spacea
float2 Tex : TEXCOORD0; // vertex UV values
};
SamplerState SamplerTransparent
{
Filter = MIN_MAG_MIP_LINEAR;
AddressU = BORDER;
AddressV = BORDER;
// default border color is 0,0,0,0 - hence transparent
};
/* ******************************************************************* */
VS_OUTPUT_COLOR BGClear_Gradient_VS( float4 vPos : POSITION, float4 color : COLOR )
{
VS_OUTPUT_COLOR Output;
Output.cPosition = mul (vPos, BGMatrixWorldViewProj);
Output.cPosition.w = 1.0;
Output.color = color;
Output.color.a = BGAlpha;
return( Output );
}
float4 BGClear_Gradient_PS( VS_OUTPUT_COLOR In ) : SV_TARGET
{
return (In.color);
}
/* ******************************************************************* */
VS_OUTPUT_TEXTURE BGClear_Texture_VS (float4 vPos : POSITION, float2 Tex : TEXCOORD)
{
VS_OUTPUT_TEXTURE Output;
// Transform the position from object space to clip space
Output.cPosition = mul (vPos, BGMatrixWorldViewProj);
Output.cPosition.w = 1.0;
Output.Tex = Tex;
return Output;
}
float4 BGClear_Texture_PS( VS_OUTPUT_TEXTURE In ) : SV_TARGET
{
float4 Output;
Output.rgb = 0;
Output.a = 1.0;
Output = TxBackground.Sample( SamplerTransparent, In.Tex );
if(Output.a != 0.0)
Output.a = BGAlpha;
return (Output);
}
/* Simple color gradient background clear */
technique10 BGClear_Gradient
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, BGClear_Gradient_VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, BGClear_Gradient_PS() ) );
}
}
/* Technique to clear background using a texture. */
technique10 BGClear_Texture
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, BGClear_Texture_VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, BGClear_Texture_PS() ) );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -