I wrote shader code in dbs. but
I really don't know why it was occurred.
Could help me please?
string Description = "PUPPYSSS Post Process 1.0";
string Thumbnail = "PostProcess.png";
/* PUPPYSSS Post Process Data */
//Screen Data
float2 Screen_Size;
const float Screen_ReduceRatio = 0.25;
const float Screen_Vectors[7] = {0.01 ,0.02 , 0.03 , 0.04 , 0.03 , 0.02 , 0.01 };
//Scene Data
float Scene_Brightness;
//High Dynamic Range Data
float HDR_Width <> = 0.006f;
float HDR_Power <> = 2.0f;
//Blur Data
float Blur_Volume <> = 0.0f;
/* PUPPYSSS Post Process Texture */
//Scene Source Texture
texture Scene_Source : RENDERCOLORTARGET
<
string ResourceName = "";
float2 ViewportRatio = { 1.0, 1.0 };
>;
//Scene Downsample Texture
texture Scene_Downsample : RENDERCOLORTARGET
<
string ResourceName = "";
float2 ViewportRatio = { 0.25, 0.25 };
>;
//Scene HDR Tone Texture
texture Scene_Tone : RENDERCOLORTARGET
<
string ResourceName = "";
float2 ViewportRatio = { 0.0625, 0.0625 };
>;
//Scene HDR Process Texture
texture Scene_HDR_Process : RENDERCOLORTARGET
<
string ResourceName = "";
float2 ViewportRatio = { 0.0625, 0.0625 };
>;
//Scene Blur Process Texture
texture Scene_Blur_Process : RENDERCOLORTARGET
<
string ResourceName = "";
float2 ViewportRatio = { 0.0625, 0.0625 };
>;
/* PUPPYSSS Post Process Sampler */
//Scene Source Sampler
sampler2D Scene_Sampler_Source = sampler_state {
Texture = < Scene_Source >;
MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;
AddressU = Wrap; AddressV = Wrap;
};
//Scene Downsample Sampler
sampler2D Scene_Sampler_DownSample = sampler_state {
Texture = < Scene_DownSample >;
MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;
AddressU = Clamp; AddressV = Clamp;
};
//Scene HDR Tone Sampler
sampler2D Scene_Sampler_Tone = sampler_state {
Texture = < Scene_Tone >;
MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;
AddressU = Clamp; AddressV = Clamp;
};
//Scene HDR Process Sampler
sampler2D Scene_Sampler_HDR_Process = sampler_state {
Texture = < Scene_HDR_Process >;
MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;
AddressU = Clamp; AddressV = Clamp;
};
//Scene Blur Process Sampler
sampler2D Scene_Sampler_Blur_Process = sampler_state {
Texture = < Scene_Blur_Process >;
MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;
AddressU = Clamp; AddressV = Clamp;
};
/* PUPPYSSS Post Process Structure */
//Input Data
struct Scene_Input
{
float4 Scene_UV : TEXCOORD;
};
//Output Data
struct Scene_Output
{
float4 Scene_Position : POSITION;
float2 Scene_Vector[7] : TEXCOORD0;
};
/* PUPPYSSS Post Process Vertex Shader Progress */
//Calculate Scene Vector Of Screen Quad
Scene_Output PostProcess_Scene_VS( Scene_Input IN , uniform float2 Direction )
{
//Set Output To Result
Scene_Output OUT;
//Set Texel Size
float2 TexelSize = HDR_Width;
//Set Vertex Vector
float2 VertexVector = Scene_UV;
//Calculate Scene Vector
float2 SceneVector = IN.Scene_UV - ( TexelSize * ( ( 7 - 1 ) * ( 0.5 * Direction ) ) );
VertexVector.y = 1.0f - VertexVector.y;
VertexVector = ( VertexVector * 2.0f ) - 1.0f;
//Calculate Scene Vector
for(int Index = 0 ; Index < 7 ; Index++ )
{
OUT.Scene_Vector[ Index ] = SceneVector + ( ( TexelSize * Index ) * Direction );
}
//Calculate Output Scene Vector
OUT.Scene_Position = float4( VertexVector.x - ( 1.0f / Screen_Size.x ) , VertexVector.y + ( 1.0f / Screen_Size.y ) , 1.0f , 1.0f );
//Return Output
return OUT;
}
/* PUPPYSSS Post Process Pixel Shader Progress */
float4 PostProcess_DownSample_PS( Scene_Output IN , uniform sampler2D Sampler_Input ) : COLOR
{
//Set DownSample Information
float4 Scene_Pixel = 0;
float2 Scene_Scale = Screen_ReduceRatio / Screen_Size;
//Reduce Main Frame Scene
for( int Index = 0 ; Index < 7 ; Index++ )
{
Scene_Pixel += tex2D( Sampler_Input , IN.Scene_Vector[ Index ] * Scene_Scale );
}
//Return Pixel Result
return Scene_Pixel / 7;
}
float4 PostProcess_Tone_PS( Scene_Output IN , uniform sampler2D Sampler_Input ) : COLOR
{
//Set Tone Information
float4 Tone_Pixel = 0;
//Get Input Scene
for( int Index = 0 ; Index < 7 ; Index++ )
{
Tone_Pixel += tex2D( Sampler_Input , IN.Scene_Vector[ Index ]);
}
//Tone Input Scene
Tone_Pixel = pow( Tone_Pixel * Scene_Brightness , 10 );
//Return Pixel Result
return Tone_Pixel;
}
float4 PostProcess_HDR_PS( Scene_Output IN , uniform sampler2D Sampler_Input ) : COLOR
{
//Set HDR Information
float4 HDR_Pixel = 0;
//Scatter HDR Scene
for( int Index = 0 ; Index < 7 ; Index++ )
{
HDR_Pixel += ( tex2D( Sampler_Input , IN.Scene_Vector[ Index ]) * Screen_Vectors[ Index ] );
}
//Set HDR Scene Alpha
HDR_Pixel.a = 1.0f;
//Return Pixel Result
return HDR_Pixel * HDR_Power;
}
float4 PostProcess_Blur_PS( Scene_Output IN , uniform sampler2D Sampler_Input ) : COLOR
{
//Set Blur Information
float4 Blur_Pixel = 0;
//Get Blur Scene
for( int Index = 0 ; Index < 7 ; Index++ )
{
Blur_Pixel += tex2D( Sampler_Input , IN.Scene_Vector[ Index ] * ( Screen_Vectors[ Index ] + Blur_Volume ) );
}
//Return Pixel Result
return Blur_Pixel;
}
float4 PostProcess_Rendering_PS( Scene_Input IN ) : COLOR
{
//Set Rendering Information
float4 Source_Pixel = tex2D( Scene_Sampler_Source , IN.Scene_UV );
//Accumulate Calculated Scene
Source_Pixel += tex2D( Scene_Sampler_HDR_Process , IN.Scene_UV );
Source_Pixel += tex2D( Scene_Sampler_Blur_Process , IN.Scene_UV );
//Return Result Pixel
return float4( Source_Pixel , 1.0f );
}
/* PUPPYSSS Post Process Technique */
technique PUPPYSSS_PostProcess
<
//Input Main Scene Source
string RenderColorTarget = "Scene_Source";
>
{
pass PostProcess_DownSample
<
//Get DownSample Texture
string RenderColorTarget = "Scene_Downsample";
>
{
ZEnable = False;
VertexShader = compile vs_2_0 PostProcess_Scene_VS( float2( 0 , 0 ) );
PixelShader = compile vs_2_0 PostProcess_DownSample_PS( Scene_Sampler_Source );
}
pass PostProcess_Tone
<
//Get Tone Texture
string RenderColorTarget = "Scene_Tone";
>
{
ZEnable = False;
VertexShader = compile vs_2_0 PostProcess_Scene_VS( float2( 0 , 0 ) );
PixelShader = compile vs_2_0 PostProcess_Tone_PS( Scene_Sampler_DownSample );
}
pass PostProcess_HDR
<
//Get HDR Texture
string RenderColorTarget = "Scene_HDR_Process";
>
{
ZEnable = False;
VertexShader = compile vs_2_0 PostProcess_Scene_VS( float2( 0 , 0 ) );
PixelShader = compile vs_2_0 PostProcess_HDR_PS( Scene_Sampler_HDR_Process );
}
pass PostProcess_Blur
<
//Get Blur Texture
string RenderColorTarget = "Scene_Blur_Process";
>
{
ZEnable = False;
VertexShader = compile vs_2_0 PostProcess_Scene_VS( float2( 0 , 0 ) );
PixelShader = compile vs_2_0 PostProcess_Blur_PS( Scene_Sampler_DownSample );
}
pass PostProcess_Rendering
<
//Render Final Texture
string RenderColorTarget = "";
>
{
ZEnable = False;
VertexShader = compile vs_2_0 PostProcess_Scene_VS( float2( 0 , 0 ) );
PixelShader = compile vs_2_0 PostProcess_Rendering_PS();
}
}
Knowledge Is Well-Known Wisdom.
So Wisdom Is Very Absolute.