diff options
author | Eric Anholt <eric@anholt.net> | 2013-03-22 17:36:16 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-03-22 17:37:02 -0700 |
commit | 4bbd5dab2a3f2442b21fe6937ccad5b6ed5a2285 (patch) | |
tree | f377f039dc30c7422c56277d45ddd7f8fb07826a | |
parent | 3db77a1625bab9ceda10f5fa66e38bbc0e42393f (diff) |
humus: Replace with shader_test files.
85 files changed, 2394 insertions, 2013 deletions
diff --git a/shaders/humus-celshading/1.frag b/shaders/humus-celshading/1.frag deleted file mode 100644 index 1b58efc..0000000 --- a/shaders/humus-celshading/1.frag +++ /dev/null @@ -1,17 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 14 -
-
-uniform sampler1D CelShade;
-
-varying vec3 lVec;
-varying vec3 norm;
-
-void main(){
- vec3 lightVec = normalize(lVec);
- float diffuse = dot(lightVec, norm);
-
- gl_FragColor = texture1D(CelShade, diffuse);
-}
- diff --git a/shaders/humus-celshading/1.shader_test b/shaders/humus-celshading/1.shader_test new file mode 100644 index 0000000..72ae781 --- /dev/null +++ b/shaders/humus-celshading/1.shader_test @@ -0,0 +1,59 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 14 + + +uniform sampler1D CelShade; + +varying vec3 lVec; +varying vec3 norm; + +void main(){ + vec3 lightVec = normalize(lVec); + float diffuse = dot(lightVec, norm); + + gl_FragColor = texture1D(CelShade, diffuse); +} + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 0 + + +uniform vec3 lightPos; + +varying vec3 lVec; +varying vec3 norm; + +void main(){ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + lVec = lightPos - gl_Vertex.xyz; + norm = gl_Normal; +} + + diff --git a/shaders/humus-celshading/1.vert b/shaders/humus-celshading/1.vert deleted file mode 100644 index fb28d3b..0000000 --- a/shaders/humus-celshading/1.vert +++ /dev/null @@ -1,18 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 0 -
-
-uniform vec3 lightPos;
-
-varying vec3 lVec;
-varying vec3 norm;
-
-void main(){
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-
- lVec = lightPos - gl_Vertex.xyz;
- norm = gl_Normal;
-}
-
- diff --git a/shaders/humus-celshading/12.shader_test b/shaders/humus-celshading/12.shader_test new file mode 100644 index 0000000..7497b6b --- /dev/null +++ b/shaders/humus-celshading/12.shader_test @@ -0,0 +1,22 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +uniform ivec4 color; +out ivec4 out_color; + +void main() +{ + out_color = color; +} + +[vertex shader] +#version 130 +in vec4 position; +void main() +{ + gl_Position = position; +} + + diff --git a/shaders/humus-celshading/2.frag b/shaders/humus-celshading/2.frag deleted file mode 100644 index 97bf6df..0000000 --- a/shaders/humus-celshading/2.frag +++ /dev/null @@ -1,11 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 19 -
-
-varying vec3 norm;
-
-void main(){
- gl_FragColor = vec4(0.0);
-}
- diff --git a/shaders/humus-celshading/3.frag b/shaders/humus-celshading/3.frag deleted file mode 100644 index 4c72c26..0000000 --- a/shaders/humus-celshading/3.frag +++ /dev/null @@ -1,6 +0,0 @@ -uniform vec4 color; -void main() -{ - gl_FragColor = color; -} - diff --git a/shaders/humus-celshading/3.vert b/shaders/humus-celshading/3.vert deleted file mode 100644 index b081d0f..0000000 --- a/shaders/humus-celshading/3.vert +++ /dev/null @@ -1,6 +0,0 @@ -attribute vec4 position; -void main() -{ - gl_Position = position; -} - diff --git a/shaders/humus-celshading/2.vert b/shaders/humus-celshading/4.shader_test index 63c2205..5aefdcc 100644 --- a/shaders/humus-celshading/2.vert +++ b/shaders/humus-celshading/4.shader_test @@ -1,23 +1,39 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 19 + + +varying vec3 norm; + +void main(){ + gl_FragColor = vec4(0.0); +} + +[vertex shader] #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #line 0 -
-
-uniform vec3 camPos;
-uniform float outlineThreshold;
-uniform float edgeThreshold;
-
-varying vec3 norm;
-
-void main(){
- vec4 pos = gl_Vertex;
- vec3 dir = camPos - gl_Vertex.xyz;
-
- pos.w = float(
- dot(dir, gl_MultiTexCoord0.xyz) * dot(dir, gl_MultiTexCoord1.xyz) < outlineThreshold ||
- dot(gl_MultiTexCoord0.xyz, gl_MultiTexCoord1.xyz) < edgeThreshold);
-
- gl_Position = gl_ModelViewProjectionMatrix * pos;
-}
-
+ + +uniform vec3 camPos; +uniform float outlineThreshold; +uniform float edgeThreshold; + +varying vec3 norm; + +void main(){ + vec4 pos = gl_Vertex; + vec3 dir = camPos - gl_Vertex.xyz; + + pos.w = float( + dot(dir, gl_MultiTexCoord0.xyz) * dot(dir, gl_MultiTexCoord1.xyz) < outlineThreshold || + dot(gl_MultiTexCoord0.xyz, gl_MultiTexCoord1.xyz) < edgeThreshold); + + gl_Position = gl_ModelViewProjectionMatrix * pos; +} + diff --git a/shaders/humus-celshading/9.shader_test b/shaders/humus-celshading/9.shader_test new file mode 100644 index 0000000..30ba541 --- /dev/null +++ b/shaders/humus-celshading/9.shader_test @@ -0,0 +1,17 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +uniform vec4 color; +void main() +{ + gl_FragColor = color; +} + +[vertex shader] +attribute vec4 position; +void main() +{ + gl_Position = position; +} + diff --git a/shaders/humus-domino/1.frag b/shaders/humus-domino/1.shader_test index af0fff3..a80d525 100644 --- a/shaders/humus-domino/1.frag +++ b/shaders/humus-domino/1.shader_test @@ -1,28 +1,93 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #line 18 -uniform sampler2D Base;
-uniform sampler2D Bump;
-
-uniform float fade;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-
-void main(){
- vec3 lightVec = normalize(lVec);
- vec3 viewVec = lightVec;
-
- float atten = saturate(1.0 / (1.0 + dot(lVec, lVec)) - 0.1);
-
- vec4 base = texture2D(Base, texCoord);
- vec3 bump = texture2D(Bump, texCoord).xyz;
- vec3 normal = normalize(bump * 2.0 - 1.0);
-
- float diffuse = saturate(dot(lightVec, normal));
- float specular = pow(diffuse, 16.0);
-
- gl_FragColor = fade * atten * ((diffuse * 0.7 + 0.3) * base + 0.5 * specular);
-}
+uniform sampler2D Base; +uniform sampler2D Bump; + +uniform float fade; + +varying vec2 texCoord; +varying vec3 lVec; + +void main(){ + vec3 lightVec = normalize(lVec); + vec3 viewVec = lightVec; + + float atten = saturate(1.0 / (1.0 + dot(lVec, lVec)) - 0.1); + + vec4 base = texture2D(Base, texCoord); + vec3 bump = texture2D(Bump, texCoord).xyz; + vec3 normal = normalize(bump * 2.0 - 1.0); + + float diffuse = saturate(dot(lightVec, normal)); + float specular = pow(diffuse, 16.0); + + gl_FragColor = fade * atten * ((diffuse * 0.7 + 0.3) * base + 0.5 * specular); +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 2 +uniform vec3 camPos; + +varying vec2 texCoord; +varying vec3 lVec; + +void main(){ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + texCoord = gl_Vertex.xz * 0.0625; + + lVec = 0.005 * (camPos - gl_Vertex.xyz).xzy; +} + + diff --git a/shaders/humus-domino/1.vert b/shaders/humus-domino/1.vert deleted file mode 100644 index 4114202..0000000 --- a/shaders/humus-domino/1.vert +++ /dev/null @@ -1,19 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 2 -uniform vec3 camPos;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-
-void main(){
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-
- texCoord = gl_Vertex.xz * 0.0625;
-
- lVec = 0.005 * (camPos - gl_Vertex.xyz).xzy;
-}
-
-
- diff --git a/shaders/humus-domino/12.shader_test b/shaders/humus-domino/12.shader_test new file mode 100644 index 0000000..7497b6b --- /dev/null +++ b/shaders/humus-domino/12.shader_test @@ -0,0 +1,22 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +uniform ivec4 color; +out ivec4 out_color; + +void main() +{ + out_color = color; +} + +[vertex shader] +#version 130 +in vec4 position; +void main() +{ + gl_Position = position; +} + + diff --git a/shaders/humus-domino/2.frag b/shaders/humus-domino/2.frag deleted file mode 100644 index 61ffb92..0000000 --- a/shaders/humus-domino/2.frag +++ /dev/null @@ -1,36 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define BATCH_INSTANCES 64 -#line 45 -uniform sampler3D Noise;
-
-uniform float fade;
-
-varying vec3 texCoord;
-varying vec3 normal;
-varying vec3 lVec;
-
-void main(){
- vec3 lightVec = normalize(lVec);
- vec3 viewVec = lightVec;
-
- float atten = saturate(1.0 / (1.0 + dot(lVec, lVec)) - 0.1);
-
- vec4 darkWood = vec4(0.09, 0.04, 0.01, 1.0);
- vec4 liteWood = vec4(0.92, 0.51, 0.13, 1.0);
-
- float rings = fract(texture3D(Noise, texCoord * 0.15, 1.0).x * 4.0);
- rings *= 4.0 * (1.0 - rings);
- rings *= rings;
-
- float n = texture3D(Noise, texCoord).x;
-
- vec4 base = lerp(darkWood, liteWood, rings + n);
-
- float diffuse = saturate(dot(lightVec, normal));
- float specular = pow(diffuse, 64.0);
-
- gl_FragColor = fade * atten * ((diffuse * 0.8 + 0.2) * base + 0.4 * specular);
-}
- diff --git a/shaders/humus-domino/3.frag b/shaders/humus-domino/3.frag deleted file mode 100644 index 4c72c26..0000000 --- a/shaders/humus-domino/3.frag +++ /dev/null @@ -1,6 +0,0 @@ -uniform vec4 color; -void main() -{ - gl_FragColor = color; -} - diff --git a/shaders/humus-domino/3.vert b/shaders/humus-domino/3.vert deleted file mode 100644 index b081d0f..0000000 --- a/shaders/humus-domino/3.vert +++ /dev/null @@ -1,6 +0,0 @@ -attribute vec4 position; -void main() -{ - gl_Position = position; -} - diff --git a/shaders/humus-domino/2.vert b/shaders/humus-domino/4.shader_test index df4b21d..4de43c5 100644 --- a/shaders/humus-domino/2.vert +++ b/shaders/humus-domino/4.shader_test @@ -1,47 +1,88 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define BATCH_INSTANCES 64 +#line 45 +uniform sampler3D Noise; + +uniform float fade; + +varying vec3 texCoord; +varying vec3 normal; +varying vec3 lVec; + +void main(){ + vec3 lightVec = normalize(lVec); + vec3 viewVec = lightVec; + + float atten = saturate(1.0 / (1.0 + dot(lVec, lVec)) - 0.1); + + vec4 darkWood = vec4(0.09, 0.04, 0.01, 1.0); + vec4 liteWood = vec4(0.92, 0.51, 0.13, 1.0); + + float rings = fract(texture3D(Noise, texCoord * 0.15, 1.0).x * 4.0); + rings *= 4.0 * (1.0 - rings); + rings *= rings; + + float n = texture3D(Noise, texCoord).x; + + vec4 base = lerp(darkWood, liteWood, rings + n); + + float diffuse = saturate(dot(lightVec, normal)); + float specular = pow(diffuse, 64.0); + + gl_FragColor = fade * atten * ((diffuse * 0.8 + 0.2) * base + 0.4 * specular); +} + +[vertex shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #define BATCH_INSTANCES 64 #line 2 -uniform vec3 camPos;
-
-void rotate(const vec2 sc, inout vec2 pos){
- pos.xy = vec2(dot(pos, sc), dot(pos, vec2(-sc.y, sc.x)));
-}
-
-varying vec3 texCoord;
-varying vec3 normal;
-varying vec3 lVec;
-
-uniform vec4 attribs[BATCH_INSTANCES];
-uniform float time;
-
-uniform float fallAngle;
-
-void main(){
- vec4 attrib = attribs[int(gl_MultiTexCoord0.x)];
-
- float a = saturate(time - attrib.w);
- a = fallAngle * pow(a, 0.8);
-
- vec2 scA = vec2(cos(a), sin(a));
- vec2 scB = vec2(cos(-attrib.z), sin(-attrib.z));
-
- vec4 position = gl_Vertex;
- normal = gl_Normal;
- rotate(scA, position.xy);
- rotate(scA, normal.xy);
- rotate(scB, position.xz);
- rotate(scB, normal.xz);
-
- position.xz += attrib.xy;
-
- gl_Position = gl_ModelViewProjectionMatrix * position;
-
- texCoord = gl_Vertex.xyz * 0.283 + attrib.w * vec3(7.243, 2.6783, 9.4921);
-
- lVec = 0.005 * (camPos - position.xyz);
-}
-
-
+uniform vec3 camPos; + +void rotate(const vec2 sc, inout vec2 pos){ + pos.xy = vec2(dot(pos, sc), dot(pos, vec2(-sc.y, sc.x))); +} + +varying vec3 texCoord; +varying vec3 normal; +varying vec3 lVec; + +uniform vec4 attribs[BATCH_INSTANCES]; +uniform float time; + +uniform float fallAngle; + +void main(){ + vec4 attrib = attribs[int(gl_MultiTexCoord0.x)]; + + float a = saturate(time - attrib.w); + a = fallAngle * pow(a, 0.8); + + vec2 scA = vec2(cos(a), sin(a)); + vec2 scB = vec2(cos(-attrib.z), sin(-attrib.z)); + + vec4 position = gl_Vertex; + normal = gl_Normal; + rotate(scA, position.xy); + rotate(scA, normal.xy); + rotate(scB, position.xz); + rotate(scB, normal.xz); + + position.xz += attrib.xy; + + gl_Position = gl_ModelViewProjectionMatrix * position; + + texCoord = gl_Vertex.xyz * 0.283 + attrib.w * vec3(7.243, 2.6783, 9.4921); + + lVec = 0.005 * (camPos - position.xyz); +} + + diff --git a/shaders/humus-domino/9.shader_test b/shaders/humus-domino/9.shader_test new file mode 100644 index 0000000..30ba541 --- /dev/null +++ b/shaders/humus-domino/9.shader_test @@ -0,0 +1,17 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +uniform vec4 color; +void main() +{ + gl_FragColor = color; +} + +[vertex shader] +attribute vec4 position; +void main() +{ + gl_Position = position; +} + diff --git a/shaders/humus-dynamicbranching/1.frag b/shaders/humus-dynamicbranching/1.frag deleted file mode 100644 index e911164..0000000 --- a/shaders/humus-dynamicbranching/1.frag +++ /dev/null @@ -1,32 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 28 -uniform sampler2D Base;
-uniform sampler2D Bump;
-
-uniform vec2 plxCoeffs;
-uniform bool hasParallax;
-
-varying vec2 texCoord;
-varying vec3 vVec;
-
-void main(){
-
-#ifdef MULTIPASS
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec4 base = texture2D(Base, plxTexCoord);
-
- gl_FragColor = 0.1 * base;
-#endif
-
-}
- diff --git a/shaders/humus-dynamicbranching/1.shader_test b/shaders/humus-dynamicbranching/1.shader_test new file mode 100644 index 0000000..5d16bd7 --- /dev/null +++ b/shaders/humus-dynamicbranching/1.shader_test @@ -0,0 +1,90 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 28 +uniform sampler2D Base; +uniform sampler2D Bump; + +uniform vec2 plxCoeffs; +uniform bool hasParallax; + +varying vec2 texCoord; +varying vec3 vVec; + +void main(){ + +#ifdef MULTIPASS + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec4 base = texture2D(Base, plxTexCoord); + + gl_FragColor = 0.1 * base; +#endif + +} + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 2 +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +uniform vec3 camPos; + +varying vec2 texCoord; +varying vec3 vVec; + +void main(){ + gl_Position = ftransform(); + +#ifdef MULTIPASS + texCoord = textureCoord; + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +#endif +} + + + diff --git a/shaders/humus-dynamicbranching/1.vert b/shaders/humus-dynamicbranching/1.vert deleted file mode 100644 index df41037..0000000 --- a/shaders/humus-dynamicbranching/1.vert +++ /dev/null @@ -1,29 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 2 -attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-uniform vec3 camPos;
-
-varying vec2 texCoord;
-varying vec3 vVec;
-
-void main(){
- gl_Position = ftransform();
-
-#ifdef MULTIPASS
- texCoord = textureCoord;
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-#endif
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/6.frag b/shaders/humus-dynamicbranching/10.shader_test index 7059fc0..968b9f1 100644 --- a/shaders/humus-dynamicbranching/6.frag +++ b/shaders/humus-dynamicbranching/10.shader_test @@ -1,83 +1,169 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix -#define SHADOWS #define LIGHT_COUNT 3 #line 43 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform samplerCube ShadowMap;
-
-uniform vec3 lightColor[LIGHT_COUNT];
-uniform vec2 plxCoeffs;
-
-uniform bool hasParallax;
-
-varying vec3 lVec[LIGHT_COUNT];
-varying vec2 texCoord;
-varying vec3 vVec;
-#ifdef SHADOWS
-varying vec3 shadowVec[LIGHT_COUNT];
-#endif
-
-void main(){
-// float atten[LIGHT_COUNT];
- vec3 atten;
- for (int i = 0; i < LIGHT_COUNT; i++){
- atten[i] = 1.0 - dot(lVec[i], lVec[i]);
- }
- atten = max(atten, 0.0);
-
-
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec3 base = texture2D(Base, plxTexCoord).rgb;
- vec3 lighting = 0.1 * base;
-
-#ifdef BRANCHING
- if (dot(atten, atten) > 0.0)
-#endif
- {
-
- vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0;
- bump = normalize(bump);
- vec3 reflVec = reflect(-viewVec, bump);
-
- for (int i = 0; i < LIGHT_COUNT; i++){
-#ifndef BRANCHING
- atten[i] *= float(lVec[i].z > 0.0);
-#else
- if (atten[i] > 0.0)
- if (lVec[i].z > 0.0)
-#endif
- {
-
-#ifdef SHADOWS
-# ifndef BRANCHING
- atten[i] *= float(length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]);
-# else
- if (length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i])
-# endif
-#endif
- {
- vec3 lightVec = normalize(lVec[i]);
-
- float diffuse = saturate(dot(lightVec, bump));
- float specular = pow(saturate(dot(reflVec, lightVec)), 16.0);
-
- lighting += atten[i] * lightColor[i] * (diffuse * base + 0.6 * specular);
- }
- }
- }
- }
-
- gl_FragColor.rgb = lighting;
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform samplerCube ShadowMap; + +uniform vec3 lightColor[LIGHT_COUNT]; +uniform vec2 plxCoeffs; + +uniform bool hasParallax; + +varying vec3 lVec[LIGHT_COUNT]; +varying vec2 texCoord; +varying vec3 vVec; +#ifdef SHADOWS +varying vec3 shadowVec[LIGHT_COUNT]; +#endif + +void main(){ +// float atten[LIGHT_COUNT]; + vec3 atten; + for (int i = 0; i < LIGHT_COUNT; i++){ + atten[i] = 1.0 - dot(lVec[i], lVec[i]); + } + atten = max(atten, 0.0); + + + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec3 base = texture2D(Base, plxTexCoord).rgb; + vec3 lighting = 0.1 * base; + +#ifdef BRANCHING + if (dot(atten, atten) > 0.0) +#endif + { + + vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0; + bump = normalize(bump); + vec3 reflVec = reflect(-viewVec, bump); + + for (int i = 0; i < LIGHT_COUNT; i++){ +#ifndef BRANCHING + atten[i] *= float(lVec[i].z > 0.0); +#else + if (atten[i] > 0.0) + if (lVec[i].z > 0.0) +#endif + { + +#ifdef SHADOWS +# ifndef BRANCHING + atten[i] *= float(length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]); +# else + if (length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]) +# endif +#endif + { + vec3 lightVec = normalize(lVec[i]); + + float diffuse = saturate(dot(lightVec, bump)); + float specular = pow(saturate(dot(reflVec, lightVec)), 16.0); + + lighting += atten[i] * lightColor[i] * (diffuse * base + 0.6 * specular); + } + } + } + } + + gl_FragColor.rgb = lighting; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define LIGHT_COUNT 3 +#line 2 +uniform vec3 camPos; +uniform vec3 lightPos[LIGHT_COUNT]; +uniform float invRadius[LIGHT_COUNT]; + +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +varying vec3 lVec[LIGHT_COUNT]; +varying vec2 texCoord; +varying vec3 vVec; +#ifdef SHADOWS +varying vec3 shadowVec[LIGHT_COUNT]; +#endif + +void main(){ + gl_Position = ftransform(); + + texCoord = textureCoord; + + for (int i = 0; i < LIGHT_COUNT; i++){ + vec3 lightVec = invRadius[i] * (lightPos[i] - gl_Vertex.xyz); + +#ifdef SHADOWS + shadowVec[i] = -lightVec; +#endif + lVec[i].x = dot(lightVec, tangent); + lVec[i].y = dot(lightVec, binormal); + lVec[i].z = dot(lightVec, normal); + } + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +} + + diff --git a/shaders/humus-dynamicbranching/10.vert b/shaders/humus-dynamicbranching/10.vert deleted file mode 100644 index 8e1914b..0000000 --- a/shaders/humus-dynamicbranching/10.vert +++ /dev/null @@ -1,38 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define SHADOWS -#line 2 -uniform vec3 lightPos;
-uniform vec3 camPos;
-uniform float invRadius;
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 shadowVec;
-
-void main(){
- gl_Position = ftransform();
-
- texCoord = textureCoord;
-
- vec3 lightVec = invRadius * (lightPos - gl_Vertex.xyz);
- shadowVec = -lightVec;
- lVec.x = dot(lightVec, tangent);
- lVec.y = dot(lightVec, binormal);
- lVec.z = dot(lightVec, normal);
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/11.vert b/shaders/humus-dynamicbranching/11.vert deleted file mode 100644 index 2e20300..0000000 --- a/shaders/humus-dynamicbranching/11.vert +++ /dev/null @@ -1,39 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define SHADOWS -#define BRANCHING -#line 2 -uniform vec3 lightPos;
-uniform vec3 camPos;
-uniform float invRadius;
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 shadowVec;
-
-void main(){
- gl_Position = ftransform();
-
- texCoord = textureCoord;
-
- vec3 lightVec = invRadius * (lightPos - gl_Vertex.xyz);
- shadowVec = -lightVec;
- lVec.x = dot(lightVec, tangent);
- lVec.y = dot(lightVec, binormal);
- lVec.z = dot(lightVec, normal);
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/12.frag b/shaders/humus-dynamicbranching/12.frag deleted file mode 100644 index c230815..0000000 --- a/shaders/humus-dynamicbranching/12.frag +++ /dev/null @@ -1,10 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 18 -varying vec3 lightVec;
-
-void main(){
- gl_FragColor = vec4(length(lightVec) + 0.005);
-}
- diff --git a/shaders/humus-dynamicbranching/13.frag b/shaders/humus-dynamicbranching/13.frag deleted file mode 100644 index 4c72c26..0000000 --- a/shaders/humus-dynamicbranching/13.frag +++ /dev/null @@ -1,6 +0,0 @@ -uniform vec4 color; -void main() -{ - gl_FragColor = color; -} - diff --git a/shaders/humus-dynamicbranching/5.frag b/shaders/humus-dynamicbranching/13.shader_test index c3027fc..d397d84 100644 --- a/shaders/humus-dynamicbranching/5.frag +++ b/shaders/humus-dynamicbranching/13.shader_test @@ -1,83 +1,173 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #define BRANCHING #define LIGHT_COUNT 3 #line 43 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform samplerCube ShadowMap;
-
-uniform vec3 lightColor[LIGHT_COUNT];
-uniform vec2 plxCoeffs;
-
-uniform bool hasParallax;
-
-varying vec3 lVec[LIGHT_COUNT];
-varying vec2 texCoord;
-varying vec3 vVec;
-#ifdef SHADOWS
-varying vec3 shadowVec[LIGHT_COUNT];
-#endif
-
-void main(){
-// float atten[LIGHT_COUNT];
- vec3 atten;
- for (int i = 0; i < LIGHT_COUNT; i++){
- atten[i] = 1.0 - dot(lVec[i], lVec[i]);
- }
- atten = max(atten, 0.0);
-
-
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec3 base = texture2D(Base, plxTexCoord).rgb;
- vec3 lighting = 0.1 * base;
-
-#ifdef BRANCHING
- if (dot(atten, atten) > 0.0)
-#endif
- {
-
- vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0;
- bump = normalize(bump);
- vec3 reflVec = reflect(-viewVec, bump);
-
- for (int i = 0; i < LIGHT_COUNT; i++){
-#ifndef BRANCHING
- atten[i] *= float(lVec[i].z > 0.0);
-#else
- if (atten[i] > 0.0)
- if (lVec[i].z > 0.0)
-#endif
- {
-
-#ifdef SHADOWS
-# ifndef BRANCHING
- atten[i] *= float(length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]);
-# else
- if (length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i])
-# endif
-#endif
- {
- vec3 lightVec = normalize(lVec[i]);
-
- float diffuse = saturate(dot(lightVec, bump));
- float specular = pow(saturate(dot(reflVec, lightVec)), 16.0);
-
- lighting += atten[i] * lightColor[i] * (diffuse * base + 0.6 * specular);
- }
- }
- }
- }
-
- gl_FragColor.rgb = lighting;
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform samplerCube ShadowMap; + +uniform vec3 lightColor[LIGHT_COUNT]; +uniform vec2 plxCoeffs; + +uniform bool hasParallax; + +varying vec3 lVec[LIGHT_COUNT]; +varying vec2 texCoord; +varying vec3 vVec; +#ifdef SHADOWS +varying vec3 shadowVec[LIGHT_COUNT]; +#endif + +void main(){ +// float atten[LIGHT_COUNT]; + vec3 atten; + for (int i = 0; i < LIGHT_COUNT; i++){ + atten[i] = 1.0 - dot(lVec[i], lVec[i]); + } + atten = max(atten, 0.0); + + + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec3 base = texture2D(Base, plxTexCoord).rgb; + vec3 lighting = 0.1 * base; + +#ifdef BRANCHING + if (dot(atten, atten) > 0.0) +#endif + { + + vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0; + bump = normalize(bump); + vec3 reflVec = reflect(-viewVec, bump); + + for (int i = 0; i < LIGHT_COUNT; i++){ +#ifndef BRANCHING + atten[i] *= float(lVec[i].z > 0.0); +#else + if (atten[i] > 0.0) + if (lVec[i].z > 0.0) +#endif + { + +#ifdef SHADOWS +# ifndef BRANCHING + atten[i] *= float(length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]); +# else + if (length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]) +# endif +#endif + { + vec3 lightVec = normalize(lVec[i]); + + float diffuse = saturate(dot(lightVec, bump)); + float specular = pow(saturate(dot(reflVec, lightVec)), 16.0); + + lighting += atten[i] * lightColor[i] * (diffuse * base + 0.6 * specular); + } + } + } + } + + gl_FragColor.rgb = lighting; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define BRANCHING +#define LIGHT_COUNT 3 +#line 2 +uniform vec3 camPos; +uniform vec3 lightPos[LIGHT_COUNT]; +uniform float invRadius[LIGHT_COUNT]; + +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +varying vec3 lVec[LIGHT_COUNT]; +varying vec2 texCoord; +varying vec3 vVec; +#ifdef SHADOWS +varying vec3 shadowVec[LIGHT_COUNT]; +#endif + +void main(){ + gl_Position = ftransform(); + + texCoord = textureCoord; + + for (int i = 0; i < LIGHT_COUNT; i++){ + vec3 lightVec = invRadius[i] * (lightPos[i] - gl_Vertex.xyz); + +#ifdef SHADOWS + shadowVec[i] = -lightVec; +#endif + lVec[i].x = dot(lightVec, tangent); + lVec[i].y = dot(lightVec, binormal); + lVec[i].z = dot(lightVec, normal); + } + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +} + + diff --git a/shaders/humus-dynamicbranching/13.vert b/shaders/humus-dynamicbranching/13.vert deleted file mode 100644 index b081d0f..0000000 --- a/shaders/humus-dynamicbranching/13.vert +++ /dev/null @@ -1,6 +0,0 @@ -attribute vec4 position; -void main() -{ - gl_Position = position; -} - diff --git a/shaders/humus-dynamicbranching/7.frag b/shaders/humus-dynamicbranching/16.shader_test index f855983..9236545 100644 --- a/shaders/humus-dynamicbranching/7.frag +++ b/shaders/humus-dynamicbranching/16.shader_test @@ -1,84 +1,173 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #define SHADOWS -#define BRANCHING #define LIGHT_COUNT 3 #line 43 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform samplerCube ShadowMap;
-
-uniform vec3 lightColor[LIGHT_COUNT];
-uniform vec2 plxCoeffs;
-
-uniform bool hasParallax;
-
-varying vec3 lVec[LIGHT_COUNT];
-varying vec2 texCoord;
-varying vec3 vVec;
-#ifdef SHADOWS
-varying vec3 shadowVec[LIGHT_COUNT];
-#endif
-
-void main(){
-// float atten[LIGHT_COUNT];
- vec3 atten;
- for (int i = 0; i < LIGHT_COUNT; i++){
- atten[i] = 1.0 - dot(lVec[i], lVec[i]);
- }
- atten = max(atten, 0.0);
-
-
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec3 base = texture2D(Base, plxTexCoord).rgb;
- vec3 lighting = 0.1 * base;
-
-#ifdef BRANCHING
- if (dot(atten, atten) > 0.0)
-#endif
- {
-
- vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0;
- bump = normalize(bump);
- vec3 reflVec = reflect(-viewVec, bump);
-
- for (int i = 0; i < LIGHT_COUNT; i++){
-#ifndef BRANCHING
- atten[i] *= float(lVec[i].z > 0.0);
-#else
- if (atten[i] > 0.0)
- if (lVec[i].z > 0.0)
-#endif
- {
-
-#ifdef SHADOWS
-# ifndef BRANCHING
- atten[i] *= float(length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]);
-# else
- if (length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i])
-# endif
-#endif
- {
- vec3 lightVec = normalize(lVec[i]);
-
- float diffuse = saturate(dot(lightVec, bump));
- float specular = pow(saturate(dot(reflVec, lightVec)), 16.0);
-
- lighting += atten[i] * lightColor[i] * (diffuse * base + 0.6 * specular);
- }
- }
- }
- }
-
- gl_FragColor.rgb = lighting;
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform samplerCube ShadowMap; + +uniform vec3 lightColor[LIGHT_COUNT]; +uniform vec2 plxCoeffs; + +uniform bool hasParallax; + +varying vec3 lVec[LIGHT_COUNT]; +varying vec2 texCoord; +varying vec3 vVec; +#ifdef SHADOWS +varying vec3 shadowVec[LIGHT_COUNT]; +#endif + +void main(){ +// float atten[LIGHT_COUNT]; + vec3 atten; + for (int i = 0; i < LIGHT_COUNT; i++){ + atten[i] = 1.0 - dot(lVec[i], lVec[i]); + } + atten = max(atten, 0.0); + + + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec3 base = texture2D(Base, plxTexCoord).rgb; + vec3 lighting = 0.1 * base; + +#ifdef BRANCHING + if (dot(atten, atten) > 0.0) +#endif + { + + vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0; + bump = normalize(bump); + vec3 reflVec = reflect(-viewVec, bump); + + for (int i = 0; i < LIGHT_COUNT; i++){ +#ifndef BRANCHING + atten[i] *= float(lVec[i].z > 0.0); +#else + if (atten[i] > 0.0) + if (lVec[i].z > 0.0) +#endif + { + +#ifdef SHADOWS +# ifndef BRANCHING + atten[i] *= float(length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]); +# else + if (length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]) +# endif +#endif + { + vec3 lightVec = normalize(lVec[i]); + + float diffuse = saturate(dot(lightVec, bump)); + float specular = pow(saturate(dot(reflVec, lightVec)), 16.0); + + lighting += atten[i] * lightColor[i] * (diffuse * base + 0.6 * specular); + } + } + } + } + + gl_FragColor.rgb = lighting; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define SHADOWS +#define LIGHT_COUNT 3 +#line 2 +uniform vec3 camPos; +uniform vec3 lightPos[LIGHT_COUNT]; +uniform float invRadius[LIGHT_COUNT]; + +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +varying vec3 lVec[LIGHT_COUNT]; +varying vec2 texCoord; +varying vec3 vVec; +#ifdef SHADOWS +varying vec3 shadowVec[LIGHT_COUNT]; +#endif + +void main(){ + gl_Position = ftransform(); + + texCoord = textureCoord; + + for (int i = 0; i < LIGHT_COUNT; i++){ + vec3 lightVec = invRadius[i] * (lightPos[i] - gl_Vertex.xyz); + +#ifdef SHADOWS + shadowVec[i] = -lightVec; +#endif + lVec[i].x = dot(lightVec, tangent); + lVec[i].y = dot(lightVec, binormal); + lVec[i].z = dot(lightVec, normal); + } + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +} + + diff --git a/shaders/humus-dynamicbranching/4.frag b/shaders/humus-dynamicbranching/19.shader_test index 3244b1f..1b1bc75 100644 --- a/shaders/humus-dynamicbranching/4.frag +++ b/shaders/humus-dynamicbranching/19.shader_test @@ -1,82 +1,168 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix +#define SHADOWS +#define BRANCHING #define LIGHT_COUNT 3 #line 43 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform samplerCube ShadowMap;
-
-uniform vec3 lightColor[LIGHT_COUNT];
-uniform vec2 plxCoeffs;
-
-uniform bool hasParallax;
-
-varying vec3 lVec[LIGHT_COUNT];
-varying vec2 texCoord;
-varying vec3 vVec;
-#ifdef SHADOWS
-varying vec3 shadowVec[LIGHT_COUNT];
-#endif
-
-void main(){
-// float atten[LIGHT_COUNT];
- vec3 atten;
- for (int i = 0; i < LIGHT_COUNT; i++){
- atten[i] = 1.0 - dot(lVec[i], lVec[i]);
- }
- atten = max(atten, 0.0);
-
-
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec3 base = texture2D(Base, plxTexCoord).rgb;
- vec3 lighting = 0.1 * base;
-
-#ifdef BRANCHING
- if (dot(atten, atten) > 0.0)
-#endif
- {
-
- vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0;
- bump = normalize(bump);
- vec3 reflVec = reflect(-viewVec, bump);
-
- for (int i = 0; i < LIGHT_COUNT; i++){
-#ifndef BRANCHING
- atten[i] *= float(lVec[i].z > 0.0);
-#else
- if (atten[i] > 0.0)
- if (lVec[i].z > 0.0)
-#endif
- {
-
-#ifdef SHADOWS
-# ifndef BRANCHING
- atten[i] *= float(length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]);
-# else
- if (length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i])
-# endif
-#endif
- {
- vec3 lightVec = normalize(lVec[i]);
-
- float diffuse = saturate(dot(lightVec, bump));
- float specular = pow(saturate(dot(reflVec, lightVec)), 16.0);
-
- lighting += atten[i] * lightColor[i] * (diffuse * base + 0.6 * specular);
- }
- }
- }
- }
-
- gl_FragColor.rgb = lighting;
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform samplerCube ShadowMap; + +uniform vec3 lightColor[LIGHT_COUNT]; +uniform vec2 plxCoeffs; + +uniform bool hasParallax; + +varying vec3 lVec[LIGHT_COUNT]; +varying vec2 texCoord; +varying vec3 vVec; +#ifdef SHADOWS +varying vec3 shadowVec[LIGHT_COUNT]; +#endif + +void main(){ +// float atten[LIGHT_COUNT]; + vec3 atten; + for (int i = 0; i < LIGHT_COUNT; i++){ + atten[i] = 1.0 - dot(lVec[i], lVec[i]); + } + atten = max(atten, 0.0); + + + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec3 base = texture2D(Base, plxTexCoord).rgb; + vec3 lighting = 0.1 * base; + +#ifdef BRANCHING + if (dot(atten, atten) > 0.0) +#endif + { + + vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0; + bump = normalize(bump); + vec3 reflVec = reflect(-viewVec, bump); + + for (int i = 0; i < LIGHT_COUNT; i++){ +#ifndef BRANCHING + atten[i] *= float(lVec[i].z > 0.0); +#else + if (atten[i] > 0.0) + if (lVec[i].z > 0.0) +#endif + { + +#ifdef SHADOWS +# ifndef BRANCHING + atten[i] *= float(length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]); +# else + if (length(shadowVec[i]) < textureCube(ShadowMap, shadowVec[i])[i]) +# endif +#endif + { + vec3 lightVec = normalize(lVec[i]); + + float diffuse = saturate(dot(lightVec, bump)); + float specular = pow(saturate(dot(reflVec, lightVec)), 16.0); + + lighting += atten[i] * lightColor[i] * (diffuse * base + 0.6 * specular); + } + } + } + } + + gl_FragColor.rgb = lighting; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define SHADOWS +#define BRANCHING +#define LIGHT_COUNT 3 +#line 2 +uniform vec3 camPos; +uniform vec3 lightPos[LIGHT_COUNT]; +uniform float invRadius[LIGHT_COUNT]; + +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +varying vec3 lVec[LIGHT_COUNT]; +varying vec2 texCoord; +varying vec3 vVec; +#ifdef SHADOWS +varying vec3 shadowVec[LIGHT_COUNT]; +#endif + +void main(){ + gl_Position = ftransform(); + + texCoord = textureCoord; + + for (int i = 0; i < LIGHT_COUNT; i++){ + vec3 lightVec = invRadius[i] * (lightPos[i] - gl_Vertex.xyz); + +#ifdef SHADOWS + shadowVec[i] = -lightVec; +#endif + lVec[i].x = dot(lightVec, tangent); + lVec[i].y = dot(lightVec, binormal); + lVec[i].z = dot(lightVec, normal); + } + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +} + + diff --git a/shaders/humus-dynamicbranching/2.frag b/shaders/humus-dynamicbranching/2.frag deleted file mode 100644 index 9032629..0000000 --- a/shaders/humus-dynamicbranching/2.frag +++ /dev/null @@ -1,33 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define MULTIPASS -#line 28 -uniform sampler2D Base;
-uniform sampler2D Bump;
-
-uniform vec2 plxCoeffs;
-uniform bool hasParallax;
-
-varying vec2 texCoord;
-varying vec3 vVec;
-
-void main(){
-
-#ifdef MULTIPASS
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec4 base = texture2D(Base, plxTexCoord);
-
- gl_FragColor = 0.1 * base;
-#endif
-
-}
- diff --git a/shaders/humus-dynamicbranching/2.vert b/shaders/humus-dynamicbranching/2.vert deleted file mode 100644 index 2202e78..0000000 --- a/shaders/humus-dynamicbranching/2.vert +++ /dev/null @@ -1,30 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define MULTIPASS -#line 2 -attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-uniform vec3 camPos;
-
-varying vec2 texCoord;
-varying vec3 vVec;
-
-void main(){
- gl_Position = ftransform();
-
-#ifdef MULTIPASS
- texCoord = textureCoord;
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-#endif
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/10.frag b/shaders/humus-dynamicbranching/22.shader_test index 889bbe7..72cd155 100644 --- a/shaders/humus-dynamicbranching/10.frag +++ b/shaders/humus-dynamicbranching/22.shader_test @@ -1,63 +1,136 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix -#define SHADOWS #line 36 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform samplerCube ShadowMap;
-
-uniform vec3 lightColor;
-uniform vec2 plxCoeffs;
-uniform vec4 select;
-
-uniform bool hasParallax;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 shadowVec;
-
-void main(){
- vec3 lighting = vec3(0.0);
-
- float atten = saturate(1.0 - dot(lVec, lVec));
-#ifndef BRANCHING
- atten *= float(lVec.z > 0.0);
-#else
- if (atten > 0.0)
- if (lVec.z > 0.0)
-#endif
- {
-
-#ifdef SHADOWS
-# ifndef BRANCHING
- atten *= float(length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select));
-# else
- if (length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select))
-# endif
-#endif
- {
- vec3 lightVec = normalize(lVec);
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec3 base = texture2D(Base, plxTexCoord).rgb;
- vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0;
- bump = normalize(bump);
-
- float diffuse = saturate(dot(lightVec, bump));
- float specular = pow(saturate(dot(reflect(-viewVec, bump), lightVec)), 16.0);
-
- lighting = atten * lightColor * (diffuse * base + 0.6 * specular);
- }
- }
- gl_FragColor.rgb = lighting;
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform samplerCube ShadowMap; + +uniform vec3 lightColor; +uniform vec2 plxCoeffs; +uniform vec4 select; + +uniform bool hasParallax; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; +varying vec3 shadowVec; + +void main(){ + vec3 lighting = vec3(0.0); + + float atten = saturate(1.0 - dot(lVec, lVec)); +#ifndef BRANCHING + atten *= float(lVec.z > 0.0); +#else + if (atten > 0.0) + if (lVec.z > 0.0) +#endif + { + +#ifdef SHADOWS +# ifndef BRANCHING + atten *= float(length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select)); +# else + if (length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select)) +# endif +#endif + { + vec3 lightVec = normalize(lVec); + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec3 base = texture2D(Base, plxTexCoord).rgb; + vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0; + bump = normalize(bump); + + float diffuse = saturate(dot(lightVec, bump)); + float specular = pow(saturate(dot(reflect(-viewVec, bump), lightVec)), 16.0); + + lighting = atten * lightColor * (diffuse * base + 0.6 * specular); + } + } + gl_FragColor.rgb = lighting; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 2 +uniform vec3 lightPos; +uniform vec3 camPos; +uniform float invRadius; + +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; +varying vec3 shadowVec; + +void main(){ + gl_Position = ftransform(); + + texCoord = textureCoord; + + vec3 lightVec = invRadius * (lightPos - gl_Vertex.xyz); + shadowVec = -lightVec; + lVec.x = dot(lightVec, tangent); + lVec.y = dot(lightVec, binormal); + lVec.z = dot(lightVec, normal); + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +} + + diff --git a/shaders/humus-dynamicbranching/9.frag b/shaders/humus-dynamicbranching/25.shader_test index 6ebce5a..b4e0eba 100644 --- a/shaders/humus-dynamicbranching/9.frag +++ b/shaders/humus-dynamicbranching/25.shader_test @@ -1,63 +1,138 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #define BRANCHING #line 36 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform samplerCube ShadowMap;
-
-uniform vec3 lightColor;
-uniform vec2 plxCoeffs;
-uniform vec4 select;
-
-uniform bool hasParallax;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 shadowVec;
-
-void main(){
- vec3 lighting = vec3(0.0);
-
- float atten = saturate(1.0 - dot(lVec, lVec));
-#ifndef BRANCHING
- atten *= float(lVec.z > 0.0);
-#else
- if (atten > 0.0)
- if (lVec.z > 0.0)
-#endif
- {
-
-#ifdef SHADOWS
-# ifndef BRANCHING
- atten *= float(length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select));
-# else
- if (length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select))
-# endif
-#endif
- {
- vec3 lightVec = normalize(lVec);
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec3 base = texture2D(Base, plxTexCoord).rgb;
- vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0;
- bump = normalize(bump);
-
- float diffuse = saturate(dot(lightVec, bump));
- float specular = pow(saturate(dot(reflect(-viewVec, bump), lightVec)), 16.0);
-
- lighting = atten * lightColor * (diffuse * base + 0.6 * specular);
- }
- }
- gl_FragColor.rgb = lighting;
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform samplerCube ShadowMap; + +uniform vec3 lightColor; +uniform vec2 plxCoeffs; +uniform vec4 select; + +uniform bool hasParallax; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; +varying vec3 shadowVec; + +void main(){ + vec3 lighting = vec3(0.0); + + float atten = saturate(1.0 - dot(lVec, lVec)); +#ifndef BRANCHING + atten *= float(lVec.z > 0.0); +#else + if (atten > 0.0) + if (lVec.z > 0.0) +#endif + { + +#ifdef SHADOWS +# ifndef BRANCHING + atten *= float(length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select)); +# else + if (length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select)) +# endif +#endif + { + vec3 lightVec = normalize(lVec); + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec3 base = texture2D(Base, plxTexCoord).rgb; + vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0; + bump = normalize(bump); + + float diffuse = saturate(dot(lightVec, bump)); + float specular = pow(saturate(dot(reflect(-viewVec, bump), lightVec)), 16.0); + + lighting = atten * lightColor * (diffuse * base + 0.6 * specular); + } + } + gl_FragColor.rgb = lighting; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define BRANCHING +#line 2 +uniform vec3 lightPos; +uniform vec3 camPos; +uniform float invRadius; + +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; +varying vec3 shadowVec; + +void main(){ + gl_Position = ftransform(); + + texCoord = textureCoord; + + vec3 lightVec = invRadius * (lightPos - gl_Vertex.xyz); + shadowVec = -lightVec; + lVec.x = dot(lightVec, tangent); + lVec.y = dot(lightVec, binormal); + lVec.z = dot(lightVec, normal); + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +} + + diff --git a/shaders/humus-dynamicbranching/8.frag b/shaders/humus-dynamicbranching/28.shader_test index d993cbb..adfa75a 100644 --- a/shaders/humus-dynamicbranching/8.frag +++ b/shaders/humus-dynamicbranching/28.shader_test @@ -1,62 +1,138 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix +#define SHADOWS #line 36 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform samplerCube ShadowMap;
-
-uniform vec3 lightColor;
-uniform vec2 plxCoeffs;
-uniform vec4 select;
-
-uniform bool hasParallax;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 shadowVec;
-
-void main(){
- vec3 lighting = vec3(0.0);
-
- float atten = saturate(1.0 - dot(lVec, lVec));
-#ifndef BRANCHING
- atten *= float(lVec.z > 0.0);
-#else
- if (atten > 0.0)
- if (lVec.z > 0.0)
-#endif
- {
-
-#ifdef SHADOWS
-# ifndef BRANCHING
- atten *= float(length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select));
-# else
- if (length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select))
-# endif
-#endif
- {
- vec3 lightVec = normalize(lVec);
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec3 base = texture2D(Base, plxTexCoord).rgb;
- vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0;
- bump = normalize(bump);
-
- float diffuse = saturate(dot(lightVec, bump));
- float specular = pow(saturate(dot(reflect(-viewVec, bump), lightVec)), 16.0);
-
- lighting = atten * lightColor * (diffuse * base + 0.6 * specular);
- }
- }
- gl_FragColor.rgb = lighting;
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform samplerCube ShadowMap; + +uniform vec3 lightColor; +uniform vec2 plxCoeffs; +uniform vec4 select; + +uniform bool hasParallax; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; +varying vec3 shadowVec; + +void main(){ + vec3 lighting = vec3(0.0); + + float atten = saturate(1.0 - dot(lVec, lVec)); +#ifndef BRANCHING + atten *= float(lVec.z > 0.0); +#else + if (atten > 0.0) + if (lVec.z > 0.0) +#endif + { + +#ifdef SHADOWS +# ifndef BRANCHING + atten *= float(length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select)); +# else + if (length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select)) +# endif +#endif + { + vec3 lightVec = normalize(lVec); + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec3 base = texture2D(Base, plxTexCoord).rgb; + vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0; + bump = normalize(bump); + + float diffuse = saturate(dot(lightVec, bump)); + float specular = pow(saturate(dot(reflect(-viewVec, bump), lightVec)), 16.0); + + lighting = atten * lightColor * (diffuse * base + 0.6 * specular); + } + } + gl_FragColor.rgb = lighting; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define SHADOWS +#line 2 +uniform vec3 lightPos; +uniform vec3 camPos; +uniform float invRadius; + +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; +varying vec3 shadowVec; + +void main(){ + gl_Position = ftransform(); + + texCoord = textureCoord; + + vec3 lightVec = invRadius * (lightPos - gl_Vertex.xyz); + shadowVec = -lightVec; + lVec.x = dot(lightVec, tangent); + lVec.y = dot(lightVec, binormal); + lVec.z = dot(lightVec, normal); + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +} + + diff --git a/shaders/humus-dynamicbranching/3.frag b/shaders/humus-dynamicbranching/3.frag deleted file mode 100644 index ad2e73c..0000000 --- a/shaders/humus-dynamicbranching/3.frag +++ /dev/null @@ -1,12 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 13 -uniform sampler2D Base;
-
-varying vec2 texCoord;
-
-void main(){
- gl_FragColor = texture2D(Base, texCoord) * gl_Color;
-}
- diff --git a/shaders/humus-dynamicbranching/3.vert b/shaders/humus-dynamicbranching/3.vert deleted file mode 100644 index 7b0a5d5..0000000 --- a/shaders/humus-dynamicbranching/3.vert +++ /dev/null @@ -1,14 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 2 -varying vec2 texCoord;
-
-void main(){
- gl_Position = ftransform();
- texCoord = gl_MultiTexCoord0.xy;
- gl_FrontColor = gl_Color;
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/11.frag b/shaders/humus-dynamicbranching/31.shader_test index c9ea43d..3c0849a 100644 --- a/shaders/humus-dynamicbranching/11.frag +++ b/shaders/humus-dynamicbranching/31.shader_test @@ -1,64 +1,122 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #define SHADOWS #define BRANCHING #line 36 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform samplerCube ShadowMap;
-
-uniform vec3 lightColor;
-uniform vec2 plxCoeffs;
-uniform vec4 select;
-
-uniform bool hasParallax;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 shadowVec;
-
-void main(){
- vec3 lighting = vec3(0.0);
-
- float atten = saturate(1.0 - dot(lVec, lVec));
-#ifndef BRANCHING
- atten *= float(lVec.z > 0.0);
-#else
- if (atten > 0.0)
- if (lVec.z > 0.0)
-#endif
- {
-
-#ifdef SHADOWS
-# ifndef BRANCHING
- atten *= float(length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select));
-# else
- if (length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select))
-# endif
-#endif
- {
- vec3 lightVec = normalize(lVec);
- vec3 viewVec = normalize(vVec);
-
- vec2 plxTexCoord = texCoord;
- if (hasParallax){
- float height = texture2D(Bump, texCoord).w;
- float offset = height * plxCoeffs.x + plxCoeffs.y;
- plxTexCoord += offset * viewVec.xy;
- }
-
- vec3 base = texture2D(Base, plxTexCoord).rgb;
- vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0;
- bump = normalize(bump);
-
- float diffuse = saturate(dot(lightVec, bump));
- float specular = pow(saturate(dot(reflect(-viewVec, bump), lightVec)), 16.0);
-
- lighting = atten * lightColor * (diffuse * base + 0.6 * specular);
- }
- }
- gl_FragColor.rgb = lighting;
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform samplerCube ShadowMap; + +uniform vec3 lightColor; +uniform vec2 plxCoeffs; +uniform vec4 select; + +uniform bool hasParallax; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; +varying vec3 shadowVec; + +void main(){ + vec3 lighting = vec3(0.0); + + float atten = saturate(1.0 - dot(lVec, lVec)); +#ifndef BRANCHING + atten *= float(lVec.z > 0.0); +#else + if (atten > 0.0) + if (lVec.z > 0.0) +#endif + { + +#ifdef SHADOWS +# ifndef BRANCHING + atten *= float(length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select)); +# else + if (length(shadowVec) < dot(textureCube(ShadowMap, shadowVec), select)) +# endif +#endif + { + vec3 lightVec = normalize(lVec); + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec3 base = texture2D(Base, plxTexCoord).rgb; + vec3 bump = texture2D(Bump, plxTexCoord).xyz * 2.0 - 1.0; + bump = normalize(bump); + + float diffuse = saturate(dot(lightVec, bump)); + float specular = pow(saturate(dot(reflect(-viewVec, bump), lightVec)), 16.0); + + lighting = atten * lightColor * (diffuse * base + 0.6 * specular); + } + } + gl_FragColor.rgb = lighting; +} + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define SHADOWS +#define BRANCHING +#line 2 +uniform vec3 lightPos; +uniform vec3 camPos; +uniform float invRadius; + +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; +varying vec3 shadowVec; + +void main(){ + gl_Position = ftransform(); + + texCoord = textureCoord; + + vec3 lightVec = invRadius * (lightPos - gl_Vertex.xyz); + shadowVec = -lightVec; + lVec.x = dot(lightVec, tangent); + lVec.y = dot(lightVec, binormal); + lVec.z = dot(lightVec, normal); + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +} + + diff --git a/shaders/humus-dynamicbranching/12.vert b/shaders/humus-dynamicbranching/34.shader_test index 0cffa84..229f48f 100644 --- a/shaders/humus-dynamicbranching/12.vert +++ b/shaders/humus-dynamicbranching/34.shader_test @@ -1,19 +1,35 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 18 +varying vec3 lightVec; + +void main(){ + gl_FragColor = vec4(length(lightVec) + 0.005); +} + + +[vertex shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #line 2 -uniform mat4 mvp;
-
-uniform vec3 lightPos;
-uniform float invRadius;
-
-varying vec3 lightVec;
-
-void main(){
- gl_Position = mvp * gl_Vertex;
-
- lightVec = invRadius * (lightPos - gl_Vertex.xyz);
-}
-
-
+uniform mat4 mvp; + +uniform vec3 lightPos; +uniform float invRadius; + +varying vec3 lightVec; + +void main(){ + gl_Position = mvp * gl_Vertex; + + lightVec = invRadius * (lightPos - gl_Vertex.xyz); +} + + diff --git a/shaders/humus-dynamicbranching/4.shader_test b/shaders/humus-dynamicbranching/4.shader_test new file mode 100644 index 0000000..8c97e58 --- /dev/null +++ b/shaders/humus-dynamicbranching/4.shader_test @@ -0,0 +1,77 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define MULTIPASS +#line 28 +uniform sampler2D Base; +uniform sampler2D Bump; + +uniform vec2 plxCoeffs; +uniform bool hasParallax; + +varying vec2 texCoord; +varying vec3 vVec; + +void main(){ + +#ifdef MULTIPASS + vec3 viewVec = normalize(vVec); + + vec2 plxTexCoord = texCoord; + if (hasParallax){ + float height = texture2D(Bump, texCoord).w; + float offset = height * plxCoeffs.x + plxCoeffs.y; + plxTexCoord += offset * viewVec.xy; + } + + vec4 base = texture2D(Base, plxTexCoord); + + gl_FragColor = 0.1 * base; +#endif + +} + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define MULTIPASS +#line 2 +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +uniform vec3 camPos; + +varying vec2 texCoord; +varying vec3 vVec; + +void main(){ + gl_Position = ftransform(); + +#ifdef MULTIPASS + texCoord = textureCoord; + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +#endif +} + + + diff --git a/shaders/humus-dynamicbranching/4.vert b/shaders/humus-dynamicbranching/4.vert deleted file mode 100644 index 9dd0d12..0000000 --- a/shaders/humus-dynamicbranching/4.vert +++ /dev/null @@ -1,45 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define LIGHT_COUNT 3 -#line 2 -uniform vec3 camPos;
-uniform vec3 lightPos[LIGHT_COUNT];
-uniform float invRadius[LIGHT_COUNT];
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec3 lVec[LIGHT_COUNT];
-varying vec2 texCoord;
-varying vec3 vVec;
-#ifdef SHADOWS
-varying vec3 shadowVec[LIGHT_COUNT];
-#endif
-
-void main(){
- gl_Position = ftransform();
-
- texCoord = textureCoord;
-
- for (int i = 0; i < LIGHT_COUNT; i++){
- vec3 lightVec = invRadius[i] * (lightPos[i] - gl_Vertex.xyz);
-
-#ifdef SHADOWS
- shadowVec[i] = -lightVec;
-#endif
- lVec[i].x = dot(lightVec, tangent);
- lVec[i].y = dot(lightVec, binormal);
- lVec[i].z = dot(lightVec, normal);
- }
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/5.vert b/shaders/humus-dynamicbranching/5.vert deleted file mode 100644 index 35161d5..0000000 --- a/shaders/humus-dynamicbranching/5.vert +++ /dev/null @@ -1,46 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define BRANCHING -#define LIGHT_COUNT 3 -#line 2 -uniform vec3 camPos;
-uniform vec3 lightPos[LIGHT_COUNT];
-uniform float invRadius[LIGHT_COUNT];
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec3 lVec[LIGHT_COUNT];
-varying vec2 texCoord;
-varying vec3 vVec;
-#ifdef SHADOWS
-varying vec3 shadowVec[LIGHT_COUNT];
-#endif
-
-void main(){
- gl_Position = ftransform();
-
- texCoord = textureCoord;
-
- for (int i = 0; i < LIGHT_COUNT; i++){
- vec3 lightVec = invRadius[i] * (lightPos[i] - gl_Vertex.xyz);
-
-#ifdef SHADOWS
- shadowVec[i] = -lightVec;
-#endif
- lVec[i].x = dot(lightVec, tangent);
- lVec[i].y = dot(lightVec, binormal);
- lVec[i].z = dot(lightVec, normal);
- }
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/6.vert b/shaders/humus-dynamicbranching/6.vert deleted file mode 100644 index e0867e3..0000000 --- a/shaders/humus-dynamicbranching/6.vert +++ /dev/null @@ -1,46 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define SHADOWS -#define LIGHT_COUNT 3 -#line 2 -uniform vec3 camPos;
-uniform vec3 lightPos[LIGHT_COUNT];
-uniform float invRadius[LIGHT_COUNT];
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec3 lVec[LIGHT_COUNT];
-varying vec2 texCoord;
-varying vec3 vVec;
-#ifdef SHADOWS
-varying vec3 shadowVec[LIGHT_COUNT];
-#endif
-
-void main(){
- gl_Position = ftransform();
-
- texCoord = textureCoord;
-
- for (int i = 0; i < LIGHT_COUNT; i++){
- vec3 lightVec = invRadius[i] * (lightPos[i] - gl_Vertex.xyz);
-
-#ifdef SHADOWS
- shadowVec[i] = -lightVec;
-#endif
- lVec[i].x = dot(lightVec, tangent);
- lVec[i].y = dot(lightVec, binormal);
- lVec[i].z = dot(lightVec, normal);
- }
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/7.shader_test b/shaders/humus-dynamicbranching/7.shader_test new file mode 100644 index 0000000..97bbf47 --- /dev/null +++ b/shaders/humus-dynamicbranching/7.shader_test @@ -0,0 +1,68 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 13 +uniform sampler2D Base; + +varying vec2 texCoord; + +void main(){ + gl_FragColor = texture2D(Base, texCoord) * gl_Color; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 2 +varying vec2 texCoord; + +void main(){ + gl_Position = ftransform(); + texCoord = gl_MultiTexCoord0.xy; + gl_FrontColor = gl_Color; +} + + + diff --git a/shaders/humus-dynamicbranching/7.vert b/shaders/humus-dynamicbranching/7.vert deleted file mode 100644 index 13116ad..0000000 --- a/shaders/humus-dynamicbranching/7.vert +++ /dev/null @@ -1,47 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define SHADOWS -#define BRANCHING -#define LIGHT_COUNT 3 -#line 2 -uniform vec3 camPos;
-uniform vec3 lightPos[LIGHT_COUNT];
-uniform float invRadius[LIGHT_COUNT];
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec3 lVec[LIGHT_COUNT];
-varying vec2 texCoord;
-varying vec3 vVec;
-#ifdef SHADOWS
-varying vec3 shadowVec[LIGHT_COUNT];
-#endif
-
-void main(){
- gl_Position = ftransform();
-
- texCoord = textureCoord;
-
- for (int i = 0; i < LIGHT_COUNT; i++){
- vec3 lightVec = invRadius[i] * (lightPos[i] - gl_Vertex.xyz);
-
-#ifdef SHADOWS
- shadowVec[i] = -lightVec;
-#endif
- lVec[i].x = dot(lightVec, tangent);
- lVec[i].y = dot(lightVec, binormal);
- lVec[i].z = dot(lightVec, normal);
- }
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/8.vert b/shaders/humus-dynamicbranching/8.vert deleted file mode 100644 index c85acdd..0000000 --- a/shaders/humus-dynamicbranching/8.vert +++ /dev/null @@ -1,37 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 2 -uniform vec3 lightPos;
-uniform vec3 camPos;
-uniform float invRadius;
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 shadowVec;
-
-void main(){
- gl_Position = ftransform();
-
- texCoord = textureCoord;
-
- vec3 lightVec = invRadius * (lightPos - gl_Vertex.xyz);
- shadowVec = -lightVec;
- lVec.x = dot(lightVec, tangent);
- lVec.y = dot(lightVec, binormal);
- lVec.z = dot(lightVec, normal);
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-}
-
-
- diff --git a/shaders/humus-dynamicbranching/9.vert b/shaders/humus-dynamicbranching/9.vert deleted file mode 100644 index e9b8a9b..0000000 --- a/shaders/humus-dynamicbranching/9.vert +++ /dev/null @@ -1,38 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define BRANCHING -#line 2 -uniform vec3 lightPos;
-uniform vec3 camPos;
-uniform float invRadius;
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 shadowVec;
-
-void main(){
- gl_Position = ftransform();
-
- texCoord = textureCoord;
-
- vec3 lightVec = invRadius * (lightPos - gl_Vertex.xyz);
- shadowVec = -lightVec;
- lVec.x = dot(lightVec, tangent);
- lVec.y = dot(lightVec, binormal);
- lVec.z = dot(lightVec, normal);
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-}
-
-
- diff --git a/shaders/humus-hdr/1.frag b/shaders/humus-hdr/1.shader_test index d46a8cb..1651957 100644 --- a/shaders/humus-hdr/1.frag +++ b/shaders/humus-hdr/1.shader_test @@ -1,39 +1,91 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix -
-varying vec2 texCoord, lmCoord;
-varying vec3 lightVec;
-varying vec3 vVec;
-
-
+ +varying vec2 texCoord, lmCoord; +varying vec3 lightVec; +varying vec3 vVec; + + #line 36 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform sampler2D LightMap;
-
-uniform vec2 plx;
-uniform float gloss;
-
-const vec3 lightColor = vec3(0.12, 0.14, 0.2);
-
-void main(){
- vec3 viewVec = normalize(vVec);
-
- float height = texture2D(Bump, texCoord).a;
- vec2 plxCoord = texCoord + (height * plx.x + plx.y) * viewVec.xy;
-
-
- vec3 base = texture2D(Base, plxCoord).rgb;
- vec3 bump = texture2D(Bump, plxCoord).xyz;
- vec3 normal = normalize(bump * 2.0 - 1.0);
-
- float diffuse = saturate(dot(lightVec, normal));
- float specular = pow(saturate(dot(reflect(-viewVec, normal), lightVec)), 16.0);
-
-
- vec4 shadow = texture2D(LightMap, lmCoord);
-
- gl_FragColor.rgb = lightColor * (shadow.x * (diffuse * base + gloss * specular) + 0.7 * shadow.w * base);
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform sampler2D LightMap; + +uniform vec2 plx; +uniform float gloss; + +const vec3 lightColor = vec3(0.12, 0.14, 0.2); + +void main(){ + vec3 viewVec = normalize(vVec); + + float height = texture2D(Bump, texCoord).a; + vec2 plxCoord = texCoord + (height * plx.x + plx.y) * viewVec.xy; + + + vec3 base = texture2D(Base, plxCoord).rgb; + vec3 bump = texture2D(Bump, plxCoord).xyz; + vec3 normal = normalize(bump * 2.0 - 1.0); + + float diffuse = saturate(dot(lightVec, normal)); + float specular = pow(saturate(dot(reflect(-viewVec, normal), lightVec)), 16.0); + + + vec4 shadow = texture2D(LightMap, lmCoord); + + gl_FragColor.rgb = lightColor * (shadow.x * (diffuse * base + gloss * specular) + 0.7 * shadow.w * base); +} + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix + +varying vec2 texCoord, lmCoord; +varying vec3 lightVec; +varying vec3 vVec; + + +#line 8 +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; +attribute vec2 lightMapCoord; + +uniform vec3 lightDir; +uniform vec3 camPos; + +void main(){ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + texCoord = textureCoord; + lmCoord = lightMapCoord; + + lightVec.x = dot(lightDir, tangent); + lightVec.y = dot(lightDir, binormal); + lightVec.z = dot(lightDir, normal); + + vec3 viewVec = camPos - gl_Vertex.xyz; + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +} + + diff --git a/shaders/humus-hdr/1.vert b/shaders/humus-hdr/1.vert deleted file mode 100644 index 7916aba..0000000 --- a/shaders/humus-hdr/1.vert +++ /dev/null @@ -1,37 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -
-varying vec2 texCoord, lmCoord;
-varying vec3 lightVec;
-varying vec3 vVec;
-
-
-#line 8 -attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-attribute vec2 lightMapCoord;
-
-uniform vec3 lightDir;
-uniform vec3 camPos;
-
-void main(){
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-
- texCoord = textureCoord;
- lmCoord = lightMapCoord;
-
- lightVec.x = dot(lightDir, tangent);
- lightVec.y = dot(lightDir, binormal);
- lightVec.z = dot(lightDir, normal);
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-}
-
-
- diff --git a/shaders/humus-hdr/10.shader_test b/shaders/humus-hdr/10.shader_test new file mode 100644 index 0000000..9a007e9 --- /dev/null +++ b/shaders/humus-hdr/10.shader_test @@ -0,0 +1,63 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix + +varying vec2 texCoord0; +varying vec2 texCoord1; +varying vec2 texCoord2; +varying vec2 texCoord3; + + +#line 24 +uniform sampler2D Image; + +void main(){ + vec3 base = texture2D(Image, texCoord0).rgb; + base += texture2D(Image, texCoord1).rgb; + base += texture2D(Image, texCoord2).rgb; + base += texture2D(Image, texCoord3).rgb; + + gl_FragColor.rgb = 0.25 * base.rgb; +} + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix + +varying vec2 texCoord0; +varying vec2 texCoord1; +varying vec2 texCoord2; +varying vec2 texCoord3; + + +#line 9 +uniform vec2 sample0, sample1, sample2, sample3; + +void main(){ + gl_Position = gl_Vertex; + + vec2 texCoord = gl_Vertex.xy * 0.5 + 0.5; + texCoord0 = texCoord + sample0; + texCoord1 = texCoord + sample1; + texCoord2 = texCoord + sample2; + texCoord3 = texCoord + sample3; +} + + + diff --git a/shaders/humus-hdr/5.frag b/shaders/humus-hdr/13.shader_test index 9418882..7f6e13e 100644 --- a/shaders/humus-hdr/5.frag +++ b/shaders/humus-hdr/13.shader_test @@ -1,28 +1,50 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix -
-varying vec2 texCoord;
-
-
+ +varying vec2 texCoord; + + #line 15 -uniform sampler2D Base;
-uniform sampler2D Blur;
-
-uniform float exposure;
-uniform float range;
-uniform float blurStrength;
-
-void main(){
- vec4 base = texture2D(Base, texCoord);
- vec4 blur = texture2D(Blur, texCoord);
-
- blur.rgb = pow(blur.rgb, vec3(blurStrength));
-
- blur *= range;
-
- vec4 color = base + blur;
-
- gl_FragColor.rgb = 1.0 - exp(-exposure * color.rgb);
-}
+uniform sampler2D Base; +uniform sampler2D Blur; + +uniform float exposure; +uniform float range; +uniform float blurStrength; + +void main(){ + vec4 base = texture2D(Base, texCoord); + vec4 blur = texture2D(Blur, texCoord); + + blur.rgb = pow(blur.rgb, vec3(blurStrength)); + + blur *= range; + + vec4 color = base + blur; + + gl_FragColor.rgb = 1.0 - exp(-exposure * color.rgb); +} + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix + +varying vec2 texCoord; + + +#line 6 +void main(){ + gl_Position = gl_Vertex; + + texCoord = gl_Vertex.xy * 0.5 + 0.5; +} + + diff --git a/shaders/humus-hdr/2.vert b/shaders/humus-hdr/2.vert deleted file mode 100644 index b888dcc..0000000 --- a/shaders/humus-hdr/2.vert +++ /dev/null @@ -1,15 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -
-varying vec3 cubeCoord;
-
-
-#line 6 -void main(){
- gl_Position = gl_Vertex;
- cubeCoord = gl_MultiTexCoord0.xyz;
-}
-
-
- diff --git a/shaders/humus-hdr/3.frag b/shaders/humus-hdr/3.frag deleted file mode 100644 index ccd7b36..0000000 --- a/shaders/humus-hdr/3.frag +++ /dev/null @@ -1,26 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -
-varying vec2 texCoord0;
-varying vec2 texCoord1;
-varying vec2 texCoord2;
-varying vec2 texCoord3;
-
-
-#line 25 -uniform sampler2D Image;
-
-uniform float invRange;
-
-void main(){
- // Downscale and convert to fixed point
- vec3 base = texture2D(Image, texCoord0).rgb;
- base += texture2D(Image, texCoord1).rgb;
- base += texture2D(Image, texCoord2).rgb;
- base += texture2D(Image, texCoord3).rgb;
-
- // Clamp for nvidia ...
- gl_FragColor.rgb = min(base.rgb * invRange, 1.0);
-}
- diff --git a/shaders/humus-hdr/3.vert b/shaders/humus-hdr/3.vert deleted file mode 100644 index 5addf41..0000000 --- a/shaders/humus-hdr/3.vert +++ /dev/null @@ -1,26 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -
-varying vec2 texCoord0;
-varying vec2 texCoord1;
-varying vec2 texCoord2;
-varying vec2 texCoord3;
-
-
-#line 9 -uniform vec2 halfPixel;
-
-void main(){
- gl_Position = gl_Vertex;
-
- vec2 texCoord = gl_Vertex.xy * 0.5 + 0.5;
-
- texCoord0 = texCoord + halfPixel * vec2( 1, 1);
- texCoord1 = texCoord + halfPixel * vec2(-1, 1);
- texCoord2 = texCoord + halfPixel * vec2(-1, -1);
- texCoord3 = texCoord + halfPixel * vec2( 1, -1);
-}
-
-
- diff --git a/shaders/humus-hdr/4.frag b/shaders/humus-hdr/4.frag deleted file mode 100644 index c9f9c34..0000000 --- a/shaders/humus-hdr/4.frag +++ /dev/null @@ -1,22 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -
-varying vec2 texCoord0;
-varying vec2 texCoord1;
-varying vec2 texCoord2;
-varying vec2 texCoord3;
-
-
-#line 24 -uniform sampler2D Image;
-
-void main(){
- vec3 base = texture2D(Image, texCoord0).rgb;
- base += texture2D(Image, texCoord1).rgb;
- base += texture2D(Image, texCoord2).rgb;
- base += texture2D(Image, texCoord3).rgb;
-
- gl_FragColor.rgb = 0.25 * base.rgb;
-}
- diff --git a/shaders/humus-hdr/2.frag b/shaders/humus-hdr/4.shader_test index 646d789..5edbfac 100644 --- a/shaders/humus-hdr/2.frag +++ b/shaders/humus-hdr/4.shader_test @@ -1,23 +1,64 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix -
-varying vec3 cubeCoord;
-
-
+ +varying vec3 cubeCoord; + + #line 14 -uniform samplerCube RGB;
-uniform samplerCube Exp;
-
-uniform vec2 scaleBias;
-
-void main(){
- vec3 sky = textureCube(RGB, cubeCoord).rgb;
- float ex = textureCube(Exp, cubeCoord).x;
-
- // Expand RGBE
- sky *= exp2(ex * scaleBias.x + scaleBias.y);
-
- gl_FragColor.rgb = sky.rgb;
-}
+uniform samplerCube RGB; +uniform samplerCube Exp; + +uniform vec2 scaleBias; + +void main(){ + vec3 sky = textureCube(RGB, cubeCoord).rgb; + float ex = textureCube(Exp, cubeCoord).x; + + // Expand RGBE + sky *= exp2(ex * scaleBias.x + scaleBias.y); + + gl_FragColor.rgb = sky.rgb; +} + + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix + +varying vec3 cubeCoord; + + +#line 6 +void main(){ + gl_Position = gl_Vertex; + cubeCoord = gl_MultiTexCoord0.xyz; +} + + diff --git a/shaders/humus-hdr/4.vert b/shaders/humus-hdr/4.vert deleted file mode 100644 index 6dd49b7..0000000 --- a/shaders/humus-hdr/4.vert +++ /dev/null @@ -1,25 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -
-varying vec2 texCoord0;
-varying vec2 texCoord1;
-varying vec2 texCoord2;
-varying vec2 texCoord3;
-
-
-#line 9 -uniform vec2 sample0, sample1, sample2, sample3;
-
-void main(){
- gl_Position = gl_Vertex;
-
- vec2 texCoord = gl_Vertex.xy * 0.5 + 0.5;
- texCoord0 = texCoord + sample0;
- texCoord1 = texCoord + sample1;
- texCoord2 = texCoord + sample2;
- texCoord3 = texCoord + sample3;
-}
-
-
- diff --git a/shaders/humus-hdr/5.vert b/shaders/humus-hdr/5.vert deleted file mode 100644 index dd00aed..0000000 --- a/shaders/humus-hdr/5.vert +++ /dev/null @@ -1,16 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -
-varying vec2 texCoord;
-
-
-#line 6 -void main(){
- gl_Position = gl_Vertex;
-
- texCoord = gl_Vertex.xy * 0.5 + 0.5;
-}
-
-
- diff --git a/shaders/humus-hdr/6.frag b/shaders/humus-hdr/6.frag deleted file mode 100644 index 4c72c26..0000000 --- a/shaders/humus-hdr/6.frag +++ /dev/null @@ -1,6 +0,0 @@ -uniform vec4 color; -void main() -{ - gl_FragColor = color; -} - diff --git a/shaders/humus-hdr/6.vert b/shaders/humus-hdr/6.vert deleted file mode 100644 index b081d0f..0000000 --- a/shaders/humus-hdr/6.vert +++ /dev/null @@ -1,6 +0,0 @@ -attribute vec4 position; -void main() -{ - gl_Position = position; -} - diff --git a/shaders/humus-hdr/7.shader_test b/shaders/humus-hdr/7.shader_test new file mode 100644 index 0000000..0c8b415 --- /dev/null +++ b/shaders/humus-hdr/7.shader_test @@ -0,0 +1,77 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix + +varying vec2 texCoord0; +varying vec2 texCoord1; +varying vec2 texCoord2; +varying vec2 texCoord3; + + +#line 25 +uniform sampler2D Image; + +uniform float invRange; + +void main(){ + // Downscale and convert to fixed point + vec3 base = texture2D(Image, texCoord0).rgb; + base += texture2D(Image, texCoord1).rgb; + base += texture2D(Image, texCoord2).rgb; + base += texture2D(Image, texCoord3).rgb; + + // Clamp for nvidia ... + gl_FragColor.rgb = min(base.rgb * invRange, 1.0); +} + + + + + + + + + + + + + + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix + +varying vec2 texCoord0; +varying vec2 texCoord1; +varying vec2 texCoord2; +varying vec2 texCoord3; + + +#line 9 +uniform vec2 halfPixel; + +void main(){ + gl_Position = gl_Vertex; + + vec2 texCoord = gl_Vertex.xy * 0.5 + 0.5; + + texCoord0 = texCoord + halfPixel * vec2( 1, 1); + texCoord1 = texCoord + halfPixel * vec2(-1, 1); + texCoord2 = texCoord + halfPixel * vec2(-1, -1); + texCoord3 = texCoord + halfPixel * vec2( 1, -1); +} + + + diff --git a/shaders/humus-portals/1.frag b/shaders/humus-portals/1.shader_test index 9503ded..feb080a 100644 --- a/shaders/humus-portals/1.frag +++ b/shaders/humus-portals/1.shader_test @@ -1,32 +1,68 @@ +[require] +GLSL >= 1.10 + +[fragment shader] #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #line 26 -
-
-uniform sampler2D Base;
-uniform sampler2D Bump;
-
-uniform float invRadius;
-uniform float ambient;
-
-varying vec2 texCoord;
-varying vec3 lightVec;
-varying vec3 viewVec;
-
-void main(){
- vec4 base = texture2D(Base, texCoord);
- vec3 bump = texture2D(Bump, texCoord).xyz * 2.0 - 1.0;
-
- bump = normalize(bump);
-
- float distSqr = dot(lightVec, lightVec);
- vec3 lVec = lightVec * inversesqrt(distSqr);
-
- float atten = clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0);
- float diffuse = clamp(dot(lVec, bump), 0.0, 1.0);
-
- float specular = pow(clamp(dot(reflect(normalize(-viewVec), bump), lVec), 0.0, 1.0), 16.0);
-
- gl_FragColor = ambient * base + (diffuse * base + 0.6 * specular) * atten;
-}
+ + +uniform sampler2D Base; +uniform sampler2D Bump; + +uniform float invRadius; +uniform float ambient; + +varying vec2 texCoord; +varying vec3 lightVec; +varying vec3 viewVec; + +void main(){ + vec4 base = texture2D(Base, texCoord); + vec3 bump = texture2D(Bump, texCoord).xyz * 2.0 - 1.0; + + bump = normalize(bump); + + float distSqr = dot(lightVec, lightVec); + vec3 lVec = lightVec * inversesqrt(distSqr); + + float atten = clamp(1.0 - invRadius * sqrt(distSqr), 0.0, 1.0); + float diffuse = clamp(dot(lVec, bump), 0.0, 1.0); + + float specular = pow(clamp(dot(reflect(normalize(-viewVec), bump), lVec), 0.0, 1.0), 16.0); + + gl_FragColor = ambient * base + (diffuse * base + 0.6 * specular) * atten; +} + + +[vertex shader] +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 0 + + +varying vec2 texCoord; +varying vec3 lightVec; +varying vec3 viewVec; + +uniform vec3 lightPos; +uniform vec3 camPos; + +void main(){ + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + + texCoord = gl_MultiTexCoord0.xy; + + vec3 lVec = lightPos - gl_Vertex.xyz; + lightVec.x = dot(gl_MultiTexCoord1.xyz, lVec); + lightVec.y = dot(gl_MultiTexCoord2.xyz, lVec); + lightVec.z = dot(gl_MultiTexCoord3.xyz, lVec); + + vec3 vVec = camPos - gl_Vertex.xyz; + viewVec.x = dot(gl_MultiTexCoord1.xyz, vVec); + viewVec.y = dot(gl_MultiTexCoord2.xyz, vVec); + viewVec.z = dot(gl_MultiTexCoord3.xyz, vVec); +} + + diff --git a/shaders/humus-portals/1.vert b/shaders/humus-portals/1.vert deleted file mode 100644 index 7a83406..0000000 --- a/shaders/humus-portals/1.vert +++ /dev/null @@ -1,30 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 0 -
-
-varying vec2 texCoord;
-varying vec3 lightVec;
-varying vec3 viewVec;
-
-uniform vec3 lightPos;
-uniform vec3 camPos;
-
-void main(){
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-
- texCoord = gl_MultiTexCoord0.xy;
-
- vec3 lVec = lightPos - gl_Vertex.xyz;
- lightVec.x = dot(gl_MultiTexCoord1.xyz, lVec);
- lightVec.y = dot(gl_MultiTexCoord2.xyz, lVec);
- lightVec.z = dot(gl_MultiTexCoord3.xyz, lVec);
-
- vec3 vVec = camPos - gl_Vertex.xyz;
- viewVec.x = dot(gl_MultiTexCoord1.xyz, vVec);
- viewVec.y = dot(gl_MultiTexCoord2.xyz, vVec);
- viewVec.z = dot(gl_MultiTexCoord3.xyz, vVec);
-}
-
-
- diff --git a/shaders/humus-portals/2.frag b/shaders/humus-portals/2.frag deleted file mode 100644 index 4c72c26..0000000 --- a/shaders/humus-portals/2.frag +++ /dev/null @@ -1,6 +0,0 @@ -uniform vec4 color; -void main() -{ - gl_FragColor = color; -} - diff --git a/shaders/humus-portals/2.vert b/shaders/humus-portals/2.vert deleted file mode 100644 index b081d0f..0000000 --- a/shaders/humus-portals/2.vert +++ /dev/null @@ -1,6 +0,0 @@ -attribute vec4 position; -void main() -{ - gl_Position = position; -} - diff --git a/shaders/humus-raytracedshadows/1.frag b/shaders/humus-raytracedshadows/1.frag deleted file mode 100644 index 00a7027..0000000 --- a/shaders/humus-raytracedshadows/1.frag +++ /dev/null @@ -1,25 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define SHADOW_SOFTNESS 0.0005 -#define SPHERE_COUNT 7 -#line 26 -
-
-varying vec3 lightVec;
-varying vec4 sphereVec[SPHERE_COUNT];
-
-void main(){
- vec4 shadow = vec4(1.0);
-
- vec3 lVec = lightVec / dot(lightVec, lightVec);
- for (int i = 0; i < SPHERE_COUNT; i++){
- float t = saturate(dot(sphereVec[i].xyz, lVec));
- vec3 p = t * lightVec - sphereVec[i].xyz;
- float len = dot(p, p);
-
- shadow.w *= saturate(SHADOW_SOFTNESS * len - sphereVec[i].w);
- }
-
- gl_FragColor = shadow;
-}
- diff --git a/shaders/humus-raytracedshadows/1.vert b/shaders/humus-raytracedshadows/1.vert deleted file mode 100644 index b480549..0000000 --- a/shaders/humus-raytracedshadows/1.vert +++ /dev/null @@ -1,32 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define SHADOW_SOFTNESS 0.0005 -#define SPHERE_COUNT 7 -#line 0 -
-
-uniform float scale;
-uniform vec3 offset;
-
-uniform vec3 lightPos;
-uniform vec4 spherePos[SPHERE_COUNT];
-
-varying vec3 lightVec;
-varying vec4 sphereVec[SPHERE_COUNT];
-
-void main(){
- vec4 pos = gl_Vertex;
- pos.xyz *= scale;
- pos.xyz += offset;
-
- gl_Position = gl_ModelViewProjectionMatrix * pos;
-
- lightVec = lightPos - pos.xyz;
- for (int i = 0; i < SPHERE_COUNT; i++){
- sphereVec[i].xyz = spherePos[i].xyz - pos.xyz;
- sphereVec[i].w = spherePos[i].w * SHADOW_SOFTNESS - 0.5;
- }
-}
-
-
- diff --git a/shaders/humus-raytracedshadows/2.frag b/shaders/humus-raytracedshadows/2.frag deleted file mode 100644 index 6307be1..0000000 --- a/shaders/humus-raytracedshadows/2.frag +++ /dev/null @@ -1,20 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 26 -
-
-uniform sampler2D Base;
-uniform sampler2D Bump;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-
-void main(){
- vec4 base = texture2D(Base, texCoord);
- vec3 bump = normalize(texture2D(Bump, texCoord).xyz * 2.0 - 1.0);
-
- float diffuse = dot(normalize(lVec), bump);
-
- gl_FragColor = diffuse * base;
-}
- diff --git a/shaders/humus-raytracedshadows/2.vert b/shaders/humus-raytracedshadows/2.vert deleted file mode 100644 index 195cb8e..0000000 --- a/shaders/humus-raytracedshadows/2.vert +++ /dev/null @@ -1,30 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 0 -
-
-uniform vec3 lightPos;
-uniform vec3 camPos;
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-
-void main(){
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- texCoord = textureCoord;
-
- vec3 lightVec = lightPos - gl_Vertex.xyz;
- vec3 viewVec = lightPos - gl_Vertex.xyz;
-
- lVec.x = dot(lightVec, tangent);
- lVec.y = dot(lightVec, binormal);
- lVec.z = dot(lightVec, normal);
-}
-
-
- diff --git a/shaders/humus-raytracedshadows/3.frag b/shaders/humus-raytracedshadows/3.frag deleted file mode 100644 index 649ceaf..0000000 --- a/shaders/humus-raytracedshadows/3.frag +++ /dev/null @@ -1,15 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 12 -
-
-uniform sampler2D Base;
-
-varying vec2 texCoord;
-
-void main(){
- vec4 base = texture2D(Base, texCoord);
-
- gl_FragColor = 0.17 * base;
-}
- diff --git a/shaders/humus-raytracedshadows/3.vert b/shaders/humus-raytracedshadows/3.vert deleted file mode 100644 index 899dc72..0000000 --- a/shaders/humus-raytracedshadows/3.vert +++ /dev/null @@ -1,16 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 0 -
-
-attribute vec2 textureCoord;
-
-varying vec2 texCoord;
-
-void main(){
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- texCoord = textureCoord;
-}
-
-
- diff --git a/shaders/humus-raytracedshadows/4.frag b/shaders/humus-raytracedshadows/4.frag deleted file mode 100644 index 62bb66b..0000000 --- a/shaders/humus-raytracedshadows/4.frag +++ /dev/null @@ -1,22 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 25 -
-
-uniform vec4 color;
-
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 norm;
-
-void main(){
- vec3 lightVec = (lVec);
- vec3 viewVec = (vVec);
- vec3 normal = normalize(norm);
-
- float diffuse = saturate(dot(lightVec, normal));
- float specular = pow(saturate(dot(reflect(-viewVec, normal), lightVec)), 20.0);
-
- gl_FragColor = diffuse * color + specular;
-}
- diff --git a/shaders/humus-raytracedshadows/4.vert b/shaders/humus-raytracedshadows/4.vert deleted file mode 100644 index 9994755..0000000 --- a/shaders/humus-raytracedshadows/4.vert +++ /dev/null @@ -1,29 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 0 -
-
-uniform float scale;
-uniform vec3 offset;
-
-uniform vec3 lightPos;
-uniform vec3 camPos;
-
-varying vec3 lVec;
-varying vec3 vVec;
-varying vec3 norm;
-
-void main(){
- vec4 pos = gl_Vertex;
- pos.xyz *= scale;
- pos.xyz += offset;
-
- gl_Position = gl_ModelViewProjectionMatrix * pos;
-
- lVec = normalize(lightPos - pos.xyz);
- vVec = normalize(camPos - pos.xyz);
- norm = gl_Vertex.xyz;
-}
-
-
- diff --git a/shaders/humus-raytracedshadows/5.frag b/shaders/humus-raytracedshadows/5.frag deleted file mode 100644 index 43cbb45..0000000 --- a/shaders/humus-raytracedshadows/5.frag +++ /dev/null @@ -1,16 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 22 -
-
-uniform vec4 color;
-
-varying vec3 lightVec;
-varying vec3 normal;
-
-void main(){
- float diffuse = 0.17 * (0.4 * dot(lightVec, normal) + 0.6);
-
- gl_FragColor = diffuse * color;
-}
- diff --git a/shaders/humus-raytracedshadows/5.vert b/shaders/humus-raytracedshadows/5.vert deleted file mode 100644 index 3c3c10a..0000000 --- a/shaders/humus-raytracedshadows/5.vert +++ /dev/null @@ -1,26 +0,0 @@ -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 0 -
-
-uniform vec3 lightPos;
-
-uniform float scale;
-uniform vec3 offset;
-
-varying vec3 lightVec;
-varying vec3 normal;
-
-void main(){
- vec4 pos = gl_Vertex;
- pos.xyz *= scale;
- pos.xyz += offset;
-
- gl_Position = gl_ModelViewProjectionMatrix * pos;
-
- lightVec = normalize(lightPos - pos.xyz);
- normal = gl_Vertex.xyz;
-}
-
-
- diff --git a/shaders/humus-raytracedshadows/6.frag b/shaders/humus-raytracedshadows/6.frag deleted file mode 100644 index 4c72c26..0000000 --- a/shaders/humus-raytracedshadows/6.frag +++ /dev/null @@ -1,6 +0,0 @@ -uniform vec4 color; -void main() -{ - gl_FragColor = color; -} - diff --git a/shaders/humus-raytracedshadows/6.vert b/shaders/humus-raytracedshadows/6.vert deleted file mode 100644 index b081d0f..0000000 --- a/shaders/humus-raytracedshadows/6.vert +++ /dev/null @@ -1,6 +0,0 @@ -attribute vec4 position; -void main() -{ - gl_Position = position; -} - diff --git a/shaders/humus-volumetricfogging2/1.frag b/shaders/humus-volumetricfogging2/1.shader_test index d2aacd6..758ee60 100644 --- a/shaders/humus-volumetricfogging2/1.frag +++ b/shaders/humus-volumetricfogging2/1.shader_test @@ -1,86 +1,153 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #define COUNT 40 #define FIRST_PASS #line 52 -uniform sampler2D Base;
-uniform sampler2D Bump;
-uniform sampler3D Fog;
-uniform sampler3D LightMap;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-
-varying vec3 dir;
-
-varying vec3 fogCrd;
-varying vec3 shadowCrd;
-
-uniform float fogStart;
-uniform vec3 shadowStart;
-
-uniform vec4 fogScaleBias;
-uniform vec3 shadowScale, shadowBias;
-
-void main(){
- const vec3 fogColor = vec3(0.9, 1.0, 0.8);
- const float fogDensity = 0.005;
-
- float n = fogDensity * length(dir);
-
- vec3 fogCoord = fogCrd;
- vec3 shadowCoord = shadowCrd;
-
-#ifdef FIRST_PASS
-
- // Regular per pixel lighting
- float atten = 1.0 / (1.0 + 0.000001 * dot(lVec, lVec));
- vec3 lightVec = normalize(lVec);
- vec3 viewVec = normalize(vVec);
-
- vec3 base = texture2D(Base, texCoord).rgb;
- vec3 normal = normalize(texture2D(Bump, texCoord).xyz * 2.0 - 1.0);
-
- float diffuse = saturate(dot(lightVec, normal));
- float specular = pow(saturate(dot(reflect(-viewVec, normal), lightVec)), 16.0);
-
- float shadow = texture3D(LightMap, shadowCrd).x;
-
- vec3 lighting = atten * shadow * (diffuse * base + 0.5 * specular) + 0.14 * base;
-#else
-
- // For later passes, continue the fog computation where we stopped last pass
- fogCoord += fogStart * dir;
- shadowCoord += shadowStart * dir;
-
-#endif
-
- float a = 1.0;
- float b = 0.0;
-
- // Volumetric fog computation
- for (int i = 0; i < COUNT; i++){
- fogCoord += fogScaleBias.w * dir;
- shadowCoord += shadowScale * dir;
-
- float fog = texture3D(Fog, fogCoord).x;
- float shadow = texture3D(LightMap, shadowCoord).x;
-
- // Compute weighting factors. This implements the commented out lerp more efficiently.
- float x = 1.0 - fog * n;
- a *= x;
- b = lerp(shadow, b, x);
- }
-
-#ifdef FIRST_PASS
- gl_FragColor.rgb = lighting * a + fogColor * b;
-#else
- // "lighting" is in the framebuffer, so we use alpha blending to multiply it with "a".
- gl_FragColor.rgb = b * fogColor;
- gl_FragColor.a = a;
-#endif
-
-}
+uniform sampler2D Base; +uniform sampler2D Bump; +uniform sampler3D Fog; +uniform sampler3D LightMap; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; + +varying vec3 dir; + +varying vec3 fogCrd; +varying vec3 shadowCrd; + +uniform float fogStart; +uniform vec3 shadowStart; + +uniform vec4 fogScaleBias; +uniform vec3 shadowScale, shadowBias; + +void main(){ + const vec3 fogColor = vec3(0.9, 1.0, 0.8); + const float fogDensity = 0.005; + + float n = fogDensity * length(dir); + + vec3 fogCoord = fogCrd; + vec3 shadowCoord = shadowCrd; + +#ifdef FIRST_PASS + + // Regular per pixel lighting + float atten = 1.0 / (1.0 + 0.000001 * dot(lVec, lVec)); + vec3 lightVec = normalize(lVec); + vec3 viewVec = normalize(vVec); + + vec3 base = texture2D(Base, texCoord).rgb; + vec3 normal = normalize(texture2D(Bump, texCoord).xyz * 2.0 - 1.0); + + float diffuse = saturate(dot(lightVec, normal)); + float specular = pow(saturate(dot(reflect(-viewVec, normal), lightVec)), 16.0); + + float shadow = texture3D(LightMap, shadowCrd).x; + + vec3 lighting = atten * shadow * (diffuse * base + 0.5 * specular) + 0.14 * base; +#else + + // For later passes, continue the fog computation where we stopped last pass + fogCoord += fogStart * dir; + shadowCoord += shadowStart * dir; + +#endif + + float a = 1.0; + float b = 0.0; + + // Volumetric fog computation + for (int i = 0; i < COUNT; i++){ + fogCoord += fogScaleBias.w * dir; + shadowCoord += shadowScale * dir; + + float fog = texture3D(Fog, fogCoord).x; + float shadow = texture3D(LightMap, shadowCoord).x; + + // Compute weighting factors. This implements the commented out lerp more efficiently. + float x = 1.0 - fog * n; + a *= x; + b = lerp(shadow, b, x); + } + +#ifdef FIRST_PASS + gl_FragColor.rgb = lighting * a + fogColor * b; +#else + // "lighting" is in the framebuffer, so we use alpha blending to multiply it with "a". + gl_FragColor.rgb = b * fogColor; + gl_FragColor.a = a; +#endif + +} + + + + + + + + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#define COUNT 40 +#define FIRST_PASS +#line 2 +uniform mat4 mvp; + +uniform vec3 lightPos; +uniform vec3 camPos; + +attribute vec2 textureCoord; +attribute vec3 tangent; +attribute vec3 binormal; +attribute vec3 normal; + +varying vec2 texCoord; +varying vec3 lVec; +varying vec3 vVec; + +varying vec3 dir; + +varying vec3 fogCrd; +varying vec3 shadowCrd; + + +uniform vec4 fogScaleBias; +uniform vec3 shadowScale, shadowBias; + +void main(){ + gl_Position = mvp * gl_Vertex; + + vec3 viewVec = camPos - gl_Vertex.xyz; + +#ifdef FIRST_PASS + texCoord = textureCoord; + + vec3 lightVec = lightPos - gl_Vertex.xyz; + lVec.x = dot(lightVec, tangent); + lVec.y = dot(lightVec, binormal); + lVec.z = dot(lightVec, normal); + + vVec.x = dot(viewVec, tangent); + vVec.y = dot(viewVec, binormal); + vVec.z = dot(viewVec, normal); +#endif + + dir = viewVec / 40.0; + + fogCrd = gl_Vertex.xyz * fogScaleBias.w + fogScaleBias.xyz; + shadowCrd = gl_Vertex.xyz * shadowScale + shadowBias; +} + + diff --git a/shaders/humus-volumetricfogging2/1.vert b/shaders/humus-volumetricfogging2/1.vert deleted file mode 100644 index 6b1d7af..0000000 --- a/shaders/humus-volumetricfogging2/1.vert +++ /dev/null @@ -1,55 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#define COUNT 40 -#define FIRST_PASS -#line 2 -uniform mat4 mvp;
-
-uniform vec3 lightPos;
-uniform vec3 camPos;
-
-attribute vec2 textureCoord;
-attribute vec3 tangent;
-attribute vec3 binormal;
-attribute vec3 normal;
-
-varying vec2 texCoord;
-varying vec3 lVec;
-varying vec3 vVec;
-
-varying vec3 dir;
-
-varying vec3 fogCrd;
-varying vec3 shadowCrd;
-
-
-uniform vec4 fogScaleBias;
-uniform vec3 shadowScale, shadowBias;
-
-void main(){
- gl_Position = mvp * gl_Vertex;
-
- vec3 viewVec = camPos - gl_Vertex.xyz;
-
-#ifdef FIRST_PASS
- texCoord = textureCoord;
-
- vec3 lightVec = lightPos - gl_Vertex.xyz;
- lVec.x = dot(lightVec, tangent);
- lVec.y = dot(lightVec, binormal);
- lVec.z = dot(lightVec, normal);
-
- vVec.x = dot(viewVec, tangent);
- vVec.y = dot(viewVec, binormal);
- vVec.z = dot(viewVec, normal);
-#endif
-
- dir = viewVec / 40.0;
-
- fogCrd = gl_Vertex.xyz * fogScaleBias.w + fogScaleBias.xyz;
- shadowCrd = gl_Vertex.xyz * shadowScale + shadowBias;
-}
-
-
- diff --git a/shaders/humus-volumetricfogging2/12.shader_test b/shaders/humus-volumetricfogging2/12.shader_test new file mode 100644 index 0000000..7497b6b --- /dev/null +++ b/shaders/humus-volumetricfogging2/12.shader_test @@ -0,0 +1,22 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +uniform ivec4 color; +out ivec4 out_color; + +void main() +{ + out_color = color; +} + +[vertex shader] +#version 130 +in vec4 position; +void main() +{ + gl_Position = position; +} + + diff --git a/shaders/humus-volumetricfogging2/2.frag b/shaders/humus-volumetricfogging2/2.frag deleted file mode 100644 index 469786f..0000000 --- a/shaders/humus-volumetricfogging2/2.frag +++ /dev/null @@ -1,8 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 11 -void main(){
- gl_FragColor = vec4(0.0);
-}
- diff --git a/shaders/humus-volumetricfogging2/2.vert b/shaders/humus-volumetricfogging2/2.vert deleted file mode 100644 index e42df26..0000000 --- a/shaders/humus-volumetricfogging2/2.vert +++ /dev/null @@ -1,12 +0,0 @@ -#version 120 -#define saturate(x) clamp(x,0.0,1.0) -#define lerp mix -#line 2 -uniform mat4 mvp;
-
-void main(){
- gl_Position = mvp * gl_Vertex;
-}
-
-
- diff --git a/shaders/humus-volumetricfogging2/3.frag b/shaders/humus-volumetricfogging2/3.frag deleted file mode 100644 index 4c72c26..0000000 --- a/shaders/humus-volumetricfogging2/3.frag +++ /dev/null @@ -1,6 +0,0 @@ -uniform vec4 color; -void main() -{ - gl_FragColor = color; -} - diff --git a/shaders/humus-volumetricfogging2/3.vert b/shaders/humus-volumetricfogging2/3.vert deleted file mode 100644 index b081d0f..0000000 --- a/shaders/humus-volumetricfogging2/3.vert +++ /dev/null @@ -1,6 +0,0 @@ -attribute vec4 position; -void main() -{ - gl_Position = position; -} - diff --git a/shaders/humus-volumetricfogging2/4.shader_test b/shaders/humus-volumetricfogging2/4.shader_test new file mode 100644 index 0000000..be18f26 --- /dev/null +++ b/shaders/humus-volumetricfogging2/4.shader_test @@ -0,0 +1,25 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 11 +void main(){ + gl_FragColor = vec4(0.0); +} + +[vertex shader] +#version 130 +#define saturate(x) clamp(x,0.0,1.0) +#define lerp mix +#line 2 +uniform mat4 mvp; + +void main(){ + gl_Position = mvp * gl_Vertex; +} + + + diff --git a/shaders/humus-volumetricfogging2/9.shader_test b/shaders/humus-volumetricfogging2/9.shader_test new file mode 100644 index 0000000..30ba541 --- /dev/null +++ b/shaders/humus-volumetricfogging2/9.shader_test @@ -0,0 +1,17 @@ +[require] +GLSL >= 1.10 + +[fragment shader] +uniform vec4 color; +void main() +{ + gl_FragColor = color; +} + +[vertex shader] +attribute vec4 position; +void main() +{ + gl_Position = position; +} + |