mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-26 16:59:18 -05:00
Review skybox shaders
This commit is contained in:
@ -9,14 +9,11 @@
|
|||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
// Input vertex attributes (from vertex shader)
|
||||||
in vec3 fragPosition;
|
varying vec3 fragPosition;
|
||||||
|
|
||||||
// Input uniform values
|
// Input uniform values
|
||||||
uniform sampler2D equirectangularMap;
|
uniform sampler2D equirectangularMap;
|
||||||
|
|
||||||
// Output fragment color
|
|
||||||
out vec4 finalColor;
|
|
||||||
|
|
||||||
vec2 SampleSphericalMap(vec3 v)
|
vec2 SampleSphericalMap(vec3 v)
|
||||||
{
|
{
|
||||||
vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
|
vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
|
||||||
@ -34,5 +31,5 @@ void main()
|
|||||||
vec3 color = texture(equirectangularMap, uv).rgb;
|
vec3 color = texture(equirectangularMap, uv).rgb;
|
||||||
|
|
||||||
// Calculate final fragment color
|
// Calculate final fragment color
|
||||||
finalColor = vec4(color, 1.0);
|
gl_FragColor = vec4(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,14 +9,14 @@
|
|||||||
#version 330
|
#version 330
|
||||||
|
|
||||||
// Input vertex attributes
|
// Input vertex attributes
|
||||||
in vec3 vertexPosition;
|
attribute vec3 vertexPosition;
|
||||||
|
|
||||||
// Input uniform values
|
// Input uniform values
|
||||||
uniform mat4 projection;
|
uniform mat4 projection;
|
||||||
uniform mat4 view;
|
uniform mat4 view;
|
||||||
|
|
||||||
// Output vertex attributes (to fragment shader)
|
// Output vertex attributes (to fragment shader)
|
||||||
out vec3 fragPosition;
|
varying vec3 fragPosition;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,33 +11,24 @@
|
|||||||
#version 110
|
#version 110
|
||||||
|
|
||||||
// Input vertex attributes (from vertex shader)
|
// Input vertex attributes (from vertex shader)
|
||||||
in vec3 fragPosition;
|
varying vec3 fragPosition;
|
||||||
|
|
||||||
// Input uniform values
|
// Input uniform values
|
||||||
uniform samplerCube environmentMap;
|
uniform samplerCube environmentMap;
|
||||||
uniform bool vflipped;
|
uniform bool vflipped;
|
||||||
|
|
||||||
// Output fragment color
|
|
||||||
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;
|
vec3 color = { 0.0 };
|
||||||
|
|
||||||
if (vflipped )
|
if (vflipped) color = texture2D(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z)).rgb;
|
||||||
color = flipTextureCube(environmentMap, fragPosition).rgb;
|
else color = texture2D(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));
|
||||||
color = pow(color, vec3(1.0/2.2));
|
color = pow(color, vec3(1.0/2.2));
|
||||||
|
|
||||||
// Calculate final fragment color
|
// Calculate final fragment color
|
||||||
finalColor = vec4(color, 1.0);
|
gl_FragColor = vec4(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,19 +20,13 @@ 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;
|
vec3 color = { 0.0 };
|
||||||
|
|
||||||
if (vflipped )
|
if (vflipped) color = texture(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z)).rgb;
|
||||||
color = flipTextureCube(environmentMap, fragPosition).rgb;
|
else color = texture(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));
|
||||||
|
|||||||
Reference in New Issue
Block a user