Skip to content

Commit

Permalink
[Metal] update depth camera and selection buffer shaders to match #446 (
Browse files Browse the repository at this point in the history
#498)

- Add new param colorTexResolution to the selection buffer shader
- Implement the Metal equivalent of texelFetch in the shaders

Signed-off-by: Rhys Mainwaring <[email protected]>
  • Loading branch information
srmainwaring authored Dec 1, 2021
1 parent 0127d13 commit ae292a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ fragment float4 main_metal
// values close to 0 get rounded to 0)
//
// See https://github.com/ignitionrobotics/ign-rendering/issues/332
// float4 p = texelFetch(inputTexture, int2(inPs.uv0 * params.texResolution.xy), 0);
// TODO - establish Metal equivalent - use standard sampler as interim approx.
float4 p = inputTexture.sample(inputSampler, inPs.uv0);
// Either: Metal equivalent of texelFetch
float4 p = inputTexture.read(uint2(inPs.uv0 * params.texResolution.xy), 0);
// Or: Use standard sampler
// float4 p = inputTexture.sample(inputSampler, inPs.uv0);

float3 point = p.xyz;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct Params
float2 projectionParams;
float far;
float inf;
float4 colorTexResolution;
};

float packFloat(float4 color)
Expand Down Expand Up @@ -66,7 +67,11 @@ fragment float4 main_metal
point = float3(p.inf);

// color
float4 color = colorTexture.sample(colorSampler, inPs.uv0);
// Either: Metal equivalent of texelFetch
float4 color = colorTexture.read(
uint2(inPs.uv0 * p.colorTexResolution.xy), 0);
// Or: Use standard sampler
// float4 color = colorTexture.sample(colorSampler, inPs.uv0);

float rgba = packFloat(color);

Expand Down

0 comments on commit ae292a8

Please sign in to comment.