Hello. I am a shader noob so please forgive me.
I am trying to create a soft edge cutout like the old legacy shader (only with lighting). I've gone through the tutorials/videos on youtube and perused the wiki. I still don't understand how to create the soft edge effect on a cut out shader. If anybody could point me in the right direction, I would be grateful.
Thanks for your time.
soft edge cutout
- Amplify_Borba
- Posts: 1239
- Joined: Mon Jul 24, 2017 9:50 am
Re: soft edge cutout
Hello, thank you for getting in touch and for your support!
I believe that cutout shaders don't display soft edges unless modified, can you please provide an example of the mentioned legacy shader?
I believe that cutout shaders don't display soft edges unless modified, can you please provide an example of the mentioned legacy shader?
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
-
AlbertPRoss
- Posts: 3
- Joined: Sun Jul 08, 2018 6:19 pm
Re: soft edge cutout
Here is the old Unity shader. I've used it for vegetation and hair in mobile games.
You can find some more here.
https://forum.unity.com/threads/cutout- ... ar.150145/
Code: Select all
// Compiled shader for PC, Mac & Linux Standalone
//////////////////////////////////////////////////////////////////////////
//
// NOTE: This is *not* a valid shader file, the contents are provided just
// for information and for debugging purposes only.
//
//////////////////////////////////////////////////////////////////////////
// Skipping shader variants that would not be included into build of current scene.
Shader "Legacy Shaders/Transparent/Cutout/Soft Edge Unlit" {
Properties {
_Color ("Main Color", Color) = (1.000000,1.000000,1.000000,1.000000)
_MainTex ("Base (RGB) Alpha (A)", 2D) = "white" { }
_Cutoff ("Base Alpha cutoff", Range(0.000000,0.900000)) = 0.500000
}
SubShader {
Tags { "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "RenderType"="TransparentCutout" }
// Stats for Vertex shader:
// d3d11: 9 math
// Stats for Fragment shader:
// d3d11: 3 math, 1 texture
Pass {
Tags { "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "RenderType"="TransparentCutout" }
Cull Off
//////////////////////////////////
// //
// Compiled programs //
// //
//////////////////////////////////
//////////////////////////////////////////////////////
No keywords set in this variant.
-- Hardware tier variant: Tier 1
-- Vertex shader for "d3d11":
// Stats: 9 math, 2 temp registers
Uses vertex data channel "Vertex"
Uses vertex data channel "Tangent"
Uses vertex data channel "TexCoord"
Constant Buffer "$Globals" (80 bytes) on slot 0 {
Vector4 _MainTex_ST at 32
}
Constant Buffer "UnityPerDraw" (160 bytes) on slot 1 {
Matrix4x4 unity_ObjectToWorld at 0
}
Constant Buffer "UnityPerFrame" (368 bytes) on slot 2 {
Matrix4x4 unity_MatrixVP at 272
}
Shader Disassembly:
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION 0 xyzw 0 NONE float xyz
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xy 2 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float xyzw
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xy 2 NONE float xy
//
vs_4_0
dcl_constantbuffer CB0[3], immediateIndexed
dcl_constantbuffer CB1[4], immediateIndexed
dcl_constantbuffer CB2[21], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xyzw
dcl_input v2.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_temps 2
0: mul r0.xyzw, v0.yyyy, cb1[1].xyzw
1: mad r0.xyzw, cb1[0].xyzw, v0.xxxx, r0.xyzw
2: mad r0.xyzw, cb1[2].xyzw, v0.zzzz, r0.xyzw
3: add r0.xyzw, r0.xyzw, cb1[3].xyzw
4: mul r1.xyzw, r0.yyyy, cb2[18].xyzw
5: mad r1.xyzw, cb2[17].xyzw, r0.xxxx, r1.xyzw
6: mad r1.xyzw, cb2[19].xyzw, r0.zzzz, r1.xyzw
7: mad o0.xyzw, cb2[20].xyzw, r0.wwww, r1.xyzw
8: mov o1.xyzw, v1.xyzw
9: mad o2.xy, v2.xyxx, cb0[2].xyxx, cb0[2].zwzz
10: ret
// Approximately 0 instruction slots used
-- Hardware tier variant: Tier 1
-- Fragment shader for "d3d11":
// Stats: 3 math, 2 temp registers, 1 textures
Set 2D Texture "_MainTex" to slot 0
Constant Buffer "$Globals" (80 bytes) on slot 0 {
Float _Cutoff at 48
Vector4 _Color at 64
}
Shader Disassembly:
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float
// COLOR 0 xyzw 1 NONE float
// TEXCOORD 0 xy 2 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_4_0
dcl_constantbuffer CB0[5], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_temps 2
0: sample r0.xyzw, v2.xyxx, t0.xyzw, s0
1: mad r1.x, cb0[4].w, r0.w, -cb0[3].x
2: mul r0.xyzw, r0.xyzw, cb0[4].xyzw
3: mov o0.xyzw, r0.xyzw
4: lt r0.x, r1.x, l(0.000000)
5: discard_nz r0.x
6: ret
// Approximately 0 instruction slots used
}
// Stats for Vertex shader:
// d3d11: 9 math
// Stats for Fragment shader:
// d3d11: 3 math, 1 texture
Pass {
Tags { "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "RenderType"="TransparentCutout" "RequireOption"="SoftVegetation" }
ZWrite Off
Cull Off
Blend SrcAlpha OneMinusSrcAlpha
//////////////////////////////////
// //
// Compiled programs //
// //
//////////////////////////////////
//////////////////////////////////////////////////////
No keywords set in this variant.
-- Hardware tier variant: Tier 1
-- Vertex shader for "d3d11":
// Stats: 9 math, 2 temp registers
Uses vertex data channel "Vertex"
Uses vertex data channel "Tangent"
Uses vertex data channel "TexCoord"
Constant Buffer "$Globals" (80 bytes) on slot 0 {
Vector4 _MainTex_ST at 32
}
Constant Buffer "UnityPerDraw" (160 bytes) on slot 1 {
Matrix4x4 unity_ObjectToWorld at 0
}
Constant Buffer "UnityPerFrame" (368 bytes) on slot 2 {
Matrix4x4 unity_MatrixVP at 272
}
Shader Disassembly:
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION 0 xyzw 0 NONE float xyz
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xy 2 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float xyzw
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xy 2 NONE float xy
//
vs_4_0
dcl_constantbuffer CB0[3], immediateIndexed
dcl_constantbuffer CB1[4], immediateIndexed
dcl_constantbuffer CB2[21], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xyzw
dcl_input v2.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_temps 2
0: mul r0.xyzw, v0.yyyy, cb1[1].xyzw
1: mad r0.xyzw, cb1[0].xyzw, v0.xxxx, r0.xyzw
2: mad r0.xyzw, cb1[2].xyzw, v0.zzzz, r0.xyzw
3: add r0.xyzw, r0.xyzw, cb1[3].xyzw
4: mul r1.xyzw, r0.yyyy, cb2[18].xyzw
5: mad r1.xyzw, cb2[17].xyzw, r0.xxxx, r1.xyzw
6: mad r1.xyzw, cb2[19].xyzw, r0.zzzz, r1.xyzw
7: mad o0.xyzw, cb2[20].xyzw, r0.wwww, r1.xyzw
8: mov o1.xyzw, v1.xyzw
9: mad o2.xy, v2.xyxx, cb0[2].xyxx, cb0[2].zwzz
10: ret
// Approximately 0 instruction slots used
-- Hardware tier variant: Tier 1
-- Fragment shader for "d3d11":
// Stats: 3 math, 2 temp registers, 1 textures
Set 2D Texture "_MainTex" to slot 0
Constant Buffer "$Globals" (80 bytes) on slot 0 {
Float _Cutoff at 48
Vector4 _Color at 64
}
Shader Disassembly:
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float
// COLOR 0 xyzw 1 NONE float
// TEXCOORD 0 xy 2 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_4_0
dcl_constantbuffer CB0[5], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v2.xy
dcl_output o0.xyzw
dcl_temps 2
0: sample r0.xyzw, v2.xyxx, t0.xyzw, s0
1: mad r1.x, cb0[4].w, r0.w, -cb0[3].x
2: mul r0.xyzw, r0.xyzw, cb0[4].xyzw
3: mov o0.xyzw, r0.xyzw
4: lt r0.x, -r1.x, l(0.000000)
5: discard_nz r0.x
6: ret
// Approximately 0 instruction slots used
}
}
}
You can find some more here.
https://forum.unity.com/threads/cutout- ... ar.150145/
- Ricardo Teixeira
- Posts: 954
- Joined: Fri Aug 09, 2013 2:26 pm
Re: soft edge cutout
Greetings,AlbertPRoss wrote:Here is the old Unity shader. I've used it for vegetation and hair in mobile games.
Code: Select all
// Compiled shader for PC, Mac & Linux Standalone ////////////////////////////////////////////////////////////////////////// // // NOTE: This is *not* a valid shader file, the contents are provided just // for information and for debugging purposes only. // ////////////////////////////////////////////////////////////////////////// // Skipping shader variants that would not be included into build of current scene. Shader "Legacy Shaders/Transparent/Cutout/Soft Edge Unlit" { Properties { _Color ("Main Color", Color) = (1.000000,1.000000,1.000000,1.000000) _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" { } _Cutoff ("Base Alpha cutoff", Range(0.000000,0.900000)) = 0.500000 } SubShader { Tags { "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "RenderType"="TransparentCutout" } // Stats for Vertex shader: // d3d11: 9 math // Stats for Fragment shader: // d3d11: 3 math, 1 texture Pass { Tags { "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "RenderType"="TransparentCutout" } Cull Off ////////////////////////////////// // // // Compiled programs // // // ////////////////////////////////// ////////////////////////////////////////////////////// No keywords set in this variant. -- Hardware tier variant: Tier 1 -- Vertex shader for "d3d11": // Stats: 9 math, 2 temp registers Uses vertex data channel "Vertex" Uses vertex data channel "Tangent" Uses vertex data channel "TexCoord" Constant Buffer "$Globals" (80 bytes) on slot 0 { Vector4 _MainTex_ST at 32 } Constant Buffer "UnityPerDraw" (160 bytes) on slot 1 { Matrix4x4 unity_ObjectToWorld at 0 } Constant Buffer "UnityPerFrame" (368 bytes) on slot 2 { Matrix4x4 unity_MatrixVP at 272 } Shader Disassembly: // // Generated by Microsoft (R) D3D Shader Disassembler // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // POSITION 0 xyzw 0 NONE float xyz // COLOR 0 xyzw 1 NONE float xyzw // TEXCOORD 0 xy 2 NONE float xy // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_POSITION 0 xyzw 0 POS float xyzw // COLOR 0 xyzw 1 NONE float xyzw // TEXCOORD 0 xy 2 NONE float xy // vs_4_0 dcl_constantbuffer CB0[3], immediateIndexed dcl_constantbuffer CB1[4], immediateIndexed dcl_constantbuffer CB2[21], immediateIndexed dcl_input v0.xyz dcl_input v1.xyzw dcl_input v2.xy dcl_output_siv o0.xyzw, position dcl_output o1.xyzw dcl_output o2.xy dcl_temps 2 0: mul r0.xyzw, v0.yyyy, cb1[1].xyzw 1: mad r0.xyzw, cb1[0].xyzw, v0.xxxx, r0.xyzw 2: mad r0.xyzw, cb1[2].xyzw, v0.zzzz, r0.xyzw 3: add r0.xyzw, r0.xyzw, cb1[3].xyzw 4: mul r1.xyzw, r0.yyyy, cb2[18].xyzw 5: mad r1.xyzw, cb2[17].xyzw, r0.xxxx, r1.xyzw 6: mad r1.xyzw, cb2[19].xyzw, r0.zzzz, r1.xyzw 7: mad o0.xyzw, cb2[20].xyzw, r0.wwww, r1.xyzw 8: mov o1.xyzw, v1.xyzw 9: mad o2.xy, v2.xyxx, cb0[2].xyxx, cb0[2].zwzz 10: ret // Approximately 0 instruction slots used -- Hardware tier variant: Tier 1 -- Fragment shader for "d3d11": // Stats: 3 math, 2 temp registers, 1 textures Set 2D Texture "_MainTex" to slot 0 Constant Buffer "$Globals" (80 bytes) on slot 0 { Float _Cutoff at 48 Vector4 _Color at 64 } Shader Disassembly: // // Generated by Microsoft (R) D3D Shader Disassembler // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_POSITION 0 xyzw 0 POS float // COLOR 0 xyzw 1 NONE float // TEXCOORD 0 xy 2 NONE float xy // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Target 0 xyzw 0 TARGET float xyzw // ps_4_0 dcl_constantbuffer CB0[5], immediateIndexed dcl_sampler s0, mode_default dcl_resource_texture2d (float,float,float,float) t0 dcl_input_ps linear v2.xy dcl_output o0.xyzw dcl_temps 2 0: sample r0.xyzw, v2.xyxx, t0.xyzw, s0 1: mad r1.x, cb0[4].w, r0.w, -cb0[3].x 2: mul r0.xyzw, r0.xyzw, cb0[4].xyzw 3: mov o0.xyzw, r0.xyzw 4: lt r0.x, r1.x, l(0.000000) 5: discard_nz r0.x 6: ret // Approximately 0 instruction slots used } // Stats for Vertex shader: // d3d11: 9 math // Stats for Fragment shader: // d3d11: 3 math, 1 texture Pass { Tags { "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "RenderType"="TransparentCutout" "RequireOption"="SoftVegetation" } ZWrite Off Cull Off Blend SrcAlpha OneMinusSrcAlpha ////////////////////////////////// // // // Compiled programs // // // ////////////////////////////////// ////////////////////////////////////////////////////// No keywords set in this variant. -- Hardware tier variant: Tier 1 -- Vertex shader for "d3d11": // Stats: 9 math, 2 temp registers Uses vertex data channel "Vertex" Uses vertex data channel "Tangent" Uses vertex data channel "TexCoord" Constant Buffer "$Globals" (80 bytes) on slot 0 { Vector4 _MainTex_ST at 32 } Constant Buffer "UnityPerDraw" (160 bytes) on slot 1 { Matrix4x4 unity_ObjectToWorld at 0 } Constant Buffer "UnityPerFrame" (368 bytes) on slot 2 { Matrix4x4 unity_MatrixVP at 272 } Shader Disassembly: // // Generated by Microsoft (R) D3D Shader Disassembler // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // POSITION 0 xyzw 0 NONE float xyz // COLOR 0 xyzw 1 NONE float xyzw // TEXCOORD 0 xy 2 NONE float xy // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_POSITION 0 xyzw 0 POS float xyzw // COLOR 0 xyzw 1 NONE float xyzw // TEXCOORD 0 xy 2 NONE float xy // vs_4_0 dcl_constantbuffer CB0[3], immediateIndexed dcl_constantbuffer CB1[4], immediateIndexed dcl_constantbuffer CB2[21], immediateIndexed dcl_input v0.xyz dcl_input v1.xyzw dcl_input v2.xy dcl_output_siv o0.xyzw, position dcl_output o1.xyzw dcl_output o2.xy dcl_temps 2 0: mul r0.xyzw, v0.yyyy, cb1[1].xyzw 1: mad r0.xyzw, cb1[0].xyzw, v0.xxxx, r0.xyzw 2: mad r0.xyzw, cb1[2].xyzw, v0.zzzz, r0.xyzw 3: add r0.xyzw, r0.xyzw, cb1[3].xyzw 4: mul r1.xyzw, r0.yyyy, cb2[18].xyzw 5: mad r1.xyzw, cb2[17].xyzw, r0.xxxx, r1.xyzw 6: mad r1.xyzw, cb2[19].xyzw, r0.zzzz, r1.xyzw 7: mad o0.xyzw, cb2[20].xyzw, r0.wwww, r1.xyzw 8: mov o1.xyzw, v1.xyzw 9: mad o2.xy, v2.xyxx, cb0[2].xyxx, cb0[2].zwzz 10: ret // Approximately 0 instruction slots used -- Hardware tier variant: Tier 1 -- Fragment shader for "d3d11": // Stats: 3 math, 2 temp registers, 1 textures Set 2D Texture "_MainTex" to slot 0 Constant Buffer "$Globals" (80 bytes) on slot 0 { Float _Cutoff at 48 Vector4 _Color at 64 } Shader Disassembly: // // Generated by Microsoft (R) D3D Shader Disassembler // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_POSITION 0 xyzw 0 POS float // COLOR 0 xyzw 1 NONE float // TEXCOORD 0 xy 2 NONE float xy // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Target 0 xyzw 0 TARGET float xyzw // ps_4_0 dcl_constantbuffer CB0[5], immediateIndexed dcl_sampler s0, mode_default dcl_resource_texture2d (float,float,float,float) t0 dcl_input_ps linear v2.xy dcl_output o0.xyzw dcl_temps 2 0: sample r0.xyzw, v2.xyxx, t0.xyzw, s0 1: mad r1.x, cb0[4].w, r0.w, -cb0[3].x 2: mul r0.xyzw, r0.xyzw, cb0[4].xyzw 3: mov o0.xyzw, r0.xyzw 4: lt r0.x, -r1.x, l(0.000000) 5: discard_nz r0.x 6: ret // Approximately 0 instruction slots used } } }
You can find some more here.
https://forum.unity.com/threads/cutout- ... ar.150145/
Thank you for the additional information, we really appreciate it. For future examples, please send the original shader.
Unfortunately, what you are looking for is actually a multi-pass shader that requires a custom template in ASE. Luckily, we're actually building one along the lines of what you're looking for.
Do you intend to use it with hair? I don't recommend using something like this for vegetation.
We'll register your interest and contact you as soon as we have any developments.
Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
-
AlbertPRoss
- Posts: 3
- Joined: Sun Jul 08, 2018 6:19 pm
Re: soft edge cutout
Okay. Thanks for the update. I probably would have known that were I more knowledgeable on shaders. Sorry.
Since I'm here though. I found a bug/glitch/hiccup. The color input isn't working for the ASE simple water shader in the Unity 2018 beta (standard pipeline). I haven't tested it in other settings. There are no bug reports. It just doesn't change the color. Also the depth settings seem to not do anything. Could be related. Most of the settings still work. I know everything worked in previous versions of Unity.
Since I'm here though. I found a bug/glitch/hiccup. The color input isn't working for the ASE simple water shader in the Unity 2018 beta (standard pipeline). I haven't tested it in other settings. There are no bug reports. It just doesn't change the color. Also the depth settings seem to not do anything. Could be related. Most of the settings still work. I know everything worked in previous versions of Unity.
- Amplify_Borba
- Posts: 1239
- Joined: Mon Jul 24, 2017 9:50 am
Re: soft edge cutout
Apologies for the inconvenience but we do not officially fully support Unity Beta releases as some of their features are still in development and issues that occur are likely to be Unity related.AlbertPRoss wrote:Okay. Thanks for the update. I probably would have known that were I more knowledgeable on shaders. Sorry.![]()
Since I'm here though. I found a bug/glitch/hiccup. The color input isn't working for the ASE simple water shader in the Unity 2018 beta (standard pipeline). I haven't tested it in other settings. There are no bug reports. It just doesn't change the color. Also the depth settings seem to not do anything. Could be related. Most of the settings still work. I know everything worked in previous versions of Unity.
In any case, I've tested the SimpleWater shader on Unity 2018.2.0f2 and it seems to be working as expected, we'll be sure to keep an eye out for any similar issues for the next official releases, so thank you for the heads up!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!