* Fix bug #1270 Added an argument to the shader in order to flip the texture * Fix Bug #1270 * Fix bug #1270
This commit is contained in:
parent
c833644a0e
commit
0e26d514b8
3 changed files with 28 additions and 3 deletions
|
@ -35,6 +35,7 @@ int main(void)
|
||||||
skybox.materials[0].shader = LoadShader("resources/shaders/glsl100/skybox.vs", "resources/shaders/glsl100/skybox.fs");
|
skybox.materials[0].shader = LoadShader("resources/shaders/glsl100/skybox.vs", "resources/shaders/glsl100/skybox.fs");
|
||||||
#endif
|
#endif
|
||||||
SetShaderValue(skybox.materials[0].shader, GetShaderLocation(skybox.materials[0].shader, "environmentMap"), (int[1]){ MAP_CUBEMAP }, UNIFORM_INT);
|
SetShaderValue(skybox.materials[0].shader, GetShaderLocation(skybox.materials[0].shader, "environmentMap"), (int[1]){ MAP_CUBEMAP }, UNIFORM_INT);
|
||||||
|
SetShaderValue(skybox.materials[0].shader, GetShaderLocation(skybox.materials[0].shader, "vflipped"), (int[1]){ 1 }, UNIFORM_INT);
|
||||||
|
|
||||||
// Load cubemap shader and setup required shader locations
|
// Load cubemap shader and setup required shader locations
|
||||||
#if defined(PLATFORM_DESKTOP)
|
#if defined(PLATFORM_DESKTOP)
|
||||||
|
|
|
@ -4,23 +4,35 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017 Victor Fisac
|
* Copyright (c) 2017 Victor Fisac
|
||||||
*
|
*
|
||||||
|
* 19-Jun-2020 - modified by Giuseppe Mastrangelo (@peppemas) - VFlip Support
|
||||||
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
#version 330
|
#version 110
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
// Input vertex attributes (from vertex shader)
|
||||||
in vec3 fragPosition;
|
in vec3 fragPosition;
|
||||||
|
|
||||||
// Input uniform values
|
// Input uniform values
|
||||||
uniform samplerCube environmentMap;
|
uniform samplerCube environmentMap;
|
||||||
|
uniform bool vflipped;
|
||||||
|
|
||||||
// Output fragment color
|
// Output fragment color
|
||||||
out vec4 finalColor;
|
out vec4 finalColor;
|
||||||
|
|
||||||
|
vec4 flipTextureCube(samplerCube sampler, vec3 texCoord) {
|
||||||
|
return texture(sampler, vec3(texCoord.x,-texCoord.y,texCoord.z));
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
// Fetch color from texture map
|
// Fetch color from texture map
|
||||||
vec3 color = texture(environmentMap, fragPosition).rgb;
|
vec3 color;
|
||||||
|
|
||||||
|
if (vflipped )
|
||||||
|
color = flipTextureCube(environmentMap, fragPosition).rgb;
|
||||||
|
else
|
||||||
|
color = texture(environmentMap, fragPosition).rgb;
|
||||||
|
|
||||||
// Apply gamma correction
|
// Apply gamma correction
|
||||||
color = color/(color + vec3(1.0));
|
color = color/(color + vec3(1.0));
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017 Victor Fisac
|
* Copyright (c) 2017 Victor Fisac
|
||||||
*
|
*
|
||||||
|
* 19-Jun-2020 - modified by Giuseppe Mastrangelo (@peppemas) - VFlip Support
|
||||||
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
#version 330
|
#version 330
|
||||||
|
@ -13,14 +15,24 @@ in vec3 fragPosition;
|
||||||
|
|
||||||
// Input uniform values
|
// Input uniform values
|
||||||
uniform samplerCube environmentMap;
|
uniform samplerCube environmentMap;
|
||||||
|
uniform bool vflipped;
|
||||||
|
|
||||||
// Output fragment color
|
// Output fragment color
|
||||||
out vec4 finalColor;
|
out vec4 finalColor;
|
||||||
|
|
||||||
|
vec4 flipTextureCube(samplerCube sampler, vec3 texCoord) {
|
||||||
|
return texture(sampler, vec3(texCoord.x,-texCoord.y,texCoord.z));
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
// Fetch color from texture map
|
// Fetch color from texture map
|
||||||
vec3 color = texture(environmentMap, fragPosition).rgb;
|
vec3 color;
|
||||||
|
|
||||||
|
if (vflipped )
|
||||||
|
color = flipTextureCube(environmentMap, fragPosition).rgb;
|
||||||
|
else
|
||||||
|
color = texture(environmentMap, fragPosition).rgb;
|
||||||
|
|
||||||
// Apply gamma correction
|
// Apply gamma correction
|
||||||
color = color/(color + vec3(1.0));
|
color = color/(color + vec3(1.0));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue