summaryrefslogtreecommitdiff
path: root/shaders/humus-dynamicbranching/4.shader_test
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/humus-dynamicbranching/4.shader_test')
-rw-r--r--shaders/humus-dynamicbranching/4.shader_test77
1 files changed, 77 insertions, 0 deletions
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
+}
+
+
+