pub unsafe static SCNShaderModifierEntryPointGeometry: &'static SCNShaderModifierEntryPointSCNShadable only.Expand description
This is the entry point to operate on the geometry vertices, for example deforming them.
It operates entirely in the vertex shader stage. It’s input is the geometry structure:
Structures available from the SCNShaderModifierEntryPointGeometry entry point:
| struct SCNShaderGeometry { | float4 position; | float3 normal; | float4 tangent; | float4 color; | float2 texcoords[kSCNTexcoordCount]; | } _geometry; | | Access: ReadWrite | Stages: Vertex shader only
kSCNTexcoordCount is a constant integer set to the number of texture coordinates used.
All the geometric fields (position, normal and tangent) are in model space. You can use one of the provided automatic uniforms such as u_modelTransform or u_modelViewTransform if you want to operate in another space (but the results must stay in the model space, otherwise remaining computations won’t be correct). The texture coordinates are the raw values found in the mesh, they have not been transformed yet by their optional contentsTransform. The contentsTransform if any is applied after the geometry shader modifier.
Example: Simple sinusoidal deformation
GLSL | uniform float Amplitude = 0.1; | | _geometry.position.xyz += _geometry.normal * (Amplitude * _geometry.position.y * _geometry.position.x) * sin(u_time);
Metal Shading Language | #pragma arguments | float Amplitude; | | _geometry.position.xyz += _geometry.normal * (Amplitude * _geometry.position.y * _geometry.position.x) * sin(scn_frame.time);
See also Apple’s documentation