Reflective planet water

This commit is contained in:
Anuken
2020-04-02 12:32:55 -04:00
parent 19239a6890
commit a26cd46a7e
7 changed files with 22 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ attribute vec4 a_color;
uniform mat4 u_proj;
uniform mat4 u_trans;
uniform vec3 u_lightdir;
//uniform vec3 u_camdir;
uniform vec3 u_camdir;
uniform vec3 u_ambientColor;
varying vec4 v_col;
@@ -14,7 +14,12 @@ const vec3 diffuse = vec3(0);
void main(){
vec3 norc = u_ambientColor * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
float falloff = 4.0;
float shinelen = 0.2;
float shinedot = max((-dot(u_camdir, a_normal) - (1.0 - shinelen)) / shinelen, 0.0);
float shinyness = (1.0 - a_color.a) * pow(shinedot, falloff);
vec4 baseCol = vec4(a_color.rgb, 1.0);
v_col = a_color * vec4(norc, 1.0);
v_col = lerp(baseCol * vec4(norc, 1.0), vec4(1.0), shinyness * norc.r);
gl_Position = u_proj * u_trans * a_position;
}