From e9a3dc265bdc8c12921ba4dc18e571b5228d93ff Mon Sep 17 00:00:00 2001 From: Tomas Lorente Date: Fri, 21 May 2021 14:56:49 -0300 Subject: [PATCH 1/6] changed calculation for depht Signed-off-by: Tomas Lorente --- ogre2/src/media/materials/programs/depth_camera_fs.glsl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ogre2/src/media/materials/programs/depth_camera_fs.glsl b/ogre2/src/media/materials/programs/depth_camera_fs.glsl index dd9a894ca..5764f8a55 100644 --- a/ogre2/src/media/materials/programs/depth_camera_fs.glsl +++ b/ogre2/src/media/materials/programs/depth_camera_fs.glsl @@ -139,7 +139,8 @@ void main() } // clamp xyz and set rgb to background color - if (point.x > far - tolerance) + if (point.x * point.x + point.y * point.y > + (far - tolerance) * (far - tolerance)) { if (isinf(max)) { @@ -158,7 +159,8 @@ void main() color = vec4(backgroundColor, 1.0); } } - else if (point.x < near + tolerance) + else if (point.x * point.x + point.y * point.y < + (near + tolerance) * (near + tolerance)) { if (isinf(min)) { From 9bfe9d13e93237a90b9a3607ca1d7538f890bcf7 Mon Sep 17 00:00:00 2001 From: Tomas Lorente Date: Wed, 16 Jun 2021 15:26:35 -0300 Subject: [PATCH 2/6] Ian comments Signed-off-by: Tomas Lorente --- ogre2/src/media/materials/programs/depth_camera_fs.glsl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ogre2/src/media/materials/programs/depth_camera_fs.glsl b/ogre2/src/media/materials/programs/depth_camera_fs.glsl index 5764f8a55..cf46bc779 100644 --- a/ogre2/src/media/materials/programs/depth_camera_fs.glsl +++ b/ogre2/src/media/materials/programs/depth_camera_fs.glsl @@ -139,8 +139,7 @@ void main() } // clamp xyz and set rgb to background color - if (point.x * point.x + point.y * point.y > - (far - tolerance) * (far - tolerance)) + if (length(point) > far - tolerance) { if (isinf(max)) { @@ -159,8 +158,7 @@ void main() color = vec4(backgroundColor, 1.0); } } - else if (point.x * point.x + point.y * point.y < - (near + tolerance) * (near + tolerance)) + else if (length(point) < near + tolerance) { if (isinf(min)) { From 87267f85438c550fb97c43295fc989358cec2f11 Mon Sep 17 00:00:00 2001 From: Tomas Lorente Date: Wed, 7 Jul 2021 11:06:12 -0300 Subject: [PATCH 3/6] test fix Signed-off-by: Tomas Lorente --- ogre2/src/media/materials/programs/depth_camera_final_fs.glsl | 2 +- ogre2/src/media/materials/programs/depth_camera_fs.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl b/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl index ef5eec270..615a2b322 100644 --- a/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl +++ b/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl @@ -50,7 +50,7 @@ void main() // to be outside of min/max range // clamp xyz - if (point.x > far - tolerance) + if (length(point) > far - tolerance) { if (isinf(max)) { diff --git a/ogre2/src/media/materials/programs/depth_camera_fs.glsl b/ogre2/src/media/materials/programs/depth_camera_fs.glsl index cf46bc779..6163b43c3 100644 --- a/ogre2/src/media/materials/programs/depth_camera_fs.glsl +++ b/ogre2/src/media/materials/programs/depth_camera_fs.glsl @@ -158,7 +158,7 @@ void main() color = vec4(backgroundColor, 1.0); } } - else if (length(point) < near + tolerance) + else if (point.x < near + tolerance) { if (isinf(min)) { From 79810846d7fad3e2e52298186a8cb9de3ca191cf Mon Sep 17 00:00:00 2001 From: Tomas Lorente Date: Wed, 7 Jul 2021 12:06:29 -0300 Subject: [PATCH 4/6] fix test Signed-off-by: Tomas Lorente --- ogre2/src/media/materials/programs/depth_camera_final_fs.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl b/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl index 615a2b322..ef5eec270 100644 --- a/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl +++ b/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl @@ -50,7 +50,7 @@ void main() // to be outside of min/max range // clamp xyz - if (length(point) > far - tolerance) + if (point.x > far - tolerance) { if (isinf(max)) { From 34267e45b831e7a3e41997629d6bda2f3f54e0c3 Mon Sep 17 00:00:00 2001 From: Tomas Lorente Date: Mon, 2 Aug 2021 16:23:39 -0300 Subject: [PATCH 5/6] updated tests and migration Signed-off-by: Tomas Lorente --- Migration.md | 4 ++++ ogre2/src/media/materials/programs/depth_camera_final_fs.glsl | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Migration.md b/Migration.md index c02192894..4e4f77ef1 100644 --- a/Migration.md +++ b/Migration.md @@ -37,6 +37,10 @@ release will remove the deprecated code. `Node::UserData` now returns no data for keys that don't exist (prior to Rendering 6.x, if `Visual::UserData` was called with a key that doesn't exist, an `int` was returned by default). +1. **depth_camera_fs.glsl** and **depth_camera_final_fs.glsl** + + `Far clipping` changed from using just depth to clip to using length + to focal point to clip. + ## Ignition Rendering 4.0 to 4.1 ## ABI break diff --git a/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl b/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl index ef5eec270..fd5ad7db2 100644 --- a/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl +++ b/ogre2/src/media/materials/programs/depth_camera_final_fs.glsl @@ -50,7 +50,7 @@ void main() // to be outside of min/max range // clamp xyz - if (point.x > far - tolerance) + if (!isinf(point.x) && length(point) > far - tolerance) { if (isinf(max)) { From 9675ef6eebe9d26513994d21e3a824990725f344 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 2 Aug 2021 15:10:09 -0700 Subject: [PATCH 6/6] tweak to migration guide Signed-off-by: Ian Chen --- Migration.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Migration.md b/Migration.md index 4e4f77ef1..d65899954 100644 --- a/Migration.md +++ b/Migration.md @@ -38,8 +38,7 @@ release will remove the deprecated code. `Visual::UserData` was called with a key that doesn't exist, an `int` was returned by default). 1. **depth_camera_fs.glsl** and **depth_camera_final_fs.glsl** - + `Far clipping` changed from using just depth to clip to using length - to focal point to clip. + + Far clipping changed from clipping by depth to clipping by range, i.e. distance to point, so that the data generated will never exceed the specified max range of the camera. ## Ignition Rendering 4.0 to 4.1