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.vs

34 lines
882 B
Text
Raw Normal View History

2023-05-19 13:14:48 +02:00
#version 330
2023-05-21 10:19:04 +02:00
layout(location = 0) in vec3 vsiPosition;
layout(location = 1) in vec3 vsiNormal;
layout(location = 2) in vec2 vsiTexCoord;
out vec2 vsoTexCoord;
out vec3 vsoNormal;
out vec4 vsoModPos;
out float vsoIntensiteLum;
uniform mat4 proj, model, view;
uniform vec4 lumPos;
uniform float phase;
void main(void) {
mat4 N = transpose(inverse(view * model));
vsoNormal = normalize((N * vec4(vsiNormal, 0)).xyz);
vec4 lumPosv = view * lumPos;
float dist = length(vsiPosition.xz), freq = 5, amplitude = 0.1 * (sqrt(2.) - dist);
float y = amplitude * cos(phase + freq * dist);
vec3 p = vec3(vsiPosition.x, y, vsiPosition.z);
vsoModPos = view * model * vec4(p, 1);
vec3 Ld = normalize(vsoModPos - lumPosv).xyz;
vsoIntensiteLum = clamp(dot(-Ld, vsoNormal), 0., 1.);
gl_Position = proj * vsoModPos;
vsoTexCoord = vec2(vsiTexCoord.x, 1 - vsiTexCoord.y);
2023-05-19 13:14:48 +02:00
}