-
Notifications
You must be signed in to change notification settings - Fork 0
/
Blur_pp.hlsl
40 lines (31 loc) · 1.59 KB
/
Blur_pp.hlsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//--------------------------------------------------------------------------------------
// Blur Post-Processing Pixel Shader
//--------------------------------------------------------------------------------------
#include "Common.hlsli"
//--------------------------------------------------------------------------------------
// Textures (texture maps)
//--------------------------------------------------------------------------------------
// The scene has been rendered to a texture, these variables allow access to that texture
Texture2D SceneTexture : register(t0);
SamplerState PointSample : register(s0); // We don't usually want to filter (bilinear, trilinear etc.) the scene texture when
// post-processing so this sampler will use "point sampling" - no filtering
//--------------------------------------------------------------------------------------
// Shader code
//--------------------------------------------------------------------------------------
// Post-processing shader that blurs the scene texture
float4 main(PostProcessingInput input) : SV_Target
{
float4 colour;
float j; // Used for the blur
const float blurQuality = 64; // The higher the number, the better the quality of the blur
// Blur the scene texture by sampling the scene texture multiple times and averaging the colour values
for (float i = 0.0f; i < 1.0f; i += (1 / blurQuality))
{
j = 0.9 + i * 0.1f;
colour += SceneTexture.Sample(PointSample, input.sceneUV * j + 0.5f - 0.5f * j);
}
// Divide the colour by the blurQuality to get the average colour
colour /= blurQuality;
//colour.a = 0.1f
return colour;
}