|
@@ -885,7 +885,7 @@ void reflection_process(uint ref_index, vec3 vertex, vec3 ref_vec, vec3 normal,
|
|
blend = pow(blend_axes.x * blend_axes.y * blend_axes.z, 2.0);
|
|
blend = pow(blend_axes.x * blend_axes.y * blend_axes.z, 2.0);
|
|
}
|
|
}
|
|
|
|
|
|
- if (reflections.data[ref_index].intensity > 0.0) { // compute reflection
|
|
|
|
|
|
+ if (reflections.data[ref_index].intensity > 0.0 && reflection_accum.a < 1.0) { // compute reflection
|
|
|
|
|
|
vec3 local_ref_vec = (reflections.data[ref_index].local_matrix * vec4(ref_vec, 0.0)).xyz;
|
|
vec3 local_ref_vec = (reflections.data[ref_index].local_matrix * vec4(ref_vec, 0.0)).xyz;
|
|
|
|
|
|
@@ -903,47 +903,43 @@ void reflection_process(uint ref_index, vec3 vertex, vec3 ref_vec, vec3 normal,
|
|
}
|
|
}
|
|
|
|
|
|
vec4 reflection;
|
|
vec4 reflection;
|
|
|
|
+ float reflection_blend = max(0.0, blend - reflection_accum.a);
|
|
|
|
|
|
reflection.rgb = textureLod(samplerCubeArray(reflection_atlas, DEFAULT_SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP), vec4(local_ref_vec, reflections.data[ref_index].index), sqrt(roughness) * MAX_ROUGHNESS_LOD).rgb * sc_luminance_multiplier();
|
|
reflection.rgb = textureLod(samplerCubeArray(reflection_atlas, DEFAULT_SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP), vec4(local_ref_vec, reflections.data[ref_index].index), sqrt(roughness) * MAX_ROUGHNESS_LOD).rgb * sc_luminance_multiplier();
|
|
reflection.rgb *= reflections.data[ref_index].exposure_normalization;
|
|
reflection.rgb *= reflections.data[ref_index].exposure_normalization;
|
|
- if (reflections.data[ref_index].exterior) {
|
|
|
|
- reflection.rgb = mix(specular_light, reflection.rgb, blend);
|
|
|
|
- }
|
|
|
|
|
|
+ reflection.a = reflection_blend;
|
|
|
|
|
|
- reflection.rgb *= reflections.data[ref_index].intensity; //intensity
|
|
|
|
- reflection.a = blend;
|
|
|
|
|
|
+ reflection.rgb *= reflections.data[ref_index].intensity;
|
|
reflection.rgb *= reflection.a;
|
|
reflection.rgb *= reflection.a;
|
|
|
|
|
|
reflection_accum += reflection;
|
|
reflection_accum += reflection;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (ambient_accum.a >= 1.0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
switch (reflections.data[ref_index].ambient_mode) {
|
|
switch (reflections.data[ref_index].ambient_mode) {
|
|
case REFLECTION_AMBIENT_DISABLED: {
|
|
case REFLECTION_AMBIENT_DISABLED: {
|
|
//do nothing
|
|
//do nothing
|
|
} break;
|
|
} break;
|
|
case REFLECTION_AMBIENT_ENVIRONMENT: {
|
|
case REFLECTION_AMBIENT_ENVIRONMENT: {
|
|
- //do nothing
|
|
|
|
vec3 local_amb_vec = (reflections.data[ref_index].local_matrix * vec4(normal, 0.0)).xyz;
|
|
vec3 local_amb_vec = (reflections.data[ref_index].local_matrix * vec4(normal, 0.0)).xyz;
|
|
-
|
|
|
|
vec4 ambient_out;
|
|
vec4 ambient_out;
|
|
|
|
+ float ambient_blend = max(0.0, blend - ambient_accum.a);
|
|
|
|
|
|
ambient_out.rgb = textureLod(samplerCubeArray(reflection_atlas, DEFAULT_SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP), vec4(local_amb_vec, reflections.data[ref_index].index), MAX_ROUGHNESS_LOD).rgb;
|
|
ambient_out.rgb = textureLod(samplerCubeArray(reflection_atlas, DEFAULT_SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP), vec4(local_amb_vec, reflections.data[ref_index].index), MAX_ROUGHNESS_LOD).rgb;
|
|
ambient_out.rgb *= reflections.data[ref_index].exposure_normalization;
|
|
ambient_out.rgb *= reflections.data[ref_index].exposure_normalization;
|
|
- ambient_out.a = blend;
|
|
|
|
- if (reflections.data[ref_index].exterior) {
|
|
|
|
- ambient_out.rgb = mix(ambient_light, ambient_out.rgb, blend);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ ambient_out.a = ambient_blend;
|
|
ambient_out.rgb *= ambient_out.a;
|
|
ambient_out.rgb *= ambient_out.a;
|
|
ambient_accum += ambient_out;
|
|
ambient_accum += ambient_out;
|
|
} break;
|
|
} break;
|
|
case REFLECTION_AMBIENT_COLOR: {
|
|
case REFLECTION_AMBIENT_COLOR: {
|
|
vec4 ambient_out;
|
|
vec4 ambient_out;
|
|
- ambient_out.a = blend;
|
|
|
|
|
|
+ float ambient_blend = max(0.0, blend - ambient_accum.a);
|
|
|
|
+
|
|
ambient_out.rgb = reflections.data[ref_index].ambient;
|
|
ambient_out.rgb = reflections.data[ref_index].ambient;
|
|
- if (reflections.data[ref_index].exterior) {
|
|
|
|
- ambient_out.rgb = mix(ambient_light, ambient_out.rgb, blend);
|
|
|
|
- }
|
|
|
|
|
|
+ ambient_out.a = ambient_blend;
|
|
ambient_out.rgb *= ambient_out.a;
|
|
ambient_out.rgb *= ambient_out.a;
|
|
ambient_accum += ambient_out;
|
|
ambient_accum += ambient_out;
|
|
} break;
|
|
} break;
|