diff options
Diffstat (limited to 'shaders/humus-dynamicbranching')
29 files changed, 1441 insertions, 1065 deletions
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/8.frag b/shaders/humus-dynamicbranching/22.shader_test index d993cbb..72cd155 100644 --- a/shaders/humus-dynamicbranching/8.frag +++ b/shaders/humus-dynamicbranching/22.shader_test @@ -1,62 +1,136 @@ -#version 120 +[require] +GLSL >= 1.10 + +[fragment shader] +#version 130 #define saturate(x) clamp(x,0.0,1.0) #define lerp mix #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/10.frag b/shaders/humus-dynamicbranching/28.shader_test index 889bbe7..adfa75a 100644 --- a/shaders/humus-dynamicbranching/10.frag +++ b/shaders/humus-dynamicbranching/28.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 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);
-}
-
-
- |