Interrupt / systemshock

Shockolate - A minimalist and cross platform System Shock source port.
GNU General Public License v3.0
813 stars 66 forks source link

[OpenGL] Night Sight does not work #135

Closed inguin closed 6 years ago

inguin commented 6 years ago

The Night Sight hardware does not work with the OpenGL renderer. It's supposed to render everything in black and white at full brightness.

Interrupt commented 6 years ago

These effects use a different shade table palette than the default lighting palette. Easiest path for this in OpenGL seems to be to use a special shader to emulate this effect.

Interrupt commented 6 years ago

Thinking more about this, it could probably be done as a post processing effect. We could have a shader param that controls whether things should draw at full brightness in the normal texture / color shaders, and then when drawing the framebuffer texture use a special black and white shader.

inguin commented 6 years ago

Reproducing the effect in the shaders is very simple (it works, but I'm getting GL errors; no idea why):

float gray = 0.30 * t.r + 0.59 * t.g + 0.11 * t.b;
gl_FragColor = vec4(gray, gray, gray, alpha);

All we need to do is switch this on or off by setting a uniform parameter.

inguin commented 6 years ago

(it works, but I'm getting GL errors; no idea why)

One mystery solved: I was no longer referencing the light value, so the shader compiler/linker optimized everything up to and including the light attribute out.