I'am trying to rewrite this shader and i'am stuck with line:
float backColor = dot (texture (iChannel0, direction).rgb, channel);
how would i do it ? Following this tutorial i should be able to pass my cubetexture here, but i cant wrap my head around this task. Right now without this line i get some random colors over time so i assume thats part i'am missing. I'am using SceneKit with SCNProgram.
Assuming you've ported the relevant parts of the shader, loaded a cube map, and bound it as a shader argument, the equivalent line of Metal Shading Language code is simply:
float backColor = dot(texCube.sample(cubeSampler, direction).rgb, channel);
where texCube
is of type texturecube<float, access::sample>
and cubeSampler
is something like
constexpr sampler cubeSampler(coord::normalized, filter::linear, mip_filter::linear)