Hi,
is there a way to use a Grab Pass in a Deferred only Shader? I got only a grey Plane. I will create a deferred water surface with refractions but deferred doesn't support transparency. Thanks!
Cyntherius wrote:Hi, thanks for your reply!
I've testet a bunch of queue indices (stepwise 0 till 3000, on 2501 the object disappears because its deferred mode and cant render semi-transparent). Unfortunately I have no clue whats the problem.
With the "Only Forward" Render Path all things seems to be right. In "Deferred Only" gray/dark/black.
// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "Custom/Deferred Grab Pass"
{
Properties
{
[Normal]_SurfaceNormal("Surface Normal", 2D) = "bump" {}
_Smoothness("Smoothness", Range( 0 , 1)) = 0
_Metallic("Metallic", Range( 0 , 1)) = 0
[HideInInspector] _texcoord( "", 2D ) = "white" {}
[HideInInspector] __dirty( "", Int ) = 1
}
SubShader
{
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" }
Cull Back
GrabPass{ }
CGPROGRAM
#pragma target 3.0
#pragma surface surf Standard keepalpha addshadow fullforwardshadows exclude_path:forward
struct Input
{
float4 screenPos;
float2 uv_texcoord;
};
uniform sampler2D _GrabTexture;
uniform sampler2D _SurfaceNormal;
uniform float4 _SurfaceNormal_ST;
uniform float _Metallic;
uniform float _Smoothness;
inline float4 ASE_ComputeGrabScreenPos( float4 pos )
{
#if UNITY_UV_STARTS_AT_TOP
float scale = -1.0;
#else
float scale = 1.0;
#endif
float4 o = pos;
o.y = pos.w * 0.5f;
o.y = ( pos.y - o.y ) * _ProjectionParams.x * scale + o.y;
return o;
}
void surf( Input i , inout SurfaceOutputStandard o )
{
float4 ase_screenPos = float4( i.screenPos.xyz , i.screenPos.w + 0.00000000001 );
float4 ase_grabScreenPos = ASE_ComputeGrabScreenPos( ase_screenPos );
float4 ase_grabScreenPosNorm = ase_grabScreenPos / ase_grabScreenPos.w;
float2 uv_SurfaceNormal = i.uv_texcoord * _SurfaceNormal_ST.xy + _SurfaceNormal_ST.zw;
float4 screenColor1 = tex2D( _GrabTexture, ( ase_grabScreenPosNorm + float4( UnpackNormal( tex2D( _SurfaceNormal, uv_SurfaceNormal ) ) , 0.0 ) ).xy );
o.Albedo = screenColor1.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Alpha = 1;
}
ENDCG
}
Fallback "Diffuse"
CustomEditor "ASEMaterialInspector"
}
/*ASEBEGIN
Version=15401
-1073;142;1066;1198;1244.813;865.6038;1.708548;True;False
Node;AmplifyShaderEditor.SamplerNode;4;-655.0253,26.25768;Float;True;Property;_SurfaceNormal;Surface Normal;0;1;[Normal];Create;True;0;0;False;0;None;1b497a628063d62448e26bf495fd985a;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.GrabScreenPosition;2;-605.5768,-439.6083;Float;False;0;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.SimpleAddOpNode;3;-261.8863,-131.3553;Float;False;2;2;0;FLOAT4;0,0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT4;0
Node;AmplifyShaderEditor.RangedFloatNode;5;-288,144;Float;False;Property;_Metallic;Metallic;2;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;6;-288,224;Float;False;Property;_Smoothness;Smoothness;1;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.ScreenColorNode;1;-52.77116,-135.7114;Float;False;Global;_GrabScreen0;Grab Screen 0;0;0;Create;True;0;0;False;0;Object;-1;False;False;1;0;FLOAT2;0,0;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;210,-128;Float;False;True;2;Float;ASEMaterialInspector;0;0;Standard;Custom/Deferred Grab Pass;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;DeferredOnly;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;-1;False;-1;-1;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;-1;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
WireConnection;3;0;2;0
WireConnection;3;1;4;0
WireConnection;1;0;3;0
WireConnection;0;0;1;0
WireConnection;0;3;5;0
WireConnection;0;4;6;0
ASEEND*/
//CHKSM=6246CBFDEF93CB10312CB4E526B00A21E5FDC790
Cyntherius wrote:Something new about the GP in only deferred?
Cyntherius wrote:This is the simplest version of the GrabPass with normal map "distorsion". I want to use the pre-rendered geometry to fake transparency in deferred(!).
- Code: Select all
// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "Custom/Deferred Grab Pass"
{
Properties
{
[Normal]_SurfaceNormal("Surface Normal", 2D) = "bump" {}
_Smoothness("Smoothness", Range( 0 , 1)) = 0
_Metallic("Metallic", Range( 0 , 1)) = 0
[HideInInspector] _texcoord( "", 2D ) = "white" {}
[HideInInspector] __dirty( "", Int ) = 1
}
SubShader
{
Tags{ "RenderType" = "Opaque" "Queue" = "Geometry+0" }
Cull Back
GrabPass{ }
CGPROGRAM
#pragma target 3.0
#pragma surface surf Standard keepalpha addshadow fullforwardshadows exclude_path:forward
struct Input
{
float4 screenPos;
float2 uv_texcoord;
};
uniform sampler2D _GrabTexture;
uniform sampler2D _SurfaceNormal;
uniform float4 _SurfaceNormal_ST;
uniform float _Metallic;
uniform float _Smoothness;
inline float4 ASE_ComputeGrabScreenPos( float4 pos )
{
#if UNITY_UV_STARTS_AT_TOP
float scale = -1.0;
#else
float scale = 1.0;
#endif
float4 o = pos;
o.y = pos.w * 0.5f;
o.y = ( pos.y - o.y ) * _ProjectionParams.x * scale + o.y;
return o;
}
void surf( Input i , inout SurfaceOutputStandard o )
{
float4 ase_screenPos = float4( i.screenPos.xyz , i.screenPos.w + 0.00000000001 );
float4 ase_grabScreenPos = ASE_ComputeGrabScreenPos( ase_screenPos );
float4 ase_grabScreenPosNorm = ase_grabScreenPos / ase_grabScreenPos.w;
float2 uv_SurfaceNormal = i.uv_texcoord * _SurfaceNormal_ST.xy + _SurfaceNormal_ST.zw;
float4 screenColor1 = tex2D( _GrabTexture, ( ase_grabScreenPosNorm + float4( UnpackNormal( tex2D( _SurfaceNormal, uv_SurfaceNormal ) ) , 0.0 ) ).xy );
o.Albedo = screenColor1.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Alpha = 1;
}
ENDCG
}
Fallback "Diffuse"
CustomEditor "ASEMaterialInspector"
}
/*ASEBEGIN
Version=15401
-1073;142;1066;1198;1244.813;865.6038;1.708548;True;False
Node;AmplifyShaderEditor.SamplerNode;4;-655.0253,26.25768;Float;True;Property;_SurfaceNormal;Surface Normal;0;1;[Normal];Create;True;0;0;False;0;None;1b497a628063d62448e26bf495fd985a;True;0;True;bump;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1;False;5;FLOAT3;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.GrabScreenPosition;2;-605.5768,-439.6083;Float;False;0;0;5;FLOAT4;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.SimpleAddOpNode;3;-261.8863,-131.3553;Float;False;2;2;0;FLOAT4;0,0,0,0;False;1;FLOAT3;0,0,0;False;1;FLOAT4;0
Node;AmplifyShaderEditor.RangedFloatNode;5;-288,144;Float;False;Property;_Metallic;Metallic;2;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.RangedFloatNode;6;-288,224;Float;False;Property;_Smoothness;Smoothness;1;0;Create;True;0;0;False;0;0;0;0;1;0;1;FLOAT;0
Node;AmplifyShaderEditor.ScreenColorNode;1;-52.77116,-135.7114;Float;False;Global;_GrabScreen0;Grab Screen 0;0;0;Create;True;0;0;False;0;Object;-1;False;False;1;0;FLOAT2;0,0;False;5;COLOR;0;FLOAT;1;FLOAT;2;FLOAT;3;FLOAT;4
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;210,-128;Float;False;True;2;Float;ASEMaterialInspector;0;0;Standard;Custom/Deferred Grab Pass;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;False;-1;0;False;-1;False;0;False;-1;0;False;-1;False;0;Opaque;0.5;True;True;0;False;Opaque;;Geometry;DeferredOnly;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;0;False;-1;False;0;False;-1;255;False;-1;255;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;0;False;-1;False;2;15;10;25;False;0.5;True;0;0;False;-1;0;False;-1;0;0;False;-1;0;False;-1;-1;False;-1;-1;False;-1;0;False;0;0,0,0,0;VertexOffset;True;False;Cylindrical;False;Relative;0;;-1;-1;-1;-1;0;False;0;0;False;-1;-1;0;False;-1;0;0;16;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0;False;4;FLOAT;0;False;5;FLOAT;0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0;False;9;FLOAT;0;False;10;FLOAT;0;False;13;FLOAT3;0,0,0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
WireConnection;3;0;2;0
WireConnection;3;1;4;0
WireConnection;1;0;3;0
WireConnection;0;0;1;0
WireConnection;0;3;5;0
WireConnection;0;4;6;0
ASEEND*/
//CHKSM=6246CBFDEF93CB10312CB4E526B00A21E5FDC790
Users browsing this forum: No registered users and 8 guests