2017-07-17 15:06:27 +03:00
|
|
|
/*******************************************************************************************
|
|
|
|
*
|
|
|
|
* rPBR [shader] - Background skybox fragment shader
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017 Victor Fisac
|
|
|
|
*
|
2020-06-20 18:55:56 +03:00
|
|
|
* 19-Jun-2020 - modified by Giuseppe Mastrangelo (@peppemas) - VFlip Support
|
|
|
|
*
|
2017-07-17 15:06:27 +03:00
|
|
|
**********************************************************************************************/
|
|
|
|
|
|
|
|
#version 330
|
|
|
|
|
|
|
|
// Input vertex attributes (from vertex shader)
|
2018-12-25 17:19:25 +03:00
|
|
|
in vec3 fragPosition;
|
2017-07-17 15:06:27 +03:00
|
|
|
|
|
|
|
// Input uniform values
|
|
|
|
uniform samplerCube environmentMap;
|
2020-06-20 18:55:56 +03:00
|
|
|
uniform bool vflipped;
|
2017-07-17 15:06:27 +03:00
|
|
|
|
|
|
|
// Output fragment color
|
|
|
|
out vec4 finalColor;
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
// Fetch color from texture map
|
2020-07-28 12:27:05 +03:00
|
|
|
vec3 color = vec3(0.0);
|
2020-06-20 18:55:56 +03:00
|
|
|
|
2020-07-10 13:20:57 +03:00
|
|
|
if (vflipped) color = texture(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z)).rgb;
|
|
|
|
else color = texture(environmentMap, fragPosition).rgb;
|
2017-07-17 15:06:27 +03:00
|
|
|
|
|
|
|
// Apply gamma correction
|
|
|
|
color = color/(color + vec3(1.0));
|
|
|
|
color = pow(color, vec3(1.0/2.2));
|
|
|
|
|
|
|
|
// Calculate final fragment color
|
|
|
|
finalColor = vec4(color, 1.0);
|
|
|
|
}
|