Skip to content

Instantly share code, notes, and snippets.

@delasign
delasign / standard.metal
Created September 5, 2018 15:50
A standard metal shader
//
// Standard.metal
// Delasign
//
// Created by Oscar De la Hera Gomez on 9/5/18.
// Copyright © 2018 Delasign. All rights reserved.
//
#include <metal_stdlib>
using namespace metal;
@delasign
delasign / mask.metal
Created September 8, 2018 17:42
A Shader target geometries in SCNTechniques
#include <metal_stdlib>
using namespace metal;
#include <SceneKit/scn_metal>
struct custom_node_t3 {
float4x4 modelTransform;
float4x4 inverseModelTransform;
float4x4 modelViewTransform;
float4x4 inverseModelViewTransform;
float4x4 normalTransform; // Inverse transpose of modelViewTransform
@delasign
delasign / PlaneWaveForm.metal
Last active September 9, 2018 21:42
A wave form shader for a plane.
//
// PlaneWaveForm.metal
// Delasign
//
// Created by Oscar De la Hera Gomez on 9/9/18.
// Copyright © 2018 Delasign. All rights reserved.
//
#include <metal_stdlib>
using namespace metal;
@delasign
delasign / A Timed Stroke Metal Shader for ARKit iOS11.4 and iOS12
Created September 24, 2018 19:46
TimedStrokeShaderWithVariables.metal
//
// TimedStroke.metal
// Delasign
//
// Created by Oscar De la Hera Gomez on 9/21/18.
// Copyright © 2018 Delasign. All rights reserved.
//
#include <metal_stdlib>
@delasign
delasign / addStrokeShaderWithTimeForChild.swift
Created September 24, 2018 19:48
How to add a timed stroke shader to a node in ARKit iOS11.4 and iOS12
struct strokeTimeVariableStruct {
var loopTime:Float = 10;
var startTime:Float = 0;
var endTime:Float = 5;
init(loopTime:Float, startTime:Float, endTime:Float) {
self.loopTime = loopTime;
self.startTime = startTime;
self.endTime = endTime;
}
@delasign
delasign / encryptDeCrypt.swift
Last active September 30, 2018 23:19
Encrypt and Decrypt a string using CryptoSwift, iOS12 XCode 10
import CryptoSwift
let encryptionKey:String = "A_SIXTEEN_CHARACTER_STRING";
let encryptionIV:String = "A_SIXTEEN_CHARACTER_STRING";
public func encryptString() {
let test = "hi there, good sir."
let encryptedTest:String = try! test.aesEncrypt(key: encryptionKey, iv: encryptionIV)
print("Test : ", test)
print("Encrypted Test : ", encryptedTest)
@delasign
delasign / configuration.swift
Created October 16, 2018 21:39
60 FPS ARKit Image Tracking Configuration
// Created by Oscar De la Hera Gomez on 10/16/18.
// Copyright © 2018 Delasign. All rights shared.
let configuration = ARWorldTrackingConfiguration()
configuration.detectionImages = referenceImages
configuration.maximumNumberOfTrackedImages = 1;
session.run(configuration, options: [.resetTracking, .removeExistingAnchors])
@delasign
delasign / GlowTechnique.plist
Created October 19, 2018 16:15
A Glow SCNTechnique for a multi-pass shader with custom symbols.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>passes</key>
<dict>
<key>pass_red_blur_v</key>
<dict>
<key>colorStates</key>
<dict>
@delasign
delasign / GlowRender.metal
Created October 19, 2018 16:21
A Blue Glow Effect with a custom metal symbol for a SCNTechnique
#include <metal_stdlib>
using namespace metal;
#include <SceneKit/scn_metal>
#include <simd/simd.h>
struct NodeBuffer {
float4x4 modelTransform;
float4x4 modelViewTransform;
@delasign
delasign / GlowRedRender.metal
Created October 19, 2018 16:21
A Red Glow Effect with a custom metal symbol for a SCNTechnique
#include <metal_stdlib>
using namespace metal;
#include <SceneKit/scn_metal>
#include <simd/simd.h>