#any way to take the default lit shader and make it act like unlit?

1 messages · Page 1 of 1 (latest)

lone citrus
#

i want to have a shader that acts like unlit but wont break if i swap the shader on a material back and forth, only way i can think to do that is just take the normal shader and any code that makes it affected by lighting but the default shaders are very confusing to read to me so im pretty lost

raven flame
#

I think even with perfect black, lit materials still reflect some light

#

You can try using emission+black object perhaps

lone citrus
# raven flame What are you trying to achieve with this?

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

lone citrus
lone citrus
raven flame
lone citrus
#

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

acoustic gyro
#

What kind of "copying" are you referring to

lone citrus
lone citrus
acoustic gyro
#

I assume you mean changing shaders in editor only, not at runtime

lone citrus
#

it is at runtime yes

#

well, changing the shader a material uses at runtime

acoustic gyro
#

But I may misunderstand

lone citrus
acoustic gyro
#

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"

lone citrus
#

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

acoustic gyro
#

What properties specifically?

lone citrus
#

shader keywords is the one im having the biggest problem with

acoustic gyro
#

Which keywords specifically?

lone citrus
#

it seems to remove them from the list if the shader doesnt have them

acoustic gyro
#

"Cartoon kinda graphics" sounds a bit different than just unlit

lone citrus
#

flat graphics reminds of cartoon 🤷‍♂️

acoustic gyro
#

Which I'd guess means using the base map as emission map

lone citrus
#

i would like to have height and stuff if possible, its just ive only gotten test shaders to work with a base map

acoustic gyro
#

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

lone citrus
acoustic gyro
#

"Production ready shaders"

lone citrus
#

you mean this?

acoustic gyro
lone citrus
#

ohhhh, amazing ty

acoustic gyro
#

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

lone citrus
acoustic gyro
#

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

lone citrus
#

ohh that works perfectly i believe

acoustic gyro
#

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

lone citrus
#

yeah i think i see what you mean, just constant z fighting

acoustic gyro
#

HDRP's render passes are pretty complex though, so it's not always easy to parse

lone citrus
#

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?

acoustic gyro