Hi, Recent I have coded the hdr that based on ps_1_1.
In addition, It had quad algorithm. however, when I executed it ,
Screen Quad Object was not rendered. Hmm...
I uploaded src.
shader code:
/* Variable */
float2 HDR_ViewSize;
float HDR_Width = 0.015f ;
float HDR_Power = 0.15f ;
/* Texture */
texture Scene_Frame < string Name = " "; >;
/* Sampler */
sampler2D Sampler_Frame = sampler_state { Texture = <Scene_Frame>; ADDRESSU = CLAMP; ADDRESSV =CLAMP; ADDRESSW=CLAMP; };
/* Structure */
struct Struct_Input
{
float4 Quad_Position : POSITION;
float2 Quad_UV : TEXCOORD;
};
struct Struct_Output
{
float4 Quad_Position : POSITION;
float2 Quad_Tex1 : TEXCOORD0;
float2 Quad_Tex2 : TEXCOORD1;
float2 Quad_Tex3 : TEXCOORD2;
float2 Quad_Tex4 : TEXCOORD3;
};
struct Struct_OutputTone
{
float4 Quad_Position : POSITION;
float2 Quad_Tex : TEXCOORD0;
};
struct Struct_OutputFrame
{
float4 Quad_Position : POSITION;
float2 Quad_Tex : TEXCOORD0;
};
/* Vertex Shder */
Struct_Output VS_BlurX1( Struct_Input IN )
{
//Prepare Output Structure
Struct_Output OUT;
//Local Variable
float2 Quad_VertexPos = IN.Quad_UV ;
Quad_VertexPos.y = 1.0f - Quad_VertexPos.y ;
Quad_VertexPos = Quad_VertexPos * 2.0f - 1.0f;
//Calculate Quad To Screen
OUT.Quad_Position = float4( Quad_VertexPos.x - ( 1.0f / HDR_ViewSize.x ) , Quad_VertexPos.y + ( 1.0f / HDR_ViewSize.y ) , 1.0f , 1.0f );
//Calculate Quad Blur
OUT.Quad_Tex1 = IN.Quad_UV + HDR_Width * ( 1 * float2( 0.5 , 0 ) );
OUT.Quad_Tex2 = IN.Quad_UV + HDR_Width * ( 1 * float2( 1.0 , 0 ) );
OUT.Quad_Tex3 = IN.Quad_UV + HDR_Width * ( 1 * float2( 1.5 , 0 ) );
OUT.Quad_Tex4 = IN.Quad_UV + HDR_Width * ( 1 * float2( 2.0 , 0 ) );
//Output Result
return OUT;
}
Struct_Output VS_BlurX2( Struct_Input IN )
{
//Prepare Output Structure
Struct_Output OUT;
//Local Variable
float2 Quad_VertexPos = IN.Quad_UV ;
Quad_VertexPos.y = 1.0f - Quad_VertexPos.y ;
Quad_VertexPos = Quad_VertexPos * 2.0f - 1.0f;
//Calculate Quad To Screen
OUT.Quad_Position = float4( Quad_VertexPos.x - ( 1.0f / HDR_ViewSize.x ) , Quad_VertexPos.y + ( 1.0f / HDR_ViewSize.y ) , 1.0f , 1.0f );
//Calculate Quad Blur
OUT.Quad_Tex1 = IN.Quad_UV + HDR_Width * ( 1 * float2( -0.5 , 0 ) );
OUT.Quad_Tex2 = IN.Quad_UV + HDR_Width * ( 1 * float2( -1.0 , 0 ) );
OUT.Quad_Tex3 = IN.Quad_UV + HDR_Width * ( 1 * float2( -1.5 , 0 ) );
OUT.Quad_Tex4 = IN.Quad_UV + HDR_Width * ( 1 * float2( -2.0 , 0 ) );
//Output Result
return OUT;
}
Struct_Output VS_BlurY1( Struct_Input IN )
{
//Prepare Output Structure
Struct_Output OUT;
//Local Variable
float2 Quad_VertexPos = IN.Quad_UV ;
Quad_VertexPos.y = 1.0f - Quad_VertexPos.y ;
Quad_VertexPos = Quad_VertexPos * 2.0f - 1.0f;
//Calculate Quad To Screen
OUT.Quad_Position = float4( Quad_VertexPos.x - ( 1.0f / HDR_ViewSize.x ) , Quad_VertexPos.y + ( 1.0f / HDR_ViewSize.y ) , 1.0f , 1.0f );
//Calculate Quad Blur
OUT.Quad_Tex1 = IN.Quad_UV + HDR_Width * ( 1 * float2( 0 , 0.5 ) );
OUT.Quad_Tex2 = IN.Quad_UV + HDR_Width * ( 1 * float2( 0 , 1.0 ) );
OUT.Quad_Tex3 = IN.Quad_UV + HDR_Width * ( 1 * float2( 0 , 1.5 ) );
OUT.Quad_Tex4 = IN.Quad_UV + HDR_Width * ( 1 * float2( 0 , 2.0 ) );
//Output Result
return OUT;
}
Struct_Output VS_BlurY2( Struct_Input IN )
{
//Prepare Output Structure
Struct_Output OUT;
//Local Variable
float2 Quad_VertexPos = IN.Quad_UV ;
Quad_VertexPos.y = 1.0f - Quad_VertexPos.y ;
Quad_VertexPos = Quad_VertexPos * 2.0f - 1.0f;
//Calculate Quad To Screen
OUT.Quad_Position = float4( Quad_VertexPos.x - ( 1.0f / HDR_ViewSize.x ) , Quad_VertexPos.y + ( 1.0f / HDR_ViewSize.y ) , 1.0f , 1.0f );
//Calculate Quad Blur
OUT.Quad_Tex1 = IN.Quad_UV + HDR_Width * ( 1 * float2( 0 , -0.5 ) );
OUT.Quad_Tex2 = IN.Quad_UV + HDR_Width * ( 1 * float2( 0 , -1.0 ) );
OUT.Quad_Tex3 = IN.Quad_UV + HDR_Width * ( 1 * float2( 0 , -1.5 ) );
OUT.Quad_Tex4 = IN.Quad_UV + HDR_Width * ( 1 * float2( 0 , -2.0 ) );
//Output Result
return OUT;
}
Struct_OutputTone VS_Tone( Struct_Input IN )
{
//Prepare Output Structure
Struct_OutputTone OUT;
//Local Variable
float2 Quad_VertexPos = IN.Quad_UV ;
Quad_VertexPos.y = 1.0f - Quad_VertexPos.y ;
Quad_VertexPos = Quad_VertexPos * 2.0f - 1.0f;
//Calculate Quad To Screen
OUT.Quad_Position = float4( Quad_VertexPos.x - ( 1.0f / HDR_ViewSize.x ) , Quad_VertexPos.y + ( 1.0f / HDR_ViewSize.y ) , 1.0f , 1.0f );
//Calculate Quad UV
OUT.Quad_Tex = IN.Quad_UV;
//Output Result
return OUT;
}
Struct_OutputFrame VS_Frame( Struct_Input IN )
{
//Prepare Output Structure
Struct_OutputTone OUT;
//Local Variable
float2 Quad_VertexPos = IN.Quad_UV ;
Quad_VertexPos.y = 1.0f - Quad_VertexPos.y ;
Quad_VertexPos = Quad_VertexPos * 2.0f - 1.0f;
//Calculate Quad To Screen
OUT.Quad_Position = float4( Quad_VertexPos.x - ( 1.0f / HDR_ViewSize.x ) , Quad_VertexPos.y + ( 1.0f / HDR_ViewSize.y ) , 1.0f , 1.0f );
//Calculate Quad UV
OUT.Quad_Tex = IN.Quad_UV;
//Output Result
return OUT;
}
/* Pixel Shader */
float4 PS_HDR( Struct_Output IN ) : COLOR
{
//Local Variable
float4 Texture_Pixel = tex2D( Sampler_Frame , IN.Quad_Tex1 );
//Calculate Pixel
Texture_Pixel = Texture_Pixel + tex2D( Sampler_Frame , IN.Quad_Tex2 ) ;
Texture_Pixel = Texture_Pixel + tex2D( Sampler_Frame , IN.Quad_Tex3 ) / 2;
Texture_Pixel = Texture_Pixel + tex2D( Sampler_Frame , IN.Quad_Tex4 ) / 2;
//Output Result
return Texture_Pixel;
}
float4 PS_Tone( Struct_OutputTone IN ) : COLOR
{
//Local Variable
float4 Texture_Tone = tex2D( Sampler_Frame , IN.Quad_Tex );
//Calculate Pixel
Texture_Tone = pow( Texture_Tone , 3 );
//Output Result
return Texture_Tone;
}
float4 PS_Frame( Struct_OutputTone IN ) : COLOR
{
//Local Variable
float4 Texture_Frame = tex2D( Sampler_Frame , IN.Quad_Tex );
//Output Result
return ( Texture_Frame * HDR_Power );
}
/* Technique */
technique HDR_Tone
{
pass Tone_Pass1
{
vertexShader = compile vs_1_1 VS_Tone();
pixelShader = compile ps_1_1 PS_Tone();
}
}
technique HDR_BlurX
{
pass BlurX_Pass1
{
VertexShader = compile vs_1_1 VS_BlurX1();
PixelShader = compile ps_1_1 PS_HDR() ;
SrcBlend = One ;
DestBlend = One ;
}
pass BlurX_Pass2
{
VertexShader = compile vs_1_1 VS_BlurX2();
PixelShader = compile ps_1_1 PS_HDR() ;
SrcBlend = One ;
DestBlend = One ;
AlphaBlendEnable = True ;
}
}
technique HDR_BlurY
{
pass BlurY_Pass1
{
VertexShader = compile vs_1_1 VS_BlurY1();
PixelShader = compile ps_1_1 PS_HDR() ;
SrcBlend = One ;
DestBlend = One ;
}
pass BlurY_Pass2
{
VertexShader = compile vs_1_1 VS_BlurY2();
PixelShader = compile ps_1_1 PS_HDR() ;
SrcBlend = One ;
DestBlend = One ;
AlphaBlendEnable = True ;
}
}
technique HDR_Frame
{
pass Frame_Pass1
{
VertexShader = compile vs_1_1 VS_Frame();
PixelShader = compile ps_1_1 PS_Frame();
SrcBlend = One ;
DestBlend = One ;
AlphaBlendEnable = True ;
}
}
Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.