BredaUniversityGames / DXX-Raytracer

DXX Raytracer is a fork of the DXX Retro project for Windows. DXX Raytracer uses modern raytracing techniques to update the graphics of the beloved retro game known as Descent.
Other
216 stars 10 forks source link

Add Parallax Mapping Support #28

Open Lehm2000 opened 1 month ago

Lehm2000 commented 1 month ago

This pull request adds parallax mapping support. This works by added a new height texture slot (grayscale) and using that texture to offset all the other texture maps by a calculated parallax to give the impression of depth/height for surfaces. The supplied height texture should use middle gray for base surface. Darker shades of gray will appear to recess into the surface, lighter shades will appear to pop out of the surface. This addition is currently limited to parallaxing the color channel and does not update the lighting and depth calculations which can result in some minor graphical oddities. This addition does result in a 2-3% performance hit. I added a toggle in the raytracing settings to allow for disabling of the effect.

Off scrn0061 On scrn0059 Off scrn0064 On scrn0063

scrn0056

Changes:

RTmaterials.h

RTmaterials.c

Renderer.h

shared_common.hlsl.h

primary_ray.hlsli

GlobalDX.h

RenderBackend.cpp

menu.c

shared_tweakvars.hlsl.h

Issues: This addition does create some minor graphical issues to be aware of and may need additional work to address. As this update does not update the lighting calculations the lighting does not move with the parallaxing texture resulting in the lighting appearing to "slide" against texture. Most noticeable in darker areas with a bright light source like a flare, brightly lit areas the issue isn't really noticeable.

The addition of depth can cause textures that were not meant to wrap to be wrapped like the below light texture. It might be possible to add a new mirrored texture sampler to address this issue, but is not part of this PR. scrn0065 scrn0066