Real-time lighting + solar system rendering

This commit is contained in:
Anuken
2020-02-29 11:58:10 -05:00
parent f0857fa22d
commit 7a01719816
20 changed files with 491 additions and 356 deletions

View File

@@ -2,20 +2,22 @@ attribute vec4 a_position;
attribute vec3 a_normal;
attribute vec4 a_color;
uniform mat4 u_projModelView;
uniform mat4 u_proj;
uniform mat4 u_trans;
uniform vec3 u_lightdir;
uniform vec3 u_ambientColor;
varying vec4 v_col;
const vec3 ambientColor = vec3(1.0);
const vec3 ambientDir = normalize(vec3(1.0, 1.0, 1.0));
const vec3 diffuse = vec3(0.3);
const vec3 diffuse = vec3(0.2);
const vec3 v1 = vec3(1.0, 0.0, 1.0);
const vec3 v2 = vec3(1.0, 0.5, 0.0);
void main(){
vec3 norc = ambientColor * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
vec3 norc = u_ambientColor * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
v_col = a_color * vec4(norc, 1.0);
gl_Position = u_projModelView * a_position;
gl_Position = u_proj * u_trans * a_position;
}

View File

@@ -1,12 +1,14 @@
attribute vec4 a_position;
attribute vec4 a_color;
uniform mat4 u_projModelView;
uniform mat4 u_proj;
uniform mat4 u_trans;
varying vec4 v_col;
varying vec4 v_position;
void main() {
gl_Position = u_projModelView * a_position;
gl_Position = u_proj * u_trans * a_position;
v_col = a_color;
v_position = a_position;
}

View File

@@ -1,9 +1,9 @@
attribute vec4 a_position;
attribute vec3 a_normal;
uniform mat4 u_projModelView;
uniform mat4 u_proj;
uniform mat4 u_trans;
uniform vec3 u_center;
uniform float u_time;
uniform int u_octaves;
uniform float u_falloff;
@@ -100,8 +100,7 @@ float onoise(vec4 pos, int octaves, float falloff, float scl, float po){
}
void main(){
vec3 center = u_center;
vec4 pos = u_projModelView * (a_position);
vec4 pos = a_position;
float height = onoise(vec4(a_position.xyz, u_time + u_seed), u_octaves, u_falloff, u_scale, u_power);
@@ -111,7 +110,5 @@ void main(){
v_height = (height + (onoise(vec4(a_position.xyz, u_time + u_seed*2.0), u_octaves, u_falloff, u_scale, u_power) - 0.5) / 6.0 - 0.5) * u_spread + 0.5;
vec3 rel = (-vec3(pos) + ((vec3(pos) - center) * dst + center));
gl_Position = u_projModelView * (a_position + vec4(center.xyz, 0.0)) + vec4(rel, 0.0);
gl_Position = u_proj * u_trans * a_position; //u_proj * (a_position + vec4(pos.xyz * (dst - 1.0), 0.0));
}