Graphics Reference
In-Depth Information
// Horizontal blur shader entry point in
// psHorizontalGaussianBlur. hlsl
float4
main
(
PS_INPUT input
):
SV_Target
{
// Texture/image coordinates to sample/load the color values
// with .
float2
texcoords
=
input
.
tex
;
float4
color
;
// Sample the color values and weight by the pre
−
calculated
// normalized Gaussian weights horizontally .
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(
−
3, 0 ) )
0.001
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(
−
2, 0 ) )
0.028
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(
−
1, 0 ) )
0.233
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(0, 0))
0.474
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(1, 0))
0.233
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(2, 0))
0.028
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(3,
0))
0.001
f
;
return
color
;
}
// Vertical blur shader entry point in
// psVerticalGaussianBlur . hlsl
float4
main
(
PS_INPUT input
):
SV_Target
{
// Texture/image coordinates to sample/load the color values
// with .
float2
texcoords
=
input
.
tex
;
float4
color
;
// Sample the color values and weight by the pre
−
calculated
// normalized Gaussian weights vertically .
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(0, 3))
0.001
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(0, 2))
0.028
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(0, 1))
0.233
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(0, 0))
0.474
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(0,
−
1))
0.233
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(0,
−
2))
0.028
f
;
color
+=
colorBuffer
.
SampleLevel
(
pointSampler
,
texcoords
,
prevLevel
,
int2
(0,
−
3))
0.001
f
;
return
color
;
}
Listing 4.6.
Simple horizontal and vertical separable blur shaders, with a 7
×
7kernel.