vertex shader: per vertex, transform geometry
fragment shader: per pixel, light/color/fx(e.g. blur) + vision/image processing
SceneKit: abstractions for 3D graphics, control vertex function and fragment function only
Metal: working with GPU, complete control of rendering graphics
SCNGeometry().shaderModifiers = [.fragment:
"""
float2 st = _surface.diffuseTextcoord.xy;
// transform using normal math operations like max, abs, ...
// use step() to binarize the colors
_surface.diffuse = mix(
float4(1), float4(0), // white and black
percentage // how much to blend together
)
"""
]
SCNProgram + Metal Shader
Use SCNTechnique instead for multi pass, such as ray tracing
let program = SCNProgram()
program.vertexFunctionName = "<#vertex shader name#>"
program.fragmentFunctionName = "<#fragment shader name#>"
let material = SCNMaterial()
material.program = program
SCNGeometry().materials = [material]
Presenter: author of "Metal Programming Guide"
Overview
vertex shader: per vertex, transform geometry fragment shader: per pixel, light/color/fx(e.g. blur) + vision/image processing
SceneKit: abstractions for 3D graphics, control vertex function and fragment function only Metal: working with GPU, complete control of rendering graphics![image](https://user-images.githubusercontent.com/10842684/57187619-c6862600-6ebf-11e9-90f7-0a900eff1ed5.png)
Simple Metal Shader by "injection"
Injection cont. for changing textures
They use a different coordinate system:
SCNProgram + Metal Shader