1
0
Fork 0

improve rendering, fix lightmap

This commit is contained in:
Sen 2025-08-31 01:07:13 +02:00
parent ec9173433e
commit 0e003971bc
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
4 changed files with 15 additions and 13 deletions

View file

@ -72,35 +72,37 @@ vec4 pcf_sample(sampler2D stex, vec2 pos) {
*/
vec3 calc_dir_light(vec3 norm, vec3 dir, vec3 rgb, vec3 direction, vec3 color) {
if(shine <= -2.0)
return color * rgb;
vec3 ldir = normalize(-direction);
float diff = max(dot(norm, ldir), 0.0);
vec3 rdir = reflect(-ldir, norm);
float spec = pow(max(dot(dir, rdir), 0.0), shine);
vec3 ambient = color * rgb + clamp(vec3(0.0), 0.0, 1.0);
float spec = shine <= 0.0 ? 0.0 : pow(max(dot(dir, rdir), 0.0), shine) * (shine < 1.0 ? shine : 1.0);
vec3 ambient = color * rgb; // + clamp(vec3(0.0), 0.0, 1.0);
vec3 diffuse = color * 0.125 * diff * rgb;
vec3 specular = color * 1.25 * spec * specular * rgb;
return (ambient + diffuse + specular);
vec3 speculars = color * 1.25 * spec * specular * rgb;
return (ambient + diffuse + speculars);
}
vec3 calc_point_light(light_t light, vec3 norm, vec3 dir, vec3 rgb) {
rgb = clamp(rgb + light_factor, 0.0, 1.0);
vec3 ldir = normalize(light.position.xyz - vertex);
float diff = max(dot(norm, ldir), 0.0);
float diff = shine <= -3.0 ? 0.0 : max(dot(norm, ldir), 0.0);
vec3 rdir = reflect(-ldir, norm);
float spec = pow(max(dot(dir, rdir), 0.0), shine);
float spec = shine <= -1.0 ? 0.0 : pow(max(dot(dir, rdir), 0.0), shine) * (shine < 1.0 ? shine : 1.0);
float distance = length((light.position.xyz - vertex) / light.range.xyz);
float attenuation = 1.0 / (light.ambient.w + light.diffuse.w * distance + light.specular.w * (distance * distance));
vec3 ambient = light.ambient.xyz * rgb;
vec3 diffuse = light.diffuse.xyz * diff * rgb;
vec3 specular = light.specular.xyz * spec * specular * rgb;
vec3 speculars = light.specular.xyz * spec * specular * rgb;
ambient *= attenuation;
diffuse *= attenuation;
specular *= attenuation;
return (ambient + diffuse + specular);
speculars *= attenuation;
return (ambient + diffuse + speculars);
}
void main() {
if(shine <= 0.0) {
if(shine <= -16.0) {
vec2 coord = fract(tex_coord * textureSize(tex, 0) / 256.0) * vis_div; // vertex.xz + vec2(0.25, 0.5)) * 24.0 / 2.0;
vec2 shift = vec2(v2rand(coord + fract(time)) * 2.0 - 1.0, v2rand(coord + 0.5 + fract(time)) * 2.0 - 1.0);
shift = vec2(dgauss(shift.x, 0.0, 1.0), dgauss(shift.y, 0.0, 1.0)) * 0.015;