// Triplanar mapping sampler
fn TriSampler(tex: texture_2d<f32>, tex_sampler: sampler, position: vec3<f32>, normal: vec3<f32>, sharpness: f32) -> vec3<f32> {
  let uv_x = position.yz;
  let uv_y = position.xz;
  let uv_z = position.xy;
  let tri_mask: vec3<f32> = normalize(pow(abs(normal), vec3<f32>(sharpness)));
  let sample_x = textureSample(tex, tex_sampler, uv_x).rgb;
  let sample_y = textureSample(tex, tex_sampler, uv_y).rgb;
  let sample_z = textureSample(tex, tex_sampler, uv_z).rgb;

  return (sample_x * tri_mask.x) + (sample_y * tri_mask.y) + (sample_z * tri_mask.z);
}