Page 1 of 1

Texture displacement togglable by a CVAR?

Posted: Sun Mar 13, 2022 10:30 pm
by KUBA18i
I'm playing around with shaders, namely the one from this thread. It allows me to give flat textures actual depth, and I like it. However, it's effects give off a strange vibe of warping around dependending on the player's position and movement, so I want to be able to disable the effect without just removing the code from the PK3.

The code is controlled by GLDefs definitions which call upon a shader file, for those interested it goes like this:

Code: Select all

material texture "WOODTABL"
        shader "shaders/displacement.fp"
        normal "materials/normalmaps/WOODTABL.png"
        specular "materials/specular/WOODTABL.png"
        texture displacement "materials/displacement/WOODTABL.png"
   glossiness 10.0
        specularlevel 0.5

Now, I have defined a CVAR for the job, like so:

Code: Select all

user bool JM_texdisp = true;

I tried putting the whole shader code under a bracket that goes like

Code: Select all


but that just crashed the game :mrgreen:

Any help would be appreciated. If there are commands to control aspects of things like this already, I would like to know them(I couldn't find them, and the article on CVARs on the wiki seems to be a bit out of date). So far, the only way to change how deep the displacement gets is editing the PNG itself.