This repository has been archived on 2025-06-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
raylib-python-cffi/examples/models/resources/shaders/cubemap.fs
Richard Smith a703659c9d initial
2019-05-21 10:56:31 +01:00

38 lines
882 B
GLSL

/*******************************************************************************************
*
* rPBR [shader] - Equirectangular to cubemap fragment shader
*
* Copyright (c) 2017 Victor Fisac
*
**********************************************************************************************/
#version 330
# Input vertex attributes (from vertex shader)
in vec3 fragPos
# Input uniform values
uniform sampler2D equirectangularMap
# Output fragment color
out vec4 finalColor
vec2 SampleSphericalMap(vec3 v)
[
vec2 uv = vec2(atan(v.z, v.x), asin(v.y))
uv *= vec2(0.1591, 0.3183)
uv += 0.5
return uv
]
void main()
[
# Normalize local position
vec2 uv = SampleSphericalMap(normalize(fragPos))
# Fetch color from texture map
vec3 color = texture(equirectangularMap, uv).rgb
# Calculate final fragment color
finalColor = vec4(color, 1.0)
]