17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 02:58:37 +01:00

Make the material shaders physically based

This commit is contained in:
2026-10-20 18:39:31 +02:00
parent cf36b24e8d
commit 7d0f76aaa9
20 changed files with 288 additions and 258 deletions

View File

@@ -58,7 +58,8 @@ void main()
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
float reflectivity = param[1].z * texture(normalmap, texture_coords ).a;
float specularity = 1.0;
// water reflects 2% at normal incidence
float specularity = 0.25;
glossiness = abs(param[1].w);
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
@@ -70,10 +71,10 @@ void main()
// fresnel effect
vec3 view_dir = normalize(vec3(0.0f, 0.0f, 0.0f) - f_pos.xyz);
float fresnel = pow ( dot (f_normal, view_dir), 0.2 );
float fresnel = pow(max(dot(normalize(f_normal), view_dir), 0.0), 0.2);
float fresnel_inv = ((fresnel - 1.0 ) * -1.0 );
vec4 color = vec4(apply_fog(clamp(fragcolor, 0.0, 1.0)), clamp((fresnel_inv + param[0].a), 0.0, 1.0));
vec4 color = vec4(apply_fog(fragcolor), clamp((fresnel_inv + param[0].a), 0.0, 1.0));
#if POSTFX_ENABLED
out_color = color;
#else