From b7ee51167f96a5813401e9158d7783518ac0a93c Mon Sep 17 00:00:00 2001 From: yvt Date: Mon, 8 Feb 2021 23:07:19 +0900 Subject: [PATCH] fix(draw): avoid zero division --- Resources/Shaders/Shadow/MapRadiosity.fs | 2 +- Resources/Shaders/Shadow/MapRadiosityLow.fs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/Shaders/Shadow/MapRadiosity.fs b/Resources/Shaders/Shadow/MapRadiosity.fs index 5745682b..5951d584 100644 --- a/Resources/Shaders/Shadow/MapRadiosity.fs +++ b/Resources/Shaders/Shadow/MapRadiosity.fs @@ -59,7 +59,7 @@ vec3 Radiosity_Map(float detailAmbientOcclusion, float ssao) { // ambient occlusion vec2 ambTexVal = texture3D(ambientShadowTexture, ambientShadowTextureCoord).xy; - float amb = ambTexVal.x / ambTexVal.y; + float amb = ambTexVal.x / (ambTexVal.y + 1.0e-12); amb = max(amb, 0.); // for some reason, mainTexture value becomes negative // mix ambient occlusion values generated by two different methods somehow diff --git a/Resources/Shaders/Shadow/MapRadiosityLow.fs b/Resources/Shaders/Shadow/MapRadiosityLow.fs index 5482b4f4..05e0a85f 100644 --- a/Resources/Shaders/Shadow/MapRadiosityLow.fs +++ b/Resources/Shaders/Shadow/MapRadiosityLow.fs @@ -60,7 +60,7 @@ vec3 Radiosity_Map(float detailAmbientOcclusion, float ssao) { // ambient occlusion vec2 ambTexVal = texture3D(ambientShadowTexture, ambientShadowTextureCoord).xy; - float amb = ambTexVal.x / ambTexVal.y; + float amb = ambTexVal.x / (ambTexVal.y + 1.0e-12); amb = max(amb, 0.); // by some reason, mainTexture value becomes negative // mix ambient occlusion values generated by two different methods somehow