Skip to content

Commit

Permalink
[Metal] Fix per-point colors in point clouds to match gazebosim#494
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
  • Loading branch information
iche033 authored and srmainwaring committed Jan 26, 2022
1 parent 0310d26 commit 51631bc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion ogre2/src/media/materials/programs/GLSL/point_fs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#version 330

uniform vec4 color;
in vec3 ptColor;

out vec4 fragColor;
Expand Down
6 changes: 3 additions & 3 deletions ogre2/src/media/materials/programs/Metal/point_fs.metal
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
* limitations under the License.
*
*/

#include <metal_stdlib>
using namespace metal;

struct PS_INPUT
{
float3 ptColor;
};

struct Params
{
float4 color;
};

fragment float4 main_metal
Expand All @@ -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);
}
6 changes: 5 additions & 1 deletion ogre2/src/media/materials/programs/Metal/point_vs.metal
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@
* limitations under the License.
*
*/

#include <metal_stdlib>
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
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 51631bc

Please sign in to comment.