I am using URP and testing out some baked lighting (with the Progressive CPU Lightmapper in Subtractive mode). I have a couple of questions in which I hope someone could help me out with:
First of all, I cannot seem to get alpha texture masks (with alpha clip enabled) to cast shadows when using the ‘URP/BakedLit’ shader? It seems to create shadows from the polygons instead. However, if I use the ‘URP/Lit’ shader it casts accurate shadows from the alpha masks.
Essentially, it contains a tag that the colors are to be included in the transmission, rather than interpreting alpha as a lot of tiny holes in the material that let a portion of the light pass through the material unchanged.
Sure, I am attaching a small unitypackage which includes a scene, 3 gameobjects, 3 materials and textures. 1 ground mesh + 2 foliage/plants (one of which is mapped with Baked Lit and the other with Lit shader). Please let me know if there’s anything else you need to investigate what is happening.
Thanks a lot of the transmission shader example, I will have a look at this one today. It works in URP and baked lighting?
Thanks for the Transmission shader you shared out. It seems to do exactly what I wanted for baked lighting. However, is there any reason why the plane itself is pink even though it’s using this shader/cloth texture? Compile error for URP or? I tried the “Upgrade Selected Materials to UniversalRP Materials” editor function, but that didn’t seem to work.
And did you have time to have a look at the unitypackage I attached previously? Where the ‘Baked Lit’ shader doesn’t seem to take the alpha mask into account for the shadows?
Hm, good question. I wrote this originally for the built-in pipeline, would have to investigate what’s wrong with it in URP. My best guess is that the base texture (which should appear on the plane) uses the wrong keyword for URP.
By the way, the main color you’re setting up in that shader should modulate the transmission color of the texture (including the alpha value), try playing around with it.
Please try to rename _MainTex to _BaseMap in the shader code, as this is the canonical name of the main texture in URP, and see if the pink color is replaced with the actual texture.
I tried what you suggested to rename _MainTex to _BaseMap, but still renders as pink. So the Transmission map is what will be projected. What does the Alpha mask in the BaseMap do? Just controlling how much light passes through? I also noticed, when I change the Transmission texture and click Generate Lighting, it doesn’t update UNTIL you nudge the mesh (plane) a bit in the viewport, to force it to update.
I tried to recreate your Transmission shader using Amplify and I can see the Base texture now. But I still have the problem where BakedLit really doesn’t respect the alpha mask, so I get hard-edge shadows from the geometry instead.
Sob… anyway, I will look into this next week. I have a test project up and running and will fix this. Thank you for providing all these screenshots! I’ll write once I have a functioning result.
Yeah that is fine, I could probably just upgrade to the very latest version anyway. I have had some odd issues with baked materials, such as metallic objects standing out like a sore thumb in areas of shadows, etc. As if the lightmap doesn’t have any effect what so ever. And same goes for the environment reflections on certain angles (smoothness fresnel). In shadows they still appear super bright. If I can’t figure out a way to fix this, I might ask for help on the forum.
Hi ,thefranke
My project is facing the same baked lit - alphatest trouble in Unity 2019 - URP , though we are using our custom lit Shader.
I wonder how you fix this bakedlit shader , could you please explain a little more details in codes at what you did?
I looked through 2020 bakedlit (which is correct) and 2019.3 bakedlit(which is wrong) , but i couldnot found what the magic you did to fix this bug.
Much Appriciated if you reply!