Skip to content

Instantly share code, notes, and snippets.

@arthurschiller
arthurschiller / SceneKit Triplanar Mapping – Surface Shader Modifier
Created October 1, 2022 13:05
A simple SceneKit shader modifier snippet for triplanar texture mapping
// Be sure to to set the WrapS and WrapT properties of your texture to .repeat
float4 worldPos = scn_frame.inverseViewTransform * float4(_surface.position, 1.0);
float4 worldNormal = scn_frame.inverseViewTransform * float4(_surface.normal, 0.0);
float3 blending = abs(worldNormal).xyz;
blending = normalize(max(blending, 0.00001)); // Force weights to sum to 1.0
float b = (blending.x + blending.y + blending.z);
blending /= float3(b, b, b);
float scale = 2.0;
@arthurschiller
arthurschiller / ARSession+GeoTracking.swift
Created October 1, 2022 09:47
Utilities to query ARKit GeoTracking support
//
// ARSession+GeoTracking.swift
// ARExperienceKit
//
// Created by Arthur Schiller on 22.04.20.
//
import ARKit
import CoreLocation