Self Shadowing Parallax Occlusion Shader

Subscribers:
1,270
Published on ● Video Link: https://www.youtube.com/watch?v=fCOzCzdk1V0



Duration: 0:45
143 views
5


The only geometry in this scene are basic cube of 12 triangles each

I take the view vector and transform it into tangent space and step it along, sampling the heightmap texture along the way. I compare the Z height of the position with the texture sampled at the X,Y components. I keep adding this step vector to the position until it is below the height of the height map. When the position is lower than the heightmap, it breaks the loop and moves onto stage2, where it does basically the same thing, but it starts at the current position that it left off, but moves towards the light source. It uses the same sampling method and compares Z position with the texture, if it is below, means the ray has been blocked and this fragment is supposed to be in shadow.

https://pastebin.com/CQqqmypm Fragment Shader Code

Warning, It runs very slow. I'm on a 3080ti