HLSL Code optimize

1 post / 0 new
coderfreak2022's picture
 
Member since October 18, 2022

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);

}

Average: 1 (2 votes)
Copyright © 2010-2013 Sergey "Treidge" Danchenko. Feel free to Contact me with any questions. Theme based on a BlogBuzz design by Antsin.com