I was following a YouTube video and guide and got some shader scripts. It was very plug and play which was nice. But I would like to tweak a few things but I have 5% knowledge about shaders.
I am using URP
- Id like it when the lights overlap they aren't additive. (I don't want that to happen in the green box)
- The guide mentions I need a different blend mode for scenes that are completely dark.
(here's the link to the guide) https://www.patreon.com/posts/wind-waker-style-78831006
Here is what my scene looks like without the directional light on.
If you review the shader tutorial it explains how for URP it needed two shaders since unity cant do multiple passes or something.
Another issue ( i found a workaround for) is that the shader doesn't apply to everything that gets hit in the circle. The flat sprites, which are the ants, are tilted at a 45 degree angle. They don't get the light applied to their front side (plane mesh)
So there are two shaders. one is a mask and one is the light to be Blend "multiplied" onto other mesh's
Here is the light shader:
Shader "Custom/StencilLight Color"
{
Properties
{
[HDR]_Color("Color",Color) = (1,1,1,1)
}
HLSLINCLUDE
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
};
v2f vert(appdata v)
{
v2f o;
o.vertex = TransformObjectToHClip(v.vertex.xyz);
return o;
}
CBUFFER_START(UnityPerMaterial)
float4 _Color;
CBUFFER_END
float4 frag(v2f i) : SV_Target
{
return _Color * _Color.a;
}
ENDHLSL
SubShader
{
Tags{"Queue" = "Transparent" "RenderType" = "Transparent"}
Pass
{
Tags
{
"RenderType" = "Transparent"
"RenderPipeline" = "UniversalPipeline"
}
Zwrite off
Ztest Lequal
Cull Back
Blend DstColor One
Stencil
{
comp equal
ref 1
pass zero
fail zero
zfail zero
}
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDHLSL
}
Pass
{
Tags
{
"RenderPipeline" = "UniversalPipeline"
"LightMode" = "UniversalForward"
}
ZTest always
ZWrite on
Cull Front
//Blend DstColor One
Blend DstColor One
Stencil
{
Ref 1
Comp equal
Pass zero
}
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
ENDHLSL
}
}
}
and here is the mask shader:
Shader "Custom/StencilLight Mask"
{
SubShader
{
Tags
{
"RenderType" = "Transparent"
"Queue" = "Transparent"
"RenderPipeline" = "UniversalPipeline"
}
LOD 100
Pass
{
Ztest Greater
Zwrite off
Cull Off
Colormask 0
Stencil
{
Comp Always
Ref 1
Pass Replace
}
}
}
}
Please let me know if you need further details. Thank you!