2020-06-04 17:17:38 -07:00
|
|
|
#version 330
|
|
|
|
|
2020-06-08 15:06:22 -07:00
|
|
|
uniform sampler2D LightTexture;
|
|
|
|
uniform sampler2D DarkTexture;
|
2020-06-08 15:57:12 -07:00
|
|
|
uniform float num_textures;
|
2020-06-04 17:17:38 -07:00
|
|
|
|
|
|
|
in vec3 xyz_coords;
|
|
|
|
in vec3 v_normal;
|
|
|
|
in vec2 v_im_coords;
|
|
|
|
in float v_opacity;
|
|
|
|
|
|
|
|
out vec4 frag_color;
|
|
|
|
|
2021-01-09 22:11:38 -08:00
|
|
|
#INSERT finalize_color.glsl
|
2020-06-04 17:17:38 -07:00
|
|
|
|
2020-06-08 15:57:12 -07:00
|
|
|
const float dark_shift = 0.2;
|
|
|
|
|
2020-06-04 17:17:38 -07:00
|
|
|
void main() {
|
2020-06-08 15:57:12 -07:00
|
|
|
vec4 color = texture(LightTexture, v_im_coords);
|
|
|
|
if(num_textures == 2.0){
|
|
|
|
vec4 dark_color = texture(DarkTexture, v_im_coords);
|
|
|
|
float dp = dot(
|
|
|
|
normalize(light_source_position - xyz_coords),
|
|
|
|
normalize(v_normal)
|
|
|
|
);
|
|
|
|
float alpha = smoothstep(-dark_shift, dark_shift, dp);
|
|
|
|
color = mix(dark_color, color, alpha);
|
|
|
|
}
|
2020-06-08 15:06:22 -07:00
|
|
|
|
2021-01-09 22:11:38 -08:00
|
|
|
frag_color = finalize_color(
|
2020-06-08 15:06:22 -07:00
|
|
|
color,
|
2020-06-06 16:55:56 -07:00
|
|
|
xyz_coords,
|
|
|
|
normalize(v_normal),
|
|
|
|
light_source_position,
|
2021-11-08 21:43:57 -08:00
|
|
|
camera_position,
|
|
|
|
reflectiveness,
|
2020-06-28 12:13:25 -07:00
|
|
|
gloss,
|
|
|
|
shadow
|
2020-06-06 16:55:56 -07:00
|
|
|
);
|
2020-06-04 17:17:38 -07:00
|
|
|
frag_color.a = v_opacity;
|
|
|
|
}
|