From 1559fe5580d59d2f70d14fbe4aaea0fbaea2e3c8 Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Wed, 26 Jan 2022 19:54:04 +0000 Subject: [PATCH 1/2] [Metal] Fix sky background in RGBD camera to match #515 (#549) Fix #515 depth_camera_fs.metal: hasBackground is a struct member and should be p.hasBackground Signed-off-by: Rhys Mainwaring --- .../src/media/materials/programs/Metal/depth_camera_fs.metal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ogre2/src/media/materials/programs/Metal/depth_camera_fs.metal b/ogre2/src/media/materials/programs/Metal/depth_camera_fs.metal index b1b3c79ac..7a87ec09c 100644 --- a/ogre2/src/media/materials/programs/Metal/depth_camera_fs.metal +++ b/ogre2/src/media/materials/programs/Metal/depth_camera_fs.metal @@ -167,7 +167,7 @@ fragment float4 main_metal // due to the scatter effect. We should still render particles in the color // image // todo(iche033) handle case when background is a cubemap - if (hasBackground == 0 && particle.x < 1e-6) + if (p.hasBackground == 0 && particle.x < 1e-6) { color = float4(p.backgroundColor, 1.0); } @@ -185,7 +185,7 @@ fragment float4 main_metal // clamp to background color only if it is not a particle pixel // todo(iche033) handle case when background is a cubemap - if (hasBackground == 0 && particle.x < 1e-6) + if (p.hasBackground == 0 && particle.x < 1e-6) { color = float4(p.backgroundColor, 1.0); } From 30f9a5e45ba0b6385e359cd8d40ab0a5977564e6 Mon Sep 17 00:00:00 2001 From: Rhys Mainwaring Date: Wed, 26 Jan 2022 21:39:53 +0000 Subject: [PATCH 2/2] [Metal] Fix per-point colors in point clouds to match #494 (#550) Signed-off-by: Ian Chen Co-authored-by: Ian Chen --- ogre2/src/media/materials/programs/GLSL/point_fs.glsl | 1 - ogre2/src/media/materials/programs/Metal/point_fs.metal | 6 +++--- ogre2/src/media/materials/programs/Metal/point_vs.metal | 6 +++++- .../src/media/materials/scripts/point_cloud_point.material | 1 - 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ogre2/src/media/materials/programs/GLSL/point_fs.glsl b/ogre2/src/media/materials/programs/GLSL/point_fs.glsl index 5c6d912d4..0489a8f1c 100644 --- a/ogre2/src/media/materials/programs/GLSL/point_fs.glsl +++ b/ogre2/src/media/materials/programs/GLSL/point_fs.glsl @@ -17,7 +17,6 @@ #version 330 -uniform vec4 color; in vec3 ptColor; out vec4 fragColor; diff --git a/ogre2/src/media/materials/programs/Metal/point_fs.metal b/ogre2/src/media/materials/programs/Metal/point_fs.metal index 4fa9088a9..346e9d2df 100644 --- a/ogre2/src/media/materials/programs/Metal/point_fs.metal +++ b/ogre2/src/media/materials/programs/Metal/point_fs.metal @@ -14,17 +14,17 @@ * limitations under the License. * */ - + #include using namespace metal; struct PS_INPUT { + float3 ptColor; }; struct Params { - float4 color; }; fragment float4 main_metal @@ -33,5 +33,5 @@ fragment float4 main_metal constant Params &p [[buffer(PARAMETER_SLOT)]] ) { - return p.color; + return float4(inPs.ptColor.x, inPs.ptColor.y, inPs.ptColor.z, 1.0); } diff --git a/ogre2/src/media/materials/programs/Metal/point_vs.metal b/ogre2/src/media/materials/programs/Metal/point_vs.metal index 192e21930..3f8636147 100644 --- a/ogre2/src/media/materials/programs/Metal/point_vs.metal +++ b/ogre2/src/media/materials/programs/Metal/point_vs.metal @@ -14,19 +14,21 @@ * limitations under the License. * */ - + #include using namespace metal; struct VS_INPUT { float4 position [[attribute(VES_POSITION)]]; + float3 normal [[attribute(VES_NORMAL)]]; }; struct PS_INPUT { float4 gl_Position [[position]]; float gl_PointSize [[point_size]]; + float3 ptColor; }; struct Params @@ -45,6 +47,8 @@ vertex PS_INPUT main_metal outVs.gl_Position = ( p.worldViewProj * input.position ).xyzw; outVs.gl_PointSize = p.size; + // We're abusing the normal variable to hold per-point colors + outVs.ptColor = input.normal; return outVs; } diff --git a/ogre2/src/media/materials/scripts/point_cloud_point.material b/ogre2/src/media/materials/scripts/point_cloud_point.material index d2d81a1e4..429968728 100644 --- a/ogre2/src/media/materials/scripts/point_cloud_point.material +++ b/ogre2/src/media/materials/scripts/point_cloud_point.material @@ -32,7 +32,6 @@ fragment_program PointCloudFS_GLSL glsl source point_fs.glsl default_params { - param_named color float4 1.0 1.0 1.0 1.0 } }