diff options
-rw-r--r-- | Makefile.am | 4 | ||||
-rw-r--r-- | data/shaders/skybox-frag.glsl | 28 | ||||
-rw-r--r-- | data/shaders/skybox-vert.glsl | 25 |
3 files changed, 56 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index 883418a..da69162 100644 --- a/Makefile.am +++ b/Makefile.am @@ -155,7 +155,9 @@ dist_shaders_DATA = \ data/shaders/pbr-vert.glsl \ data/shaders/pbr-frag.glsl \ data/shaders/phong-vert.glsl \ - data/shaders/phong-frag.glsl + data/shaders/phong-frag.glsl \ + data/shaders/skybox-frag.glsl \ + data/shaders/skybox-vert.glsl info_TEXINFOS = doc/chickadee.texi doc_chickadee_TEXINFOS = \ diff --git a/data/shaders/skybox-frag.glsl b/data/shaders/skybox-frag.glsl new file mode 100644 index 0000000..b388828 --- /dev/null +++ b/data/shaders/skybox-frag.glsl @@ -0,0 +1,28 @@ +// -*- mode: c -*- + +#ifdef GLSL120 +varying vec3 fragDir; +#else +in vec3 fragDir; +#endif + +#ifdef GLSL330 +out vec4 fragColor; +#endif + +#ifndef GLSL330 +#define fragColor gl_FragColor +#endif + +uniform samplerCube cubeMap; + +#ifndef GLSL330 +// Compatibility shim for older GLSL versions. +vec3 texture(samplerCube tex, vec3 coord) { + return textureCube(tex, coord); +} +#endif + +void main() { + fragColor = texture(cubeMap, fragDir); +} diff --git a/data/shaders/skybox-vert.glsl b/data/shaders/skybox-vert.glsl new file mode 100644 index 0000000..312fcd6 --- /dev/null +++ b/data/shaders/skybox-vert.glsl @@ -0,0 +1,25 @@ +// -*- mode: c -*- + +#ifdef GLSL330 +layout (location = 0) in vec3 position; +#elif defined(GLSL130) +in vec3 position; +#elif defined(GLSL120) +attribute vec3 position; +#endif + +#ifdef GLSL120 +varying vec3 fragDir; +#else +out vec3 fragDir; +#endif + +uniform mat4 view; +uniform mat4 projection; + +void main() { + // Remove the translation part of the view matrix. + mat4 viewDir = mat4(mat3(view)); + fragDir = position; + gl_Position = projection * viewDir * vec4(position, 1.0); +} |