Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

HLSL code optimize

The following HLSL pixel shader code is used to perform a 4x4 downsample using a simple box filter. give a way to greatly reduce cost of this shader.



float4 g_OffsetsSample[16];

texture g_Texture;

sampler2D g_Sampler = sampler_state;

{

texture = (g_Texture);

MinFilter = Point;

MagFilter = Point;

MipFilter = Point;

};


float4 PSMain(float2 vTexCoord : TEXCOORD0) : COLOR

{

float4 sample = 0.0f;

for(int i =0; i<16;i++)

{

sample += tex2D(g_Sampler, vTexCoord + g_OffsetsSample .xy);

}


return sample * (1/16.f);

}

Answers

Sign In or Register to comment.