Skip to content

Latest commit

 

History

History
36 lines (22 loc) · 1.9 KB

README.md

File metadata and controls

36 lines (22 loc) · 1.9 KB

SceneKit — OpenGL Shaders

This is a project demo to test adding shader fragments to models rendered in SceneKit, using the shaderModifiers attribute in the SCNShadable protocol. It's a small and digestable, a good starting point for adding new shader fragments or copying setup / shader bits into another project.

Some of the shaders are taken/modified from the WWDC 2014 SceneKit Slides. A couple have been slightly modified to work on iOS (uniform values were disallowed in the iOS version to my knowledge).

This was the final project for the Computer Graphics class at Southern Adventist University. The original class presentation slides are a good introduction to SceneKit and shaderModifiers, aimed at intermediate level graphics / OpenGL students.

GL Shaders ScreenShot

Extending the demo

Simply include more models and shaders by including in the project and modifying the Settings.swift file with another appropriate settings object.

Model

Provide a new ModelSettingItem in the ModelSettings array with either a SceneKit node or grab a node from an included .dae file.

// SceneKit node (using class function to generate)
ModelSettingItem(modelData: ModelData(name: "Cube", node: AllSettings.cubeNode()))

// Grab a node in a .dae file from art.scnassets
ModelSettingItem(modelData: ModelData(filename: "ship", nodeName: "shipMesh"))

Shaders

Add a shader fragment with extension .shader and include it in the appropriate shader settings array.

// Include sm_geom.shader file and make setting object for it
ShaderSettingItem(shaderData: ShaderData(filename: "sm_geom"))