ValveSoftware / source-sdk-2013

The 2013 edition of the Source SDK
https://developer.valvesoftware.com/wiki/SDK2013_GettingStarted
Other
3.76k stars 2k forks source link

D3DRS_SRGBWRITEENABLE render state probably not properly managed between different shaders [i.e. in CS:GO] #329

Open dtugend opened 9 years ago

dtugend commented 9 years ago

Hello.

The problem gets most visible, when you overload the materials with a depthdebug shader based material:

This is how it should look (please note that this is work in progress and thus i.e. I didn't account for the 3D skybox scale yet): D3DRS_SRGBWRITEENABLE render state fixed

This how it actually looks: D3DRS_SRGBWRITEENABLE render state not fixed

There are several hints that some elements (i.e. world texture decal shaders and maybe the GUI shaders) enable D3DRS_SRGBWRITEENABLE and others disable it and that in-between the state is "random" and not properly managed. In other words things like pShaderShadow->EnableSRGBWrite probably affect other shaders, because the state is not properly managed.

Maybe the problem is me because I am using the depth shaders, maybe not.

I can fix it for my self, just wanted to let you know in case you run into a similar problem.

I can't tell from the code if each shader is supposed to default everything or not, if yes, then pShaderShadow->EnableSRGBWrite(false) needs to be added to the debugdepth shader. But I already found hints, that this again might affect other shaders (i.e. in the GUI) that don't set a default either.