mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-05 12:09:02 +01:00
Make the default material matte
This commit is contained in:
@@ -236,6 +236,9 @@ const float SUN_BRDF_LIMIT = 1.0e6;
|
|||||||
vec3 spec_f0 = vec3(0.04);
|
vec3 spec_f0 = vec3(0.04);
|
||||||
float spec_roughness = 0.5;
|
float spec_roughness = 0.5;
|
||||||
|
|
||||||
|
// a matte material (mat_default) reflects nothing: neither the surroundings nor the sun and the lamps, only the diffuse light
|
||||||
|
bool matte = false;
|
||||||
|
|
||||||
// light of a light from Light_dir reflected by the surface, in the units of the diffuse shading (a white lambertian surface
|
// light of a light from Light_dir reflected by the surface, in the units of the diffuse shading (a white lambertian surface
|
||||||
// facing the light reflects 1 of it): pi times the cook-torrance brdf with schlick's fresnel of F0, times n.l. Limit caps the
|
// facing the light reflects 1 of it): pi times the cook-torrance brdf with schlick's fresnel of F0, times n.l. Limit caps the
|
||||||
// brdf without the n.l
|
// brdf without the n.l
|
||||||
@@ -545,6 +548,8 @@ void add_local_light(light_s light, vec2 part, vec3 fragnormal, inout vec3 diffu
|
|||||||
return;
|
return;
|
||||||
vec3 color = light.color * light.intensity;
|
vec3 color = light.color * light.intensity;
|
||||||
diffuse += color * part.x;
|
diffuse += color * part.x;
|
||||||
|
if (matte)
|
||||||
|
return;
|
||||||
specular += color * (part.y * param[1].y) * specular_light(normalize(light.pos - f_pos.xyz), fragnormal, spec_f0, spec_roughness, LOCAL_LIGHT_BRDF_LIMIT);
|
specular += color * (part.y * param[1].y) * specular_light(normalize(light.pos - f_pos.xyz), fragnormal, spec_f0, spec_roughness, LOCAL_LIGHT_BRDF_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -713,6 +718,11 @@ vec3 shade_surface(vec3 fragcolor, vec3 fragnormal, vec3 texturecolor, float ref
|
|||||||
vec3 cubemap_spec = env_spec;
|
vec3 cubemap_spec = env_spec;
|
||||||
float cubemap_share = max(reflectivity, 0.0);
|
float cubemap_share = max(reflectivity, 0.0);
|
||||||
float ambient_share = clamp(1.0 - reflectivity, 0.0, 1.0);
|
float ambient_share = clamp(1.0 - reflectivity, 0.0, 1.0);
|
||||||
|
if (matte)
|
||||||
|
{
|
||||||
|
env_spec = vec3(0.0);
|
||||||
|
cubemap_share = 0.0;
|
||||||
|
}
|
||||||
// what the diffuse layer is left with
|
// what the diffuse layer is left with
|
||||||
vec3 diffuse_albedo = texturecolor * (1.0 - metalic) * (1.0 - env_spec);
|
vec3 diffuse_albedo = texturecolor * (1.0 - metalic) * (1.0 - env_spec);
|
||||||
if (legacy_coat)
|
if (legacy_coat)
|
||||||
@@ -723,7 +733,7 @@ vec3 shade_surface(vec3 fragcolor, vec3 fragnormal, vec3 texturecolor, float ref
|
|||||||
ambient_share = 1.0;
|
ambient_share = 1.0;
|
||||||
diffuse_albedo *= 1.0 - cubemap_spec * min(cubemap_share, 1.0);
|
diffuse_albedo *= 1.0 - cubemap_spec * min(cubemap_share, 1.0);
|
||||||
}
|
}
|
||||||
vec3 envcolor = envmap_color_rough(fragnormal, env_roughness);
|
vec3 envcolor = (matte ? vec3(0.0) : envmap_color_rough(fragnormal, env_roughness));
|
||||||
|
|
||||||
if (lights_count == 0U)
|
if (lights_count == 0U)
|
||||||
return fragcolor * diffuse_albedo
|
return fragcolor * diffuse_albedo
|
||||||
@@ -766,7 +776,7 @@ vec3 shade_surface(vec3 fragcolor, vec3 fragnormal, vec3 texturecolor, float ref
|
|||||||
// nothing to the highlight
|
// nothing to the highlight
|
||||||
if (!sunless)
|
if (!sunless)
|
||||||
fragcolor += sunlight * (sun_NdotL * (1.0 - (1.0 - shadowtone) * shadow));
|
fragcolor += sunlight * (sun_NdotL * (1.0 - (1.0 - shadowtone) * shadow));
|
||||||
vec3 specular = sunlight * specular_light(light_dir, fragnormal, f0, roughness, SUN_BRDF_LIMIT) * (1.0 - shadow);
|
vec3 specular = matte ? vec3(0.0) : sunlight * specular_light(light_dir, fragnormal, f0, roughness, SUN_BRDF_LIMIT) * (1.0 - shadow);
|
||||||
|
|
||||||
vec3 lampspecular = vec3(0.0);
|
vec3 lampspecular = vec3(0.0);
|
||||||
add_local_lights(fragnormal, fragcolor, lampspecular);
|
add_local_lights(fragnormal, fragcolor, lampspecular);
|
||||||
|
|||||||
@@ -37,11 +37,9 @@ void main()
|
|||||||
|
|
||||||
vec3 fragcolor = ambient;
|
vec3 fragcolor = ambient;
|
||||||
vec3 fragnormal = normalize(f_normal);
|
vec3 fragnormal = normalize(f_normal);
|
||||||
float reflectivity = param[1].z;
|
matte = true;
|
||||||
//float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5;
|
|
||||||
legacy_gloss();
|
|
||||||
|
|
||||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, 0.0, shadow_tone);
|
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, 0.0, 0.0, shadow_tone);
|
||||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||||
/*
|
/*
|
||||||
float distance = dot(f_pos.xyz, f_pos.xyz);
|
float distance = dot(f_pos.xyz, f_pos.xyz);
|
||||||
|
|||||||
Reference in New Issue
Block a user