Merge pull request #1530 from Wallbreaker5th/master

Modified the shaders slightly
This commit is contained in:
Grant Sanderson 2021-06-14 09:44:01 -07:00 committed by GitHub
commit 44a9c6337e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 7 deletions

View file

@ -17,16 +17,16 @@ vec4 add_light(vec4 color,
float shadow){
if(gloss == 0.0 && shadow == 0.0) return color;
// TODO, do we actually want this? It effectively treats surfaces as two-sided
if(unit_normal.z < 0){
unit_normal *= -1;
}
// TODO, read this in as a uniform?
float camera_distance = 6;
float camera_distance = focal_distance;
// Assume everything has already been rotated such that camera is in the z-direction
vec3 to_camera = vec3(0, 0, camera_distance) - point;
vec3 to_light = light_coords - point;
// TODO, do we actually want this? It effectively treats surfaces as two-sided
if(dot(to_camera,unit_normal) < 0){
unit_normal *= -1;
}
vec3 light_reflection = -to_light + 2 * unit_normal * dot(to_light, unit_normal);
float dot_prod = dot(normalize(light_reflection), normalize(to_camera));
float shine = gloss * exp(-3 * pow(1 - dot_prod, 2));

View file

@ -3,6 +3,7 @@
uniform vec3 light_source_position;
uniform float gloss;
uniform float shadow;
uniform float focal_distance;
in vec3 xyz_coords;
in vec3 v_normal;

View file

@ -6,6 +6,7 @@ uniform float num_textures;
uniform vec3 light_source_position;
uniform float gloss;
uniform float shadow;
uniform float focal_distance;
in vec3 xyz_coords;
in vec3 v_normal;

View file

@ -4,6 +4,7 @@ uniform vec3 light_source_position;
uniform float gloss;
uniform float shadow;
uniform float anti_alias_width;
uniform float focal_distance;
in vec4 color;
in float radius;