From 5df748eb48cff2fb60b544501da6afcdd5a8ec28 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 1 Dec 2021 18:22:58 -0800 Subject: [PATCH] metal Signed-off-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 } }