Cyan ✨ Profile picture
Mar 19, 2020 8 tweets 3 min read
Been looking into custom lighting for Universal RP (v7.2.1+) & #shadergraph (see thread)

blogs.unity3d.com/2019/07/31/cus…

This article is pretty good, but the Unlit Master won't receive shadows - unless you also use the keywords :
MAIN_LIGHT_CALCULATE_SHADOWS
_MAIN_LIGHT_SHADOW_CASCADE Image
However, the Default value in the blackboard doesn't seem to work unless the keyword is exposed in the main graph.. (but that requires the _ON suffix which would change the keyword).

So to enable them, I'm using the Debug mode on the Material inspector to set them instead : Image
(Could probably also set them through a C# script using material.EnableKeyword)
(Side note, in the URP Lit shader code the "_MAIN_LIGHT_SHADOWS" keyword is used instead of MAIN_LIGHT_CALCULATE_SHADOWS. But this produces errors in shadergraph as it requires a shadowCoord to be set up in the Varyings struct, which I don't think we can do).
This seems to be the only way to receive shadows with the Unlit Master currently, without editing the generated code. Might be a little awkward, but it works (in URP 7.2.1, 2019.3.3f1 at least).

Thought I'd share this, in case anyone else finds it useful. 🙂
Correction, this isn't the only method to obtain shadows. It's also possible to use this MainLight custom function instead, which rewrites what happens in Shadows.hlsl but bypasses the problem of keywords not being defined :
github.com/ciro-unity/Bot…
(not my code)
For this to work with shadow cascades line 18 should be replaced with :
half cascadeIndex = ComputeCascadeIndex(WorldPos);
float4 shadowCoord = mul(_MainLightWorldToShadow[cascadeIndex], float4(WorldPos, 1.0));
to bypass the cascades keyword in TransformWorldToShadowCoord
To add to this thread: not including the _MAIN_LIGHT_SHADOWS keyword actually strips all other keywords from the build so it must be included.

A much easier fix for the shadowCoord error is described in the tweet below. Also see: github.com/Cyanilux/URP_S…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Cyan ✨

Cyan ✨ Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Cyanilux

Apr 20, 2020
Hey all, wanted to share some info about how the shoreline shader is done. (This is a slightly simplified version).

(note : while it's based visually on the ACNH shoreline, it's probably not exactly the same way they are handling it) 😄

See thread!! 🌊🏝️ #unity3D #shadergraph
Firstly, the effect uses UVs, where the Y axis is towards the beach, and the X axis repeats around the island. Creating this was a manual process in Blender. Geometry with UV Y=1 appears as sand, and Y=0 as deeper water without the wave pattern.
For the ocean waves (lines) I'm using a Fraction node with the UV.y input to create a repeating pattern of lines, offset by time so they scroll and noise so they are wobbly.

Note the noise should be sampled using worldspace projected UVs so it tiles correctly (& has no seams).
Read 13 tweets
Sep 13, 2019
Saw a few others doing cloud shaders last week, so I might as well join in! Really happy with how this turned out. ☁️🌥️☁️ (See thread for #shadergraph + info) #unity3D #madewithunity #shaders
This is actually a fairly simple effect - It's a few Noise nodes with different scales & time offsets stacked onto each other, which are used to offset the Y vertex position of a plane. Also has a depth effect so it fades based on scene objects. Here's the #shadergraph
Note that there are some issues with this in the current LWRP version. In order to fix these I had to edit the code generated by the Master node - (right click the Master node and Show Generated Code. Then copy the file from the Temp folder into your Assets)
Read 8 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(