public class SCNMaterial extends NSObject implements SCNAnimatable, SCNShadable, NSCopying, NSSecureCoding
A SCNMaterial determines how a geometry is rendered. It encapsulates the colors and textures that define the appearance of 3d geometries.
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_retSCNShadable.Block_handleBindingOfSymbolUsingBlock, SCNShadable.Block_handleUnbindingOfSymbolUsingBlock| Modifier | Constructor and Description |
|---|---|
protected |
SCNMaterial(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
_supportsSecureCoding()
This property must return YES on all classes that allow secure coding.
|
static boolean |
accessInstanceVariablesDirectly() |
void |
addAnimationForKey(SCNAnimation animation,
java.lang.String key)
addAnimation:forKey:
|
void |
addAnimationPlayerForKey(SCNAnimationPlayer player,
java.lang.String key)
addAnimationPlayer:forKey:
|
static SCNMaterial |
alloc() |
static SCNMaterial |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
SCNMaterialProperty |
ambient()
[@property] ambient
|
SCNMaterialProperty |
ambientOcclusion()
[@property] ambientOcclusion
|
CAAnimation |
animationForKey(java.lang.String key)
animationForKey:
|
NSArray<java.lang.String> |
animationKeys()
[@property] animationKeys
|
SCNAnimationPlayer |
animationPlayerForKey(java.lang.String key)
animationPlayerForKey:
|
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
long |
blendMode()
[@property] blendMode
|
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument) |
static NSArray<java.lang.String> |
classFallbacksForKeyedArchiver() |
static org.moe.natj.objc.Class |
classForKeyedUnarchiver() |
SCNMaterialProperty |
clearCoat()
[@property] clearCoat
|
SCNMaterialProperty |
clearCoatNormal()
[@property] clearCoatNormal
|
SCNMaterialProperty |
clearCoatRoughness()
[@property] clearCoatRoughness
|
long |
colorBufferWriteMask()
Determines whether the receiver writes to the color buffer when rendered.
|
java.lang.Object |
copyWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
long |
cullMode()
[@property] cullMode
|
static java.lang.String |
debugDescription_static() |
static java.lang.String |
description_static() |
SCNMaterialProperty |
diffuse()
[@property] diffuse
|
SCNMaterialProperty |
displacement()
[@property] displacement
|
SCNMaterialProperty |
emission()
[@property] emission
|
void |
encodeWithCoder(NSCoder coder) |
long |
fillMode()
[@property] fillMode
|
double |
fresnelExponent()
[@property] fresnelExponent
|
void |
handleBindingOfSymbolUsingBlock(java.lang.String symbol,
SCNShadable.Block_handleBindingOfSymbolUsingBlock block)
handleBindingOfSymbol:usingBlock:
|
void |
handleUnbindingOfSymbolUsingBlock(java.lang.String symbol,
SCNShadable.Block_handleUnbindingOfSymbolUsingBlock block)
handleUnbindingOfSymbol:usingBlock:
|
static long |
hash_static() |
SCNMaterial |
init() |
SCNMaterial |
initWithCoder(NSCoder coder)
NS_DESIGNATED_INITIALIZER
|
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
boolean |
isAnimationForKeyPaused(java.lang.String key)
isAnimationForKeyPaused:
|
boolean |
isDoubleSided()
[@property] doubleSided
|
boolean |
isLitPerPixel()
[@property] litPerPixel
|
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
java.lang.String |
lightingModelName()
[@property] lightingModelName
|
boolean |
locksAmbientWithDiffuse()
[@property] locksAmbientWithDiffuse
|
static SCNMaterial |
material()
material
|
static SCNMaterial |
materialWithMDLMaterial(MDLMaterial mdlMaterial) |
SCNMaterialProperty |
metalness()
[@property] metalness
|
NSNumber |
minimumLanguageVersion()
[@property] minimumLanguageVersion
|
SCNMaterialProperty |
multiply()
[@property] multiply
|
java.lang.String |
name()
[@property] name
|
static SCNMaterial |
new_objc() |
SCNMaterialProperty |
normal()
[@property] normal
|
void |
pauseAnimationForKey(java.lang.String key)
pauseAnimationForKey:
|
SCNProgram |
program()
[@property] program
|
boolean |
readsFromDepthBuffer()
[@property] readsFromDepthBuffer
|
SCNMaterialProperty |
reflective()
[@property] reflective
|
void |
removeAllAnimations()
removeAllAnimations
|
void |
removeAllAnimationsWithBlendOutDuration(double duration)
removeAllAnimationsWithBlendOutDuration
|
void |
removeAnimationForKey(java.lang.String key)
removeAnimationForKey
|
void |
removeAnimationForKeyBlendOutDuration(java.lang.String key,
double duration)
removeAnimationForKey:blendOutDuration:
|
void |
removeAnimationForKeyFadeOutDuration(java.lang.String key,
double duration)
removeAnimationForKey:fadeOutDuration:
|
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
void |
resumeAnimationForKey(java.lang.String key)
resumeAnimationForKey:
|
SCNMaterialProperty |
roughness()
[@property] roughness
|
SCNMaterialProperty |
selfIllumination()
[@property] selfIllumination
|
void |
setBlendMode(long value)
[@property] blendMode
|
void |
setColorBufferWriteMask(long value)
Determines whether the receiver writes to the color buffer when rendered.
|
void |
setCullMode(long value)
[@property] cullMode
|
void |
setDoubleSided(boolean value)
[@property] doubleSided
|
void |
setFillMode(long value)
[@property] fillMode
|
void |
setFresnelExponent(double value)
[@property] fresnelExponent
|
void |
setLightingModelName(java.lang.String value)
[@property] lightingModelName
|
void |
setLitPerPixel(boolean value)
[@property] litPerPixel
|
void |
setLocksAmbientWithDiffuse(boolean value)
[@property] locksAmbientWithDiffuse
|
void |
setMinimumLanguageVersion(NSNumber value)
[@property] minimumLanguageVersion
|
void |
setName(java.lang.String value)
[@property] name
|
void |
setProgram(SCNProgram value)
[@property] program
|
void |
setReadsFromDepthBuffer(boolean value)
[@property] readsFromDepthBuffer
|
void |
setShaderModifiers(NSDictionary<java.lang.String,java.lang.String> value)
[@property] shaderModifiers
|
void |
setShininess(double value)
[@property] shininess
|
void |
setSpeedForAnimationKey(double speed,
java.lang.String key)
setSpeed:forAnimationKey:
|
void |
setTransparency(double value)
[@property] transparency
|
void |
setTransparencyMode(long value)
[@property] transparencyMode
|
static void |
setVersion_static(long aVersion) |
void |
setWritesToDepthBuffer(boolean value)
[@property] writeToDepthBuffer
|
NSDictionary<java.lang.String,java.lang.String> |
shaderModifiers()
[@property] shaderModifiers
|
double |
shininess()
[@property] shininess
|
SCNMaterialProperty |
specular()
[@property] specular
|
static org.moe.natj.objc.Class |
superclass_static() |
static boolean |
supportsSecureCoding() |
double |
transparency()
[@property] transparency
|
long |
transparencyMode()
[@property] transparencyMode
|
SCNMaterialProperty |
transparent()
[@property] transparent
|
static long |
version_static() |
boolean |
writesToDepthBuffer()
[@property] writeToDepthBuffer
|
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKeypublic static boolean accessInstanceVariablesDirectly()
public static SCNMaterial alloc()
public static SCNMaterial allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public static long hash_static()
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public static SCNMaterial material()
Creates and initialize a material instance.
public static SCNMaterial materialWithMDLMaterial(MDLMaterial mdlMaterial)
public static SCNMaterial new_objc()
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public static void setVersion_static(long aVersion)
public static org.moe.natj.objc.Class superclass_static()
public static boolean supportsSecureCoding()
public static long version_static()
public void addAnimationForKey(SCNAnimation animation, java.lang.String key)
SCNAnimatableAdds and runs an animation
Only SCNAnimation (preferred), CABasicAnimation, CAKeyframeAnimation and CAAnimationGroup are supported. The animation starts playing right away. The animation is automatically removed on completion unless if removedOnCompletion is explicitly set to NO.
addAnimationForKey in interface SCNAnimatableanimation - Added animation.key - May be any string such that only one animation per unique key is added per animatable object. removedOnCompletion] public SCNMaterialProperty ambient()
Specifies the receiver's ambient property.
The ambient property specifies the amount of ambient light to reflect. This property has no visual impact on scenes that have no ambient light. Setting the ambient has no effect if locksAmbientWithDiffuse is set to YES.
public SCNMaterialProperty ambientOcclusion()
The ambientOcclusion property specifies the ambient occlusion of the surface. The ambient occlusion is multiplied with the ambient light, then the result is added to the lighting contribution. This property has no visual impact on scenes that have no ambient light. When an ambient occlusion map is set, the ambient property is ignored.
public CAAnimation animationForKey(java.lang.String key)
SCNAnimatableReturns the animation with the given identifier
This will return nil if no such animation exists. Attempting to modify any properties of the returned object will result in undefined behavior.
animationForKey in interface SCNAnimatablekey - The identifier for the animation to retrieve.public NSArray<java.lang.String> animationKeys()
SCNAnimatableReturns an array containing the keys of all animations currently attached to the receiver.
animationKeys in interface SCNAnimatablepublic long blendMode()
Specifies the receiver's blend mode. Defaults to SCNBlendModeAlpha.
public java.lang.Object copyWithZone(org.moe.natj.general.ptr.VoidPtr zone)
copyWithZone in interface NSCopyingpublic long cullMode()
Determines the culling mode of the receiver. Defaults to SCNCullBack. Animatable.
public SCNMaterialProperty diffuse()
Specifies the receiver's diffuse property.
The diffuse property specifies the amount of light diffusely reflected from the surface. The diffuse light is reflected equally in all directions and is therefore independent of the point of view.
public SCNMaterialProperty emission()
The emission property specifies the amount of light the material emits. This emission does not light up other surfaces in the scene.
public void encodeWithCoder(NSCoder coder)
encodeWithCoder in interface NSCodingpublic double fresnelExponent()
Specifies the receiver's fresnel exponent value. Defaults to 0.0. Animatable.
The effect of the reflectivity property is modulated by this property. The fresnelExponent changes the exponent of the reflectance. The bigger the exponent, the more concentrated the reflection is around the edges.
public void handleBindingOfSymbolUsingBlock(java.lang.String symbol,
SCNShadable.Block_handleBindingOfSymbolUsingBlock block)
SCNShadableSets the block to call at render time to bind the value for the specified symbol of the receiver's SCNProgram. This method has no effect for symbols declared in shader modifiers.
This method can only be used with OpenGL and OpenGLES based programs.
handleBindingOfSymbolUsingBlock in interface SCNShadablesymbol - The name of the symbol to bind a value for.block - The block to call to bind the specified symbol.public void handleUnbindingOfSymbolUsingBlock(java.lang.String symbol,
SCNShadable.Block_handleUnbindingOfSymbolUsingBlock block)
SCNShadableSets the block to call at render time to unbind the value for the specified symbol of the receiver's SCNProgram. This method has no effect for symbols declared in shader modifiers.
This method can only be used with OpenGL and OpenGLES based programs.
handleUnbindingOfSymbolUsingBlock in interface SCNShadablesymbol - The name of the symbol to unbind.block - The block to call to unbind the specified symbol.public SCNMaterial init()
public SCNMaterial initWithCoder(NSCoder coder)
NSCodinginitWithCoder in interface NSCodingpublic boolean isAnimationForKeyPaused(java.lang.String key)
SCNAnimatableReturns whether the animation for the specified identifier is paused.
isAnimationForKeyPaused in interface SCNAnimatablekey - The identifier for the animation to query.public boolean isDoubleSided()
Determines whether the receiver is double sided. Defaults to NO. Animatable.
public void setDoubleSided(boolean value)
Determines whether the receiver is double sided. Defaults to NO. Animatable.
public boolean isLitPerPixel()
Determines whether the receiver is lit per pixel. Defaults to YES. Animatable.
public void setLitPerPixel(boolean value)
Determines whether the receiver is lit per pixel. Defaults to YES. Animatable.
public java.lang.String lightingModelName()
Determines the receiver's lighting model. See above for the list of lighting models. Defaults to SCNLightingModelBlinn.
public boolean locksAmbientWithDiffuse()
Makes the ambient property automatically match the diffuse property. Defaults to YES. Animatable.
public SCNMaterialProperty metalness()
The metalness property specifies how metallic the material's surface appears. Lower values (darker colors) cause the material to appear more like a dielectric surface. Higher values (brighter colors) cause the surface to appear more metallic. This property is only used when 'lightingModelName' is 'SCNLightingModelPhysicallyBased'.
public SCNMaterialProperty multiply()
The multiply property specifies a color or an image used to multiply the output fragments with. The computed fragments are multiplied with the multiply value to produce the final fragments. This property may be used for shadow maps, to fade out or tint 3d objects.
public java.lang.String name()
Determines the name of the receiver.
public SCNMaterialProperty normal()
The normal property specifies the surface orientation.
When an image is set on the normal property the material is automatically lit per pixel. Setting a color has no effect.
public void pauseAnimationForKey(java.lang.String key)
SCNAnimatablePause the animation with the given identifier.
pauseAnimationForKey in interface SCNAnimatablekey - The identifier for the animation to pause.public SCNProgram program()
SCNShadableSpecifies a custom program used to render the receiver.
When a program is set, it overrides all the rendering parameters such as material settings and shaderModifiers.
program in interface SCNShadablepublic boolean readsFromDepthBuffer()
Determines whether the receiver reads from the depth buffer when rendered. Defaults to YES.
public SCNMaterialProperty reflective()
The reflective property specifies the reflectivity of the surface. The surface will not actually reflect other objects in the scene. This property may be used as a sphere mapping to reflect a precomputed environment.
public void removeAllAnimations()
SCNAnimatableRemove all animations.
removeAllAnimations in interface SCNAnimatablepublic void removeAnimationForKey(java.lang.String key)
SCNAnimatableRemove the animation with the given identifier.
removeAnimationForKey in interface SCNAnimatablekey - The identifier for the animation to remove.public void removeAnimationForKeyFadeOutDuration(java.lang.String key,
double duration)
SCNAnimatableSmoothly remove the animation with the given identifier.
removeAnimationForKeyFadeOutDuration in interface SCNAnimatablekey - The identifier for the animation to remove.duration - The fade out duration used to remove the animation.public void resumeAnimationForKey(java.lang.String key)
SCNAnimatableResume the animation with the given identifier.
resumeAnimationForKey in interface SCNAnimatablekey - The identifier for the animation to resume.public SCNMaterialProperty roughness()
The roughness property specifies the apparent smoothness of the surface. Lower values (darker colors) cause the material to appear shiny, with well-defined specular highlights. Higher values (brighter colors) cause specular highlights to spread out and the diffuse property of the material to become more retroreflective. This property is only used when 'lightingModelName' is 'SCNLightingModelPhysicallyBased'.
public SCNMaterialProperty selfIllumination()
The selfIllumination property specifies a texture or a color that is added to the lighting contribution of the surface. When a selfIllumination is set, the emission property is ignored.
public void setBlendMode(long value)
Specifies the receiver's blend mode. Defaults to SCNBlendModeAlpha.
public void setCullMode(long value)
Determines the culling mode of the receiver. Defaults to SCNCullBack. Animatable.
public void setFresnelExponent(double value)
Specifies the receiver's fresnel exponent value. Defaults to 0.0. Animatable.
The effect of the reflectivity property is modulated by this property. The fresnelExponent changes the exponent of the reflectance. The bigger the exponent, the more concentrated the reflection is around the edges.
public void setLightingModelName(java.lang.String value)
Determines the receiver's lighting model. See above for the list of lighting models. Defaults to SCNLightingModelBlinn.
public void setLocksAmbientWithDiffuse(boolean value)
Makes the ambient property automatically match the diffuse property. Defaults to YES. Animatable.
public void setName(java.lang.String value)
Determines the name of the receiver.
public void setProgram(SCNProgram value)
SCNShadableSpecifies a custom program used to render the receiver.
When a program is set, it overrides all the rendering parameters such as material settings and shaderModifiers.
setProgram in interface SCNShadablepublic void setReadsFromDepthBuffer(boolean value)
Determines whether the receiver reads from the depth buffer when rendered. Defaults to YES.
public void setShaderModifiers(NSDictionary<java.lang.String,java.lang.String> value)
SCNShadableDictionary of shader modifiers snippets, targeting entry points. The valid keys are the entry points described in the "Shader Modifier Entry Point" constants. The values are the code snippets formatted as described below.
Shader modifiers allow you to inject shader code in the standard shaders of SceneKit. This injection is allowed in few controlled entry points, allowing specific kind of tasks in specific context. Each modifier can operate on specific structures along with access to global uniforms, that could be the standard SceneKit uniforms or its own declared uniforms.
Shader modifiers can be used to tweak SceneKit rendering by adding custom code at the following entry points: 1. vertex (SCNShaderModifierEntryPointGeometry) 2. surface (SCNShaderModifierEntryPointSurface) 3. lighting (SCNShaderModifierEntryPointLightingModel) 4. fragment (SCNShaderModifierEntryPointFragment) See below for a detailed explanation of these entry points and the context they provide.
Shader modifiers can be written in either GLSL or the Metal Shading Language. Metal shaders won't run on iOS 8 and macOS 10.10 or earlier.
The structure of a shader modifier is:
GLSL | uniform float myGrayAmount = 3.0; // Custom GLSL uniforms declarations are of the form `[uniform type uniformName [= defaultValue]]` | | // Optional global function definitions (for Metal: references to uniforms in global functions are not supported). | float mySin(float t) { | return sin(t); | } | | [#pragma transparent | opaque] | [#pragma body] | | // the shader modifier code snippet itself | vec3 myColor = myGrayAmount; | _output.color.rgb += myColor;
Metal Shading Language | #pragma arguments | float myGrayAmount; // Custom Metal uniforms declarations require a #pragma and are of the form `[type name]` | | #pragma declaration | // Optional global function definitions (for Metal: references to uniforms in global functions are not supported). | float mySin(float t) { | return sin(t); | } | | [#pragma transparent | opaque] | [#pragma body] | | // the shader modifier code snippet itself | float3 myColor = myGrayAmount; | _output.color.rgb += myColor;
The `#pragma body` directive Is only needed if you declared functions that must not be included in the shader code itself.
The `#pragma transparent` directive Forces the rendering to be blended using the following equation: _output.color.rgb + (1 - _output.color.a) * dst.rgb; where `dst` represents the current fragment color. The rgb components must be premultiplied.
The `#pragma opaque` directive Forces the rendering to be opaque. It then ignores the alpha component of the fragment.
When using Metal, you can also transfer varying values from the vertex shader (geometry shader modifier) to the fragment shader (surface and/or fragment shader modifier): 1. Start by declaring the varying values in at least one of the shader modifiers:
Metal Shading Language | #pragma varyings | half3 myVec;
2. Then write the varying values from the vertex shader (geometry shader modifier):
Metal Shading Language | #pragma body | out.myVec = _geometry.normal.xyz * 0.5h + 0.5h;
3. Finally read the varying values from the fragment shader (surface and/or fragment shader modifier):
Metal Shading Language | _output.color.rgb = saturate(in.myVec);
SceneKit declares the following built-in uniforms:
GLSL | Metal Shading Language | --------------------------------------------┼-------------------------------------------------------┤ float u_time | float scn_frame.time | The current time, in seconds vec2 u_inverseResolution | float2 scn_frame.inverseResolution | 1.0 / screen size --------------------------------------------┼-------------------------------------------------------┤ mat4 u_viewTransform | float4x4 scn_frame.viewTransform | See SCNViewTransform mat4 u_inverseViewTransform | float4x4 scn_frame.inverseViewTransform | mat4 u_projectionTransform | float4x4 scn_frame.projectionTransform | See SCNProjectionTransform mat4 u_inverseProjectionTransform | float4x4 scn_frame.inverseProjectionTransform | --------------------------------------------┼-------------------------------------------------------┤ mat4 u_normalTransform | float4x4 scn_node.normalTransform | See SCNNormalTransform mat4 u_modelTransform | float4x4 scn_node.modelTransform | See SCNModelTransform mat4 u_inverseModelTransform | float4x4 scn_node.inverseModelTransform | mat4 u_modelViewTransform | float4x4 scn_node.modelViewTransform | See SCNModelViewTransform mat4 u_inverseModelViewTransform | float4x4 scn_node.inverseModelViewTransform | mat4 u_modelViewProjectionTransform | float4x4 scn_node.modelViewProjectionTransform | See SCNModelViewProjectionTransform mat4 u_inverseModelViewProjectionTransform | float4x4 scn_node.inverseModelViewProjectionTransform | --------------------------------------------┼-------------------------------------------------------┤ mat2x3 u_boundingBox; | float2x3 scn_node.boundingBox | The bounding box of the current geometry, in model space, u_boundingBox[0].xyz and u_boundingBox[1].xyz being respectively the minimum and maximum corner of the box. mat2x3 u_worldBoundingBox; | float2x3 scn_node.worldBoundingBox | The bounding box of the current geometry, in world space.
When writing shaders using the Metal Shading Language a complete description of the type of the scn_frame variable (SCNSceneBuffer) can be found in the
In addition to these built-in uniforms, it is possible to use custom uniforms:
The SCNGeometry and SCNMaterial classes are key-value coding compliant classes, which means that you can set values for arbitrary keys. Even if the key `myAmplitude` is not a declared property of the class, you can still set a value for it.
Declaring a `myAmplitude` uniform in the shader modifier makes SceneKit observe the reveiver's `myAmplitude` key. Any change to that key will make SceneKit bind the uniform with the new value.
The following GLSL and Metal Shading Language types (and their Objective-C counterparts) can be used to declare (and bind) custom uniforms:
GLSL | Metal Shading Language | Objective-C |
------------┼------------------------┼---------------------------------------┤
int | int | NSNumber, NSInteger, int |
float | float | NSNumber, CGFloat, float, double |
vec2 | float2 | CGPoint |
vec3 | float3 | SCNVector3 |
vec4 | float4 | SCNVector4 |
mat4, mat44 | float4x4 | SCNMatrix4 |
sampler2D | texture2d | SCNMaterialProperty |
samplerCube | texturecube | SCNMaterialProperty (with a cube map) |
- | device const T* | MTLBuffer | Feature introduced in macOS 10.13, iOS 11.0 and tvOS 11.0
- | struct {...} | NSData | The entire struct can be set using NSData but it is also possible to set individual members using the member's name as a key and a value compatible with the member's type
Common scalar types wrapped into a NSValue are also supported.
The following prefixes are reserved by SceneKit and should not be used in custom names:
1. u_
2. a_
3. v_
Custom uniforms can be animated using explicit animations.
setShaderModifiers in interface SCNShadablepublic void setShininess(double value)
Specifies the receiver's shininess value. Defaults to 1.0. Animatable.
public void setSpeedForAnimationKey(double speed,
java.lang.String key)
SCNAnimatableUpdate the animation speed of the animation with the given identifier.
setSpeedForAnimationKey in interface SCNAnimatablespeed - The new speed of the animation.key - The identifier for the animation to update.public void setTransparency(double value)
Specifies the receiver's transparency value. Defaults to 1.0. Animatable.
The color of the transparent property is multiplied by this property. The result is then used to produce the final transparency according to the rule defined by the transparencyMode property.
public void setTransparencyMode(long value)
Determines the transparency mode of the receiver. See above for the transparency modes. Defaults to SCNTransparencyModeDefault.
public void setWritesToDepthBuffer(boolean value)
Determines whether the receiver writes to the depth buffer when rendered. Defaults to YES.
public NSDictionary<java.lang.String,java.lang.String> shaderModifiers()
SCNShadableDictionary of shader modifiers snippets, targeting entry points. The valid keys are the entry points described in the "Shader Modifier Entry Point" constants. The values are the code snippets formatted as described below.
Shader modifiers allow you to inject shader code in the standard shaders of SceneKit. This injection is allowed in few controlled entry points, allowing specific kind of tasks in specific context. Each modifier can operate on specific structures along with access to global uniforms, that could be the standard SceneKit uniforms or its own declared uniforms.
Shader modifiers can be used to tweak SceneKit rendering by adding custom code at the following entry points: 1. vertex (SCNShaderModifierEntryPointGeometry) 2. surface (SCNShaderModifierEntryPointSurface) 3. lighting (SCNShaderModifierEntryPointLightingModel) 4. fragment (SCNShaderModifierEntryPointFragment) See below for a detailed explanation of these entry points and the context they provide.
Shader modifiers can be written in either GLSL or the Metal Shading Language. Metal shaders won't run on iOS 8 and macOS 10.10 or earlier.
The structure of a shader modifier is:
GLSL | uniform float myGrayAmount = 3.0; // Custom GLSL uniforms declarations are of the form `[uniform type uniformName [= defaultValue]]` | | // Optional global function definitions (for Metal: references to uniforms in global functions are not supported). | float mySin(float t) { | return sin(t); | } | | [#pragma transparent | opaque] | [#pragma body] | | // the shader modifier code snippet itself | vec3 myColor = myGrayAmount; | _output.color.rgb += myColor;
Metal Shading Language | #pragma arguments | float myGrayAmount; // Custom Metal uniforms declarations require a #pragma and are of the form `[type name]` | | #pragma declaration | // Optional global function definitions (for Metal: references to uniforms in global functions are not supported). | float mySin(float t) { | return sin(t); | } | | [#pragma transparent | opaque] | [#pragma body] | | // the shader modifier code snippet itself | float3 myColor = myGrayAmount; | _output.color.rgb += myColor;
The `#pragma body` directive Is only needed if you declared functions that must not be included in the shader code itself.
The `#pragma transparent` directive Forces the rendering to be blended using the following equation: _output.color.rgb + (1 - _output.color.a) * dst.rgb; where `dst` represents the current fragment color. The rgb components must be premultiplied.
The `#pragma opaque` directive Forces the rendering to be opaque. It then ignores the alpha component of the fragment.
When using Metal, you can also transfer varying values from the vertex shader (geometry shader modifier) to the fragment shader (surface and/or fragment shader modifier): 1. Start by declaring the varying values in at least one of the shader modifiers:
Metal Shading Language | #pragma varyings | half3 myVec;
2. Then write the varying values from the vertex shader (geometry shader modifier):
Metal Shading Language | #pragma body | out.myVec = _geometry.normal.xyz * 0.5h + 0.5h;
3. Finally read the varying values from the fragment shader (surface and/or fragment shader modifier):
Metal Shading Language | _output.color.rgb = saturate(in.myVec);
SceneKit declares the following built-in uniforms:
GLSL | Metal Shading Language | --------------------------------------------┼-------------------------------------------------------┤ float u_time | float scn_frame.time | The current time, in seconds vec2 u_inverseResolution | float2 scn_frame.inverseResolution | 1.0 / screen size --------------------------------------------┼-------------------------------------------------------┤ mat4 u_viewTransform | float4x4 scn_frame.viewTransform | See SCNViewTransform mat4 u_inverseViewTransform | float4x4 scn_frame.inverseViewTransform | mat4 u_projectionTransform | float4x4 scn_frame.projectionTransform | See SCNProjectionTransform mat4 u_inverseProjectionTransform | float4x4 scn_frame.inverseProjectionTransform | --------------------------------------------┼-------------------------------------------------------┤ mat4 u_normalTransform | float4x4 scn_node.normalTransform | See SCNNormalTransform mat4 u_modelTransform | float4x4 scn_node.modelTransform | See SCNModelTransform mat4 u_inverseModelTransform | float4x4 scn_node.inverseModelTransform | mat4 u_modelViewTransform | float4x4 scn_node.modelViewTransform | See SCNModelViewTransform mat4 u_inverseModelViewTransform | float4x4 scn_node.inverseModelViewTransform | mat4 u_modelViewProjectionTransform | float4x4 scn_node.modelViewProjectionTransform | See SCNModelViewProjectionTransform mat4 u_inverseModelViewProjectionTransform | float4x4 scn_node.inverseModelViewProjectionTransform | --------------------------------------------┼-------------------------------------------------------┤ mat2x3 u_boundingBox; | float2x3 scn_node.boundingBox | The bounding box of the current geometry, in model space, u_boundingBox[0].xyz and u_boundingBox[1].xyz being respectively the minimum and maximum corner of the box. mat2x3 u_worldBoundingBox; | float2x3 scn_node.worldBoundingBox | The bounding box of the current geometry, in world space.
When writing shaders using the Metal Shading Language a complete description of the type of the scn_frame variable (SCNSceneBuffer) can be found in the
In addition to these built-in uniforms, it is possible to use custom uniforms:
The SCNGeometry and SCNMaterial classes are key-value coding compliant classes, which means that you can set values for arbitrary keys. Even if the key `myAmplitude` is not a declared property of the class, you can still set a value for it.
Declaring a `myAmplitude` uniform in the shader modifier makes SceneKit observe the reveiver's `myAmplitude` key. Any change to that key will make SceneKit bind the uniform with the new value.
The following GLSL and Metal Shading Language types (and their Objective-C counterparts) can be used to declare (and bind) custom uniforms:
GLSL | Metal Shading Language | Objective-C |
------------┼------------------------┼---------------------------------------┤
int | int | NSNumber, NSInteger, int |
float | float | NSNumber, CGFloat, float, double |
vec2 | float2 | CGPoint |
vec3 | float3 | SCNVector3 |
vec4 | float4 | SCNVector4 |
mat4, mat44 | float4x4 | SCNMatrix4 |
sampler2D | texture2d | SCNMaterialProperty |
samplerCube | texturecube | SCNMaterialProperty (with a cube map) |
- | device const T* | MTLBuffer | Feature introduced in macOS 10.13, iOS 11.0 and tvOS 11.0
- | struct {...} | NSData | The entire struct can be set using NSData but it is also possible to set individual members using the member's name as a key and a value compatible with the member's type
Common scalar types wrapped into a NSValue are also supported.
The following prefixes are reserved by SceneKit and should not be used in custom names:
1. u_
2. a_
3. v_
Custom uniforms can be animated using explicit animations.
shaderModifiers in interface SCNShadablepublic double shininess()
Specifies the receiver's shininess value. Defaults to 1.0. Animatable.
public SCNMaterialProperty specular()
Specifies the receiver's specular property.
The specular property specifies the amount of light to reflect in a mirror-like manner. The specular intensity increases when the point of view lines up with the direction of the reflected light.
public boolean _supportsSecureCoding()
NSSecureCoding_supportsSecureCoding in interface NSSecureCodingpublic double transparency()
Specifies the receiver's transparency value. Defaults to 1.0. Animatable.
The color of the transparent property is multiplied by this property. The result is then used to produce the final transparency according to the rule defined by the transparencyMode property.
public long transparencyMode()
Determines the transparency mode of the receiver. See above for the transparency modes. Defaults to SCNTransparencyModeDefault.
public SCNMaterialProperty transparent()
The transparent property specifies the transparent areas of the material.
public boolean writesToDepthBuffer()
Determines whether the receiver writes to the depth buffer when rendered. Defaults to YES.
public void addAnimationPlayerForKey(SCNAnimationPlayer player, java.lang.String key)
SCNAnimatableAdd an animation player.
The animation player is not removed automatically on completion. The animation doesn't start playing immediatelly. Call "play" on the player to start playing it.
addAnimationPlayerForKey in interface SCNAnimatableplayer - Added animation player.key - May be any string such that only one animation per unique key is added per animatable object.play]public SCNAnimationPlayer animationPlayerForKey(java.lang.String key)
SCNAnimatableReturns the animation player with the given identifier
This will return nil if no such animation player exists.
animationPlayerForKey in interface SCNAnimatablekey - The identifier for the animation player to retrieve.public long colorBufferWriteMask()
public SCNMaterialProperty displacement()
The displacement property specifies how vertex are translated in tangent space.
Pass a grayscale image for a simple 'elevation' or rgb image for a vector displacement.
public long fillMode()
Determines of to how to rasterize the receiver's primitives. Defaults to SCNFillModeFill.
public void removeAnimationForKeyBlendOutDuration(java.lang.String key,
double duration)
SCNAnimatableSmoothly remove the animation with the given identifier.
removeAnimationForKeyBlendOutDuration in interface SCNAnimatablekey - The identifier for the animation to remove.duration - The blend out duration used to remove the animation.public void setColorBufferWriteMask(long value)
public void setFillMode(long value)
Determines of to how to rasterize the receiver's primitives. Defaults to SCNFillModeFill.
public SCNMaterialProperty clearCoat()
The clearCoat property specifies color and intensity of the coat layer.
public SCNMaterialProperty clearCoatNormal()
The clearCoatNormal property specifies color and intensity of the optional coat normal map.
public SCNMaterialProperty clearCoatRoughness()
The clearCoat property specifies color and intensity of the coat roughness.
public NSNumber minimumLanguageVersion()
SCNShadableThe minimum language version required to interpret the shadable source code (wrapped MTLLanguageVersion). Defaults to nil.
By default SceneKit does not use the most recent language version in order to reduce compilation times. If set to nil the shadable source code is assumed to compile with any language version greater than or equal to Metal 2.0.
minimumLanguageVersion in interface SCNShadablepublic void removeAllAnimationsWithBlendOutDuration(double duration)
SCNAnimatableSmoothly remove all animations.
removeAllAnimationsWithBlendOutDuration in interface SCNAnimatableduration - The blend out duration used to remove the animation.public void setMinimumLanguageVersion(NSNumber value)
SCNShadableThe minimum language version required to interpret the shadable source code (wrapped MTLLanguageVersion). Defaults to nil.
By default SceneKit does not use the most recent language version in order to reduce compilation times. If set to nil the shadable source code is assumed to compile with any language version greater than or equal to Metal 2.0.
setMinimumLanguageVersion in interface SCNShadable