#any way to take the default lit shader and make it act like unlit?
1 messages · Page 1 of 1 (latest)
What are you trying to achieve with this?
I think even with perfect black, lit materials still reflect some light
You can try using emission+black object perhaps
im wanting to swap every render's material's shader back and forth between unlit and lit while maintaining it looking decent-ish and not breaking, like height maps and stuff im not sure if thats tied to lighting but if so im fine with that being gone
i would be fine with it still reflecting light, although i feel like if i changed the code to remove lighting it would also remove reflected lighting
i did try this and just couldnt get it to work
Right I was thinking in terms of changing exposed material properties for a regular lit shader/shadergraph
You could try copying through the shader stuff in the second half of https://catlikecoding.com/unity/tutorials/basics/building-a-graph/
https://discussions.unity.com/t/how-to-write-unlit-surface-shader/45001 this could also be of help
yeah i have no problem making an unlit shader, it just doesnt have the keywords and properties that the default shader has, so when copied back and forth it loses infomation
im realizing i probably do just have to change the entire default shader code
Why do this?
Why would it "break"
What is it supposed to look like
What kind of "copying" are you referring to
im doing it just cause i want to
my understanding of it breaking is its losing infomation when changing the shader because the shader im changing to doesnt have those variables
i just want it to have support for alpha color and texture, and tiling and offset, if it loses everything that adds depth then thats fine to me
my understanding is when you change shaders on a material it copies the properties onto the new shader
I assume you mean changing shaders in editor only, not at runtime
I think the simplest option likely is to use a Lit material made to look like Unlit
You can achieve that with a mask map that has 1 on the red channel and 0 on all other channels, plus pure black base map/color
Emission map/color is then your "unlit" color
But I may misunderstand
same
Maybe you mean you want the base map/color or some other map to become the unlit/emission color instead? That's what I'm getting at with "why"
i mean literally like in editor when you just change it from lit to unlit, but still trying to keep properties so i dont need to store a big list of them in memory
the why is literally just because i want to do it, having a button that just changes the entire world from cartoon kinda graphics to realistic graphics is neat to me
What properties specifically?
shader keywords is the one im having the biggest problem with
Which keywords specifically?
it seems to remove them from the list if the shader doesnt have them
"Cartoon kinda graphics" sounds a bit different than just unlit
flat graphics reminds of cartoon 🤷♂️
Which I'd guess means using the base map as emission map
i would like to have height and stuff if possible, its just ive only gotten test shaders to work with a base map
The best path might be to get the node template of the HDRP Lit shader which has all the same properties and keywords, then just change what they do
Swap base color with emission, or anything else
yeah that would be perfect if that exists, though that link doesnt seem to contain it
It's a sample you can get from the package manager from Shader Graph's samples tab
"Production ready shaders"
you mean this?
ohhhh, amazing ty
After that I'd use the Custom Pass framework which specifically does shader overrides like this
Maybe can do the override from scripts too but that sounds tedious and then you may have to take care of material validation
ohh yeah instead of changing the materials shader just slap that on the object rendering it?
More precisely you target your Camera with a Volume that has this Custom Pass which renders your objects per layer using its override
Custom Pass articles in the docs although important are pretty dense, so this video may be helpful showing it in practice
https://youtu.be/vBqSSXjQvCo
It is old though, so some things may have changed
That's why shader override is missing from the video
ohh that works perfectly i believe
I've only done what you're now doing in URP so I don't know all the details
In URP the override renders objects anew so you had to take care to cull the objects from the camera first to not render them multiple times
May be different in HDRP
yeah i think i see what you mean, just constant z fighting
It may also be totally invisible, as they can be written over each other at different stages of rendering
The video points to this at least with the outline example, and shows the frame debugger which can be used to verify this
HDRP's render passes are pretty complex though, so it's not always easy to parse
so i have to cull everything to prevent it doing so? i didnt realize thats something you can just do
ohh you meant using the depth to do so right?
I meant that I don't know if Custom Pass when overriding a renderer changes how it's rendered, or renders it again
My experience with RenderObjects that's URP's equivalent feature to Custom Pass suggests it may be a command to render it again, after it's been rendered once unnecessarily behind it
But that may not apply here, something for you to test / look up