And
https://youtube.com/shorts/U51bsfvQ2FM
https://youtube.com/shorts/cFctihaemsI
In the first video, iOS 17.5.1, and occlusion works correctly, in the second video, iOS 18.0, and it does not work correctly. The app builds are identical. Here is the shader code.
#include <metal_stdlib>
#include <RealityKit/RealityKit.h>
using namespace metal;
constexpr sampler textureSampler(coord::normalized,
address::repeat,
filter::linear,
mip_filter::linear);
[[visible]]
void pngImage(realitykit::surface_parameters params) {
auto surface = params.surface();
float2 uv = params.geometry().uv0() * 8;
auto tex = params.textures();
half3 color = (half3)tex.base_color().sample(textureSampler, uv).rgb;
half opacity = tex.opacity().sample(textureSampler, uv).r;
if (color.r > 0.15 && color.g > 0.15 && color.b > 0.15) {
surface.set_emissive_color(color * 1.5);
opacity = 0.5;
} else {
opacity *= 0.0;
}
params.surface().set_opacity(opacity);
}
The same problem occurs, for example, with this shader.
[[visible]]
void strobe(realitykit::surface_parameters params) {
auto surface = params.surface();
half3 white = half3(1.0, 1.0, 1.0);
params.surface().set_base_color(white);
surface.set_base_color(white);
surface.set_emissive_color(white);
float time = params.uniforms().time();
half opacity = abs (sin (time * 2) * 0.5 + 0.5 );
surface.set_opacity(opacity);
}