.shader
// Made with Amplify Shader Editor v1.9.0.2
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "S_FX_Screen_01"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("MainTex", 2D) = "white" {}
_TilingOffset("TilingOffset", Vector) = (1,1,0,0)
_UV_Speed("UV_Speed", Vector) = (0,0,0,0)
_Mask("Mask", 2D) = "white" {}
_MaskIntensity("MaskIntensity", Float) = 1
_Alpha("Alpha", Range( 0 , 1)) = 1
code
Assistant
User
Assistant
The error message that mentions _GrabTexture_ST seems to suggest there's a problem with properties associated with the GrabPass feature in Unity. is an automatically generated property by Unity that holds texture scale and offset for the texture captured in the GrabPass.
[Worker0] Shader properties can't be added to this global property sheet. Trying to add _GrabTexture (type 4 count 1)
[Worker0] Shader properties can't be added to this global property sheet. Trying to add _GrabTexture_HDR (type 2 count 1)
Shader properties can't be added to this global property sheet. Trying to add _GrabTexture_ST (type 2 count 1)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)。帮我修复下shader的错误
The error message you are seeing has to do with the use of a GrabPass and its associated properties. The shader you provided includes a GrabPass, which is a technique to capture the screen before rendering objects, so you can use it as a texture within the same shader. The particular issue is with _GrabTexture_ST, which is the sampler state (texture scale and offset) for the texture captured by the grab pass.
The error is suggesting that there's a problem with the way _GrabTexture_ST is being used or declared in the shader, as Unity cannot add this property to the global property sheet.
Let's address the following possibilities that might fix the issue:
Ensure that the GrabPass is named correctly:
The shader code has to reference the name assigned to the GrabPass in order to use it correctly.
hlsl
GrabPass { "_GrabTexture" }
Correct the declaration of the GrabPass texture:
If you have a name for the GrabPass like above, make sure you reference it correctly in the code:
hlsl
sampler2D _GrabTexture;
Remove unnecessary lines:
The error message mentions _GrabTexture_ST. This is usually an automatic tiling and offset property for textures, but it's not always needed for a GrabPass. Unless you explicitly need to manipulate the tiling and offset of the GrabPass texture, you may remove any lines referencing _GrabTexture_ST.
If _GrabTexture_ST is being used and is necessary, you can try to add a half4 property to define it manually in the shader if this property must be modifiable and not automatically handled by Unity.
hlsl
// In Properties
_GrabTexture_ST("Grab Texture Tiling and Offset", Vector) = (1,1,0,0)
// In the CGPROGRAM/DX11 section
sampler2D _GrabTexture;
float4 _GrabTexture_ST;
Make sure you use _GrabTexture_ST correctly with texture sampling functions that accept scale and offset parameters. For instance:
Overall, it's essential to ensure that Unity's automatic handling of _GrabTexture and associated properties aligns with your custom shader code. If after making the changes the error persists, the issue may lie elsewhere in the shader code, and a more granular debugging process will be required.
If you don't need any specific handling for _GrabTexture_ST, removing its references may solve your problem.
Please note that shader development can be quite complex and errors often require careful debugging of the code. If further errors occur, you might need to inspect each part of the shader and test it step-by-step to isolate the issue.
Shader properties can’t be added to this global property sheet. Trying to add _GrabTexture_ST (type 2 count 1)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)。帮我修复下shader的错误
_GrabTexture_ST
It appears that this error is not triggered by an explicit reference in your shader code but might be the result of the internal workings of Unity's shader system, which is trying to automatically add this property _GrabTexture_ST for the grabbed texture.
Here are a few steps that may help resolve the issue:
Name the GrabPass:
Make sure to name your GrabPass so that you have explicit control over it, instead of using an unnamed GrabPass. This prevents Unity from automatically handling the naming.
hlsl
// Inside SubShader
GrabPass { "_GrabTexture" }
Explicitly declare sampler for the GrabPass:
Declare sampler2D for your named GrabPass texture. You will then sample _GrabTexture rather than allowing Unity to automatically generate.
hlsl
sampler2D _GrabTexture;
Remove ASE declaration macro for _GrabTexture:
Discussing your shader, it suggests an Amplify Shader Editor macro ASE_DECLARE_SCREENSPACE_TEXTURE. This macro might be in conflict with how Unity automatically handles grabbed textures. Try simplifying the declaration of your grabbed texture by commenting out or removing the macro and see if Unity handles it better.
hlsl
// Comment out or remove this line:
// ASE_DECLARE_SCREENSPACE_TEXTURE( _GrabTexture )
Review the rest of your shader code:
Ensure there is no other place in your shader where _GrabTexture_ST or similar syntax is present, as it should not typically be necessary to deal with the scale and offset for the GrabPass texture this way.
Fallback:
Ensure you don't have a fallback that might be causing compatibility issues. Since you have a Fallback Off at the end of your shader, this should not be an issue, but double-check that there are no other fallback references.
If making these adjustments does not resolve the issue, you may need to strip down your shader to a minimal example and see if the error persists. Gradually add back features to pinpoint what's causing the conflict.
Remember that shader debugging is often iterative and might require trying a few different approaches to isolate the problem. Unity's Shader compilation can be quite picky, and seemingly minor discrepancies can lead to errors.