Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement r_deluxeMapping, r_specularMapping, r_glowMapping etc. #188

Merged
merged 11 commits into from Mar 30, 2019

Conversation

Projects
None yet
3 participants
@illwieckz
Copy link
Member

illwieckz commented Mar 24, 2019

Some code that implements r_deluxeMapping, r_specularMapping and r_glowMapping.

It's made the way we can disable normal mapping while keeping deluxe mapping.
Of course disabling deluxe mapping disable normal mapping too.

It's made the way we can disable normal mapping while keeping parallax mapping.

Some glsl code is not compiled when some features are disabled. More disablements will be done in future PRs, but this already makes a GMA965 going from 10 fps to 15 fps while rendering the parpax default scene (spectator intermission) which is already 50% more (but this is unnoticeable on R9 390X).

Some specular code is refactored the way it's not copy-pasted across multiple files anymore.

@slipher

This comment has been minimized.

Copy link
Contributor

slipher commented Mar 25, 2019

If I understand correctly, each one of {r_deluxeMapping, r_specularMapping, r_glowMapping} is implemented as a switch that can be individually turned on or off for each texture? Maybe it would make more sense to make this a global variable (requiring a renderer restart to change) so that it does require 2x as many variants of each GLSL shader to be compiled.

@illwieckz

This comment has been minimized.

Copy link
Member Author

illwieckz commented Mar 25, 2019

right

@illwieckz

This comment has been minimized.

Copy link
Member Author

illwieckz commented Mar 25, 2019

Note that we can't do #ifdef tr_deluxeMapping since that macro would be set on vid restart while the data to set it (tr.worldDeluxeMapping) is set at bsp load. This setting is content dependent (the lightmap files) and this kind of macros are not redefined between map loads. In any way the same shader would be used for all textures of the whole map.

Edit: And there is no easy way to set a fallback. There was an if in glsl code based on the fallback being black, but I foundbetter to compile two shaders and use one of them for all textures of a given map than branching that if on every pixel.

@illwieckz

This comment has been minimized.

Copy link
Member Author

illwieckz commented Mar 26, 2019

Uh no! those defines look to be set once for all at startup. The GenEngineConstants function is called on each vid_restart call but the same shader is used across each vid_restart. A complete engine restart is required to see the shader being “optimized”. o.O

@illwieckz illwieckz force-pushed the illwieckz:optdeluxemap branch from e529124 to a4afb46 Mar 26, 2019

@illwieckz

This comment has been minimized.

Copy link
Member Author

illwieckz commented Mar 26, 2019

r_normalMapping, r_specularMapping and r_glowMapping are now set for all the shaders, but I'm not sure code is properly disabled because I have hard time to check those macros are taken in account or not and when. I haven't compared for perf on my old gma965 yet.

Note that more code disablement is to be done.

Because of those macros being for all the materials and not per-material, I had to light & specular stuff from reliefMapping_fp.glsl into a new lib named computeLight_fp.glsl. This is something I wanted to do in anyway since it was stupid to pass all the lighting stuff to the heat haze shader that just requires the normalmap code.

Show resolved Hide resolved src/engine/renderer/tr_shade.cpp
Show resolved Hide resolved src/engine/renderer/tr_shade.cpp
Show resolved Hide resolved src/engine/renderer/tr_init.cpp
Show resolved Hide resolved src/engine/renderer/tr_shade.cpp Outdated
Show resolved Hide resolved src/engine/renderer/tr_shade.cpp Outdated
Show resolved Hide resolved src/engine/renderer/tr_init.cpp Outdated
Show resolved Hide resolved src/engine/renderer/tr_init.cpp Outdated
Show resolved Hide resolved src/engine/renderer/glsl_source/reliefMapping_fp.glsl Outdated
Show resolved Hide resolved src/engine/renderer/glsl_source/computeLight_fp.glsl Outdated

@illwieckz illwieckz force-pushed the illwieckz:optdeluxemap branch 3 times, most recently from ca1e154 to 32c08d8 Mar 30, 2019

@slipher

This comment has been minimized.

Copy link
Contributor

slipher commented Mar 30, 2019

LGTM

@illwieckz illwieckz force-pushed the illwieckz:optdeluxemap branch from 32c08d8 to 87e6f3d Mar 30, 2019

@illwieckz

This comment has been minimized.

Copy link
Member Author

illwieckz commented Mar 30, 2019

@slipher can you look at the latest commit I added? I just noticed I forgot to include this one in this PR while extracting some commits from my workspace to branches for other PR to come. This is very straightforward, it just uses parallaxDepth/Offset thing in reliefMapping_fp only hence no need to pass the variables anywhere parallax is done hence there is only one place to put ifdef. Basically they are defined where they are used. This avoids boiler plate.

@illwieckz illwieckz force-pushed the illwieckz:optdeluxemap branch from 87e6f3d to ea6ad3a Mar 30, 2019

@slipher

This comment has been minimized.

Copy link
Contributor

slipher commented Mar 30, 2019

👍

@illwieckz illwieckz force-pushed the illwieckz:optdeluxemap branch from ea6ad3a to 0beb003 Mar 30, 2019

@illwieckz

This comment has been minimized.

Copy link
Member Author

illwieckz commented Mar 30, 2019

I just force pushed because I squashed this very minor thing (both are vec2 so no need for any mask):

diff --git a/src/engine/renderer/glsl_source/liquid_fp.glsl b/src/engine/renderer/glsl_source/liquid_fp.glsl
index 7154718c8..ac7a19099 100644
--- a/src/engine/renderer/glsl_source/liquid_fp.glsl
+++ b/src/engine/renderer/glsl_source/liquid_fp.glsl
@@ -90,7 +90,7 @@ void  main()
 
        // calculate the screen texcoord in the 0.0 to 1.0 range
        vec2 texScreen = gl_FragCoord.st * r_FBufScale;
-       vec2 texNormal = var_TexNormal.st;
+       vec2 texNormal = var_TexNormal;
 
 #if defined(USE_PARALLAX_MAPPING)
        // ray intersect in view direction

@illwieckz illwieckz merged commit 0beb003 into DaemonEngine:master Mar 30, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.