Materialpropertyblock



An abstract primitive component to animate and visualize a clipping primitive that can beused to drive per pixel based clipping.

Inheritance

When a MaterialPropertyBlock can not be used and a material must be instanced, MaterialInstance can be used as follows: public class MyBehaviour: MonoBehaviour // Assigned via the inspector. Public Renderer targetRenderer; private void OnEnable Material material = targetRenderer.EnsureComponent.Material; material. Feb 10, 2017 Since there's no good reason to create MaterialPropertyBlock each frame, simply cache single instance. Other possible implementations are: (1) Implement cache as property (2) Create MaterialPropertyBlock at ResetResources Reason of avoiding (1) is consistency. Material property blocks (MPBs) allow us a way around that which we can use to change properties on a per object basis without Important to mention here is that if you’re using one of Unity’s new scriptable render pipelines the performance slowdown might be way less and you can even make the performance worse by using property blocks.

ClippingPrimitive
Implements
Namespace: Microsoft.MixedReality.Toolkit.Utilities
Assembly: cs.temp.dll.dll
Syntax

Fields

clippingSide

Declaration
Field Value
TypeDescription
ClippingPrimitive.Side

materialPropertyBlock

Declaration
Field Value
TypeDescription
MaterialPropertyBlock

renderers

Declaration
Field Value
TypeDescription
List<Renderer>

Properties

ClippingSide

The renderer(s) that should be affected by the primitive.

Declaration
Property Value
TypeDescription
ClippingPrimitive.Side

ClippingSideProperty

Declaration
Property Value
TypeDescription
String

IsDirty

Keeping track of any field, property or transformation changes to optimize material property block setting.

Declaration
Property Value
TypeDescription
Boolean

Keyword

Materialpropertyblock Urp

Declaration
Property Value
TypeDescription
String

UseOnPreRender

Toggles whether the primitive will use the Camera OnPreRender event.

Declaration
Property Value
TypeDescription
Boolean
Remarks

This is especially helpful if you're trying to clip dynamically created objects that may be added to the scene after LateUpdate such as OnWillRender

Materialpropertyblock

Material Property Block Unity

Methods

AddRenderer(Renderer)

Adds a renderer to the list of objects this clipping primitive clips.

Declaration
Parameters
TypeNameDescription
Renderer_renderer

ClearRenderers()

Removes all renderers in the list of objects this clipping primitive clips.

Declaration
Materialpropertyblock

GetRenderersCopy()

Declaration
Returns
TypeDescription
IEnumerable<Renderer>

The current list of renderers.

Initialize()

Declaration

LateUpdate()

Declaration

OnCameraPreRender(CameraEventRouter)

Declaration
Parameters
Materialpropertyblock
TypeNameDescription
CameraEventRouterrouter

OnDestroy()

Materialpropertyblocks

Declaration

OnDisable()

Declaration

OnEnable()

Declaration

OnMaterialChanged(MaterialInstance)

Declaration
Parameters
TypeNameDescription
MaterialInstancematerialInstance

RemoveRenderer(Renderer)

Removes a renderer to the list of objects this clipping primitive clips.

Materialpropertyblock

Declaration
Parameters
TypeNameDescription
Renderer_renderer

ToggleClippingFeature(Material, Boolean)

Declaration
Parameters
Materialpropertyblocks
TypeNameDescription
Materialmaterial
BooleankeywordOn

ToggleClippingFeature(Material[], Boolean)

Declaration

Materialpropertyblock Srp

Parameters
TypeNameDescription
Material[]materials
BooleankeywordOn

ToggleClippingFeature(Boolean)

Materialpropertyblock Urp

Declaration
Parameters
TypeNameDescription
BooleankeywordOn

UpdateRenderers()

Declaration

UpdateShaderProperties(MaterialPropertyBlock)

Declaration
Parameters
TypeNameDescription
MaterialPropertyBlockmaterialPropertyBlock

Implements

IMaterialInstanceOwner

Float Node

The Float node ( shortcut: numeric 1 key ) generates a single float value. This value is usually useful to either define a Constant value which is directly used in shader calculations or to define an exposed Property value that can be modified by the material inspector that uses it.
This node can also be set as a ranged float by defining different values to its Min and Max parameters. As a ranged float it will only have values between [Min,Max].
A slider for current Value and Min and Max value modifiers will be made available on the node body when on ranged float mode.


Nodes used: Texture Coordinates, Float, Multiply, Texture Sample

Node Parameter Description Default Value
Type A set of ways the value behaves in different situations.
  • Constant: the value is assigned directly in shader code and can't be dynamically changed.
  • Property: the value becomes available in the properties of the material that uses the shader and can be changed in the material inspector or by script.
  • Instanced Property: the value can only be set by script and this defines the shader as an instanced shader. ( see more here: GPU Instancing )
  • Global: the value can only be set by script and this defines a static variable that is shared between all shaders that use it. It's useful to change a value globally.
Constant
Name Name of the property holding the float value. This is the name that will be shown in the material properties label if type is set to Property, if not this name is ignored but still useful for organization purposes or to generate a Property Name Float #
Variable Mode Defines if the current property/global variable is to be created on the current shader.
  • Create: Property and/or global variable is created in the shader
  • Fetch: No variable nor property is registered on shader, useful when p.e. there's need to using global variables declared over a included cginc
Create
Auto-Register If toggled on, creates the property and/or global variable even if not connected to an Output node Off
Precision Defines the amount of bytes the variable can hold, effectively defining how precise the value is. It's usefulness is bond by the hardware specifications necessary. Lowest precision is slightly faster but might produce errors and artifacts.
  • Float: Highest precision, useful for values that can be very high or very low in value (ie: positions, coordinates, etc)
  • Half: Medium precision, in most cases is as good as Float but at half of it's precision
Float
Min Defines minimum value if node is set to be a ranged float 0
Max Defines maximum value if node is set to be a ranged float 0
Default Value This is the float value the shader currently holds. It's also the default value that is used when a new material is created with this shader. 0
Other Parameters
Property Name This is the variable name that contains the float value, this is automatically generated using the Name parameter, it's greyed out and not editable. The generation process removes special characters, whitespaces and adds an underscore at the beginning ( ie: 'My Property Name' becomes '_MyPropertyName' ). This parameter is only visible in Property, Instanced Property and Global types to indicate what's the variable name to use when editing this value by script. _Float#
Material Value This is the float value the node the material currently holds. This parameter is only visible in Property and Instanced Property types which are the two types that let you change the value per material. 0
Attributes
Hide in Inspector Does not show the property value in the material inspector Off
HDR Indicates that a property expects a high-dynamic range (HDR) value Off
Gamma Indicates that a property is specified as sRGB value in the UI and possibly needs conversion according to color space used Off
Per Renderer Data Indicates that a property will be coming from per-renderer data in the form of a MaterialPropertyBlock. Off
Toggle Displays a float as a toggle. The property value will be 0 or 1, depending on the toggle state Off
Int Range Displays an integer slider for a Range shader property Off
Enum Displays a popup menu for a float property, and enables corresponding shader keyword. This option activates a new Enums group where the user can either create custom enums or use engine enum classes Off
Custom Attributes Allows adding custom attributes directly on a textfield -

Math Operators - Floats and Color

Retrieved from 'http://wiki.amplify.pt/index.php?title=Unity_Products:Amplify_Shader_Editor/Float&oldid=3165'