Unity Products:Amplify Shader Editor/Get Local Var and Unity Products:Amplify Shader Editor/Grab Screen Color: Difference between pages

From Amplify Creations Wiki
(Difference between pages)
Jump to navigation Jump to search
ampwiki>Kebrus
mNo edit summary
 
m (1 revision imported)
 
Line 1: Line 1:
[[Unity_Products:Amplify_Shader_Editor/Nodes | Back to Node List]]
[[Unity_Products:Amplify_Shader_Editor/Nodes | Back to Node List]]
== Grab Screen Color Node ==


== Get Local Var Node ==
The Grab Screen Color allows a Grab Pass to be used. This special pass grabs the contents of the screen when the object is about to be drawn into a texture which can then be fetched using screen space UV coordinates.<br/>


The Get Local Var node ''( shortcut: G key )'' allows access to local values created via a [[Unity Products:Amplify Shader Editor/Register Local Var|Register Local Var]] node. This can be done by selecting a local variable through its [[#paramReference|Reference]] property available at the Node Properties window or upper left corner of the node body.
This node can either generate its internal UV coordinates or use custom ones if specified on the [[#paramUV|UV]] input port. By using the [[Unity_Products:Amplify_Shader_Editor/Grab_Screen_Position| Grab Screen Position]] node alongside with this node it becomes very easy and intuitive to achieve effects like p.e. refraction.<br/>
<br/>'''NOTE:''' Using this node is similar to directly connect the '''Register Local Var''' output to where the value is needed.
When UV input port is left unconnected, internal generated UVs are similar on having a Grab Screen Position directly connected to it.


<img class="responsive-img" src="http://wiki.amplify.pt/images/NodeDetail/RegisterGetLocalVar.jpg">  
A custom texture name can also be used by activating the [[#paramCustomGrabPass|Custom Grab Pass]] toggle and specifying a new name into the [[#paramGrabPassName|Name]]. Please note that a Grab Pass behavior changes when specifying a custom texture name as the current screen contents will only be grabbed once per frame for the first object that used the given texture name. If no custom texture name is set then the current screen contents will be grabbed for each object that uses it.
Please check Unity [https://docs.unity3d.com/Manual/SL-GrabPass.html official documentation] for further information.<br/>
<br/>
'''Built-in Notes:''' Grab passes only works in the '''Forward''' rendering path. The grab texture will return incorrect results if used on a deferred only shader.<br/>
'''URP 3D Notes:''' For this node to correctly work with '''URP 3D Renderer''' users must:<br/>
* Go to their pipeline asset's inspector and activate the '''Opaque Texture''' toggle.<br/>
* Make sure the [[#param2DRenderer|2D Renderer]] option over this node is turned off.<br/>
'''URP 2D Notes:''' For this node to correctly work with '''URP 2D Renderer''' users must:<br/>
* Set the '''Foremost Sorting Layer''' on the '''2D Asset Renderer'''  to the last layer which is going to be caught by this node.
* Set the '''Sorting Layer''' of the sprite itself ( which will be using the shader with the [[Unity_Products:Amplify_Shader_Editor/Grab_Screen_Color|Grab Screen Color]] node ) to one which is above the one specified on the previous step.
* Make sure the [[#param2DRenderer|2D Renderer]]' option over this node is turned on.<br/>
 
<br/>
<img class="responsive-img" src="http://wiki.amplify.pt/images/NodeDetail/GrabScreenPosAndColor.jpg">
<br/><font size="1">Nodes used:  
<br/><font size="1">Nodes used:  
[[Unity_Products:Amplify_Shader_Editor/World_Normal|World Normal]],  
[[Unity_Products:Amplify_Shader_Editor/Grab_Screen_Position|Grab Screen Position]],  
[[Unity_Products:Amplify_Shader_Editor/World_Space_Light_Dir|World Space Light Dir]],
[[Unity_Products:Amplify_Shader_Editor/Float|Float]],  
[[Unity_Products:Amplify_Shader_Editor/Dot|Dot]],
[[Unity_Products:Amplify_Shader_Editor/Texture_Sample|Texture Sample]],  
[[Unity_Products:Amplify_Shader_Editor/Register_Local_Var|Register Local Var]],  
[[Unity_Products:Amplify_Shader_Editor/Add|Add]],  
[[Unity_Products:Amplify_Shader_Editor/Get_Local_Var|Get Local Var]],  
[[Unity_Products:Amplify_Shader_Editor/Grab_Screen_Color|Grab Screen Color]]
[[Unity_Products:Amplify_Shader_Editor/Scale_And_Offset|Scale And Offset]],
[[Unity_Products:Amplify_Shader_Editor/Float|Float]],
[[Unity_Products:Amplify_Shader_Editor/Texture_Sample|Texture Sample]]
</font>
</font>


Line 22: Line 34:
! style="width: 10%;" | Node Parameter !! Description !! style="width: 10%;" | Default Value
! style="width: 10%;" | Node Parameter !! Description !! style="width: 10%;" | Default Value
|-
|-
| id="paramAutoRegister" | Auto-Register
| Creates Grab Pass even if not connected to an output node.
| False
|-
| id="paramMode" | Mode
| Specify if this node is to register a new Grab Pass or to use one already created from another Grab Screen Color as reference
* '''Object:'''  Register a new Grab Pass
* '''Reference:''' Use Grab Pass registered by referenced Grab Screen Color node
| Object
|-
| id="paramprecision" | 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
|-
| id="paramNormalize" | Normalize
| Automatically performs the perspective division over the input UVs.
| False
|-
| colspan="3" style="background:white; text-align: center; font-size: 11px;"| Object
|- style="background: #e5e5e5;" |
| id="paramCustomGrabPass" | Custom Grab Pass
| A custom texture name can be used on the grab pass register process when turned on. Otherwise the default _GrabTexture sampler will be used.
Please note that when toggled off or no name is specified, a screen grab is done for each object that uses it, as opposed to when a name is specified the screen grab is only done once per frame for the first object that used the give texture name.
| False
|- style="background: #e5e5e5;" |
| id="paramGrabPassName" | Name
| Specify a custom texture name which will have the current screen contents.
| Grab Screen #
|- style="background: #e5e5e5;" |
| id="paramGrabPassProperty Name" | Property Name
| This is the variable name that contains the 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 Texture Name" becomes "_MyTextureName" )
| _GrabScreen#
|-
| colspan="3" style="background:white; text-align: center; font-size: 11px;"| Reference
|- style="background: #e5e5e5;" |
| id="paramReference" | Reference
| id="paramReference" | Reference
| Lists all available local variables. Select one to be used by the node.
| Select Grab Pass property from other Grab Screen Color node to be used as reference
| None
| None
|-
| colspan="3" style="background:white; text-align: center; font-size: 11px;"| HDRP
|- style="background: #e5e5e5;" |
| id="paramExposure" | Exposure
| Sets if fetched scene color value is affected by current exposure
| False
|-
| colspan="3" style="background:white; text-align: center; font-size: 11px;"| URP
|- style="background: #e5e5e5;" |
| id="param2DRenderer" | 2D Renderer
| Selects if scene color fetch is to be made over the 3D Camera Opaque texture or the 2D Camera Sorting Layer texture
| False
|}
{| class="wikitable" style="width: 100%;"
|-
! style="width: 10%;" | Input Port !! Description !! style="width: 10%;" | Type
|-
| UV
| Specify current UV coordinates to be used on Grab Pass texture fetch. Auto-generate UVs similar on having a Grab Screen Position directly connected to it.
| Float2
|- style="background: #e5e5e5;" |
| LOD
| Specify which LOD level of the HDRP color pyramid is to be used. (Only available on HDRP)
| Float
|}
{| class="wikitable" style="width: 100%;"
|-
! style="width: 10%;" | Output Port !! Description !! style="width: 10%;" | Type
|-
| RGBA
| Returns the current fetched color from the scene color texture
| Float4
|-
| R
| Returns only the R component of the current fetched color from the scene color texture
| Float
|-
| G
| Returns only the G component of the current fetched color from the scene color texture
| Float
|-
| B
| Returns only the B component of the current fetched color from the scene color texture
| Float
|-
| A
| Returns only the A component of the current fetched color from the scene color texture
| Float
|}
|}




[[Unity_Products:Amplify_Shader_Editor/Nodes | Back to Node List ]]
[[Unity_Products:Amplify_Shader_Editor/Nodes | Back to Node List]]
[[Category:Nodes]][[Category:Miscellaneous]]
[[Category:Nodes]][[Category:Camera and Screen]]

Latest revision as of 00:06, 2 December 2023

Back to Node List

Grab Screen Color Node

The Grab Screen Color allows a Grab Pass to be used. This special pass grabs the contents of the screen when the object is about to be drawn into a texture which can then be fetched using screen space UV coordinates.

This node can either generate its internal UV coordinates or use custom ones if specified on the UV input port. By using the Grab Screen Position node alongside with this node it becomes very easy and intuitive to achieve effects like p.e. refraction.
When UV input port is left unconnected, internal generated UVs are similar on having a Grab Screen Position directly connected to it.

A custom texture name can also be used by activating the Custom Grab Pass toggle and specifying a new name into the Name. Please note that a Grab Pass behavior changes when specifying a custom texture name as the current screen contents will only be grabbed once per frame for the first object that used the given texture name. If no custom texture name is set then the current screen contents will be grabbed for each object that uses it.

Please check Unity official documentation for further information.

Built-in Notes: Grab passes only works in the Forward rendering path. The grab texture will return incorrect results if used on a deferred only shader.
URP 3D Notes: For this node to correctly work with URP 3D Renderer users must:

  • Go to their pipeline asset's inspector and activate the Opaque Texture toggle.
  • Make sure the 2D Renderer option over this node is turned off.

URP 2D Notes: For this node to correctly work with URP 2D Renderer users must:

  • Set the Foremost Sorting Layer on the 2D Asset Renderer to the last layer which is going to be caught by this node.
  • Set the Sorting Layer of the sprite itself ( which will be using the shader with the Grab Screen Color node ) to one which is above the one specified on the previous step.
  • Make sure the 2D Renderer' option over this node is turned on.



Nodes used: Grab Screen Position, Float, Texture Sample, Add, Grab Screen Color

Node Parameter Description Default Value
Auto-Register Creates Grab Pass even if not connected to an output node. False
Mode Specify if this node is to register a new Grab Pass or to use one already created from another Grab Screen Color as reference
  • Object: Register a new Grab Pass
  • Reference: Use Grab Pass registered by referenced Grab Screen Color node
Object
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
Normalize Automatically performs the perspective division over the input UVs. False
Object
Custom Grab Pass A custom texture name can be used on the grab pass register process when turned on. Otherwise the default _GrabTexture sampler will be used.

Please note that when toggled off or no name is specified, a screen grab is done for each object that uses it, as opposed to when a name is specified the screen grab is only done once per frame for the first object that used the give texture name.

False
Name Specify a custom texture name which will have the current screen contents. Grab Screen #
Property Name This is the variable name that contains the 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 Texture Name" becomes "_MyTextureName" ) _GrabScreen#
Reference
Reference Select Grab Pass property from other Grab Screen Color node to be used as reference None
HDRP
Exposure Sets if fetched scene color value is affected by current exposure False
URP
2D Renderer Selects if scene color fetch is to be made over the 3D Camera Opaque texture or the 2D Camera Sorting Layer texture False
Input Port Description Type
UV Specify current UV coordinates to be used on Grab Pass texture fetch. Auto-generate UVs similar on having a Grab Screen Position directly connected to it. Float2
LOD Specify which LOD level of the HDRP color pyramid is to be used. (Only available on HDRP) Float


Output Port Description Type
RGBA Returns the current fetched color from the scene color texture Float4
R Returns only the R component of the current fetched color from the scene color texture Float
G Returns only the G component of the current fetched color from the scene color texture Float
B Returns only the B component of the current fetched color from the scene color texture Float
A Returns only the A component of the current fetched color from the scene color texture Float


Back to Node List