Shaders - Fast Aproximate Screen Space Reflections
/
0 Comments
A while back, when working on my first engine, Atom Engine (DirectX 9), I played a bit with shaders for reflections. A fast but extremely hacky method to get them is to grab the pixel coordinates (in screen space), and negate them in the y or x axis. Then just add them up with the color.
Shader Snippet (HLSL) for the simple case
In practice, it works quite good.
You can extend it by adding a lot of blur, and also by using the surface normal to select the axist to negate. For example, negating both the x and y axis and using the reflection vector to mix both.
You can extend it by adding a lot of blur, and also by using the surface normal to select the axist to negate. For example, negating both the x and y axis and using the reflection vector to mix both.
Below there are a couple screens, that just negate the y axis, and add too little some blur.
![]() |
Works best for planar surfaces |
![]() |
The black regions are caused by the addressing mode. Should be set to wrap |
// sspixel = coordinates in screen space (normalized 0 to 1) float2 newPixel = sspixel; newPixel.y = 1 - newPixel.y; // DX 9 Style float3 reflection = tex2D(texSampler,newPixel); // DX >10 Style //float3 reflection = colTexture.SampleLevel(texSampler,newPixel,0);