1
0
Fork 0

implement basic shader

This commit is contained in:
Sen 2025-08-28 17:41:29 +02:00
parent 563f235b2f
commit cf0239c76e
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
6 changed files with 114 additions and 104 deletions

View file

@ -10,10 +10,13 @@ struct light_t {
in vec3 vertex;
in vec3 normal;
in vec4 brightness;
in vec2 tex_coord;
in vec2 lm_coord;
uniform vec3 cam_pos;
uniform sampler2D tex;
uniform sampler2D lightmap;
uniform vec3 specular;
uniform float shine;
uniform float max_vert_dist;
@ -72,8 +75,9 @@ vec3 calc_point_light(light_t light, vec3 norm, vec3 dir, vec3 rgb) {
void main() {
vec3 norm = normalize(normal);
vec3 dir = normalize(cam_pos - vertex);
vec4 texel = texture(tex, tex_coord);
vec3 rgb = texel.rgb * texel.a;
vec4 texel = texture(tex, tex_coord) * brightness;
vec3 light_v = texture(lightmap, vec2(0.03125 + lm_coord.x * 256, 0.03125 + lm_coord.y * 256)).rgb;
vec3 rgb = texel.rgb;
vec3 result = calc_dir_light(norm, dir, rgb);
// int l = 0;
for(int z = 0; z < n_lights; z++) {
@ -83,5 +87,5 @@ void main() {
// l++;
// }
}
FragColor = vec4(result, 1.0);
FragColor = texel * vec4(light_v, 1.0); // vec4(result, texel.a);
}