summaryrefslogtreecommitdiff
path: root/shaders/humus-portals/1.frag
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/humus-portals/1.frag')
-rw-r--r--shaders/humus-portals/1.frag32
1 files changed, 32 insertions, 0 deletions
diff --git a/shaders/humus-portals/1.frag b/shaders/humus-portals/1.frag
new file mode 100644
index 0000000..9503ded
--- /dev/null
+++ b/shaders/humus-portals/1.frag
@@ -0,0 +1,32 @@
+#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;
+}
+