|
|
|
@ -75,6 +75,19 @@ struct Material {
@@ -75,6 +75,19 @@ struct Material {
|
|
|
|
|
|
|
|
|
|
uniform Material material; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// https://gamedev.stackexchange.com/questions/92015/optimized-linear-to-srgb-glsl |
|
|
|
|
// Converts a color from sRGB gamma to linear light gamma |
|
|
|
|
vec3 toLinear(vec3 sRGB) |
|
|
|
|
{ |
|
|
|
|
bvec3 cutoff = lessThan(sRGB, vec3(0.04045)); |
|
|
|
|
vec3 higher = pow((sRGB + vec3(0.055))/vec3(1.055), vec3(2.4)); |
|
|
|
|
vec3 lower = sRGB/vec3(12.92); |
|
|
|
|
|
|
|
|
|
return mix(higher, lower, cutoff); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
main() { |
|
|
|
|
// store the fragment position vector in the first gbuffer texture |
|
|
|
@ -95,6 +108,6 @@ main() {
@@ -95,6 +108,6 @@ main() {
|
|
|
|
|
if (tex.a < 0.1) |
|
|
|
|
discard; |
|
|
|
|
|
|
|
|
|
gAlbedoSpec.rgb = tex.rgb; // store specular intensity in gAlbedoSpec's alpha component |
|
|
|
|
gAlbedoSpec.rgb = toLinear(tex.rgb); // store specular intensity in gAlbedoSpec's alpha component |
|
|
|
|
gAlbedoSpec.a = texture(material.texture_specular1, theTexCoord).r; |
|
|
|
|
} |
|
|
|
|