This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Oscar De la Hera Gomez on 8/13/18. | |
// Copyright © 2018 Delasign. All rights reserved. | |
// | |
import UIKit | |
import SceneKit | |
import ARKit | |
class ViewController: UIViewController, ARSCNViewDelegate { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// | |
// Created by Oscar De la Hera Gomez on 8/13/18. | |
// Copyright © 2018 Delasign. All rights reserved. | |
import UIKit | |
import SceneKit | |
import ARKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func addFadeInMaterialToChild(child:SCNNode) { | |
let program = SCNProgram() | |
program.fragmentFunctionName = "fadeInSurfaceFragment" | |
program.vertexFunctionName = "fadeInVertexShader" | |
program.isOpaque = false; | |
// CREATE A MATERIAL, ADD THE PROGRAM, AND ADD IT TO THE CHILD. | |
let shaderMaterial = SCNMaterial() | |
shaderMaterial.program = program; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func addTextureShaderToChild(child:SCNNode) { | |
let program = SCNProgram() | |
program.fragmentFunctionName = "TextureSurfaceFragment" | |
program.vertexFunctionName = "TextureVertexShader" | |
program.isOpaque = false; | |
// CREATE A MATERIAL, ADD THE PROGRAM, AND ADD IT TO THE CHILD. | |
let shaderMaterial = SCNMaterial() | |
shaderMaterial.program = program; | |
shaderMaterial.transparencyMode = .rgbZero; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func addShaderWithTransparencyToChild(child:SCNNode) { | |
let program = SCNProgram() | |
let shaderName = "YOUR_SHADER_NAME"; | |
program.fragmentFunctionName = shaderName + "SurfaceFragment" | |
program.vertexFunctionName = shaderName + "VertexShader" | |
program.isOpaque = false; | |
// CREATE A MATERIAL, ADD THE PROGRAM, AND ADD IT TO THE CHILD. | |
let shaderMaterial = SCNMaterial() |
OlderNewer