This repository has been archived on 2023-05-27. You can view files and clone it, but cannot push or open issues or pull requests.
api8/shaders/tag.fs

33 lines
825 B
Forth
Raw Permalink Normal View History

2023-05-19 13:14:48 +02:00
#version 330
2023-05-21 10:19:04 +02:00
in vec3 vsoNormal;
in vec4 vsoModPos;
in vec2 vsoTexCoord;
out vec4 fragColor;
uniform sampler2D tex0;
2023-05-21 20:32:08 +02:00
uniform sampler2D tex1;
2023-05-21 10:19:04 +02:00
uniform mat4 viewMatrix;
uniform vec4 lumPos;
2023-05-21 20:32:08 +02:00
uniform float fadeAmount;
const float fadeStart = 0;
const float fadeEnd = 1;
2023-05-21 10:19:04 +02:00
void main(void) {
const vec3 Vu = vec3(0, 0, -1);
vec4 lumPosv = viewMatrix * lumPos;
vec3 Ld = normalize(vsoModPos - lumPosv).xyz;
vec3 reflexion = normalize(reflect(Ld, vsoNormal));
float ispec = pow(clamp(dot(-Vu, reflexion), 0., 1.), 20);
float phongIL = clamp(dot(-Ld, vsoNormal), 0., 1.);
2023-05-21 20:32:08 +02:00
vec4 color1 = texture(tex0, vsoTexCoord);
vec4 color2 = texture(tex1, vsoTexCoord);
2023-05-23 12:22:14 +02:00
float fadeFactor = smoothstep(fadeStart, fadeEnd, fadeAmount / vsoTexCoord.x);
2023-05-21 20:32:08 +02:00
2023-05-23 12:22:14 +02:00
fragColor = phongIL * mix(color1, color2, fadeFactor) + ispec * vec4(1);
2023-05-19 13:14:48 +02:00
}