Hi, thanks for that suggestion. I tried disabling and using my own UVs, and that helped the “all black” problem.
But, I’m still having trouble baking out my Shader Graph. I’ll explain below. Any help would be very appreciated, thanks!
I have a pretty simple “toon shader” that uses a Custom Function to get GetMainLight() and then draws a shadow based on attenuation. It then multiplies this with the mesh’s vertex colors and puts it into PBR’s emission value. All other PBR values are 0.0 or black. This produces the correct effect using realtime lights.
Then, to bake, I switch my single Directional Light to “Baked”, turn on Baked Global Illumination and set the mode to “Subtractive.”
-
After baking, the lightmaps don’t get used, because I’m using emission and not albedo. If I switch to albedo, then I do see lightmaps. I can also fix this by adding the “Backed GI” Shader Graph node and multiplying it with my emission value, just before I connect it to the PBR. So far so good, but…
-
The lightmaps don’t look anything like my shader.
-
Do I need to define the meta pass somehow? I tried adding a custom function that passed the shadow color calculation into albedo if LIGHTWEIGHT_META_PASS_INCLUDED was defined. But that didn’t help. I also just hooked up my shader to albedo instead of emission to see if that fixed the baking, but it didn’t.
So, I guess my question is: Is there any way to bake my stylized shadows into the lightmap using Shader Graph, so I can just use the lightmap texture directly?
Or do I somehow need to pass the lightmap-texture samples I have now, through my shadow-node system? So, like, replacing the GetMainLight() part with the lightmap texture somehow?
Screenshots of everything below. Thanks!
REALTIME LIGHT
BAKED LIGHT
SHADER
THE CUSTOM FUNCTION
void MainLight_half(float3 WorldPos, out half3 Direction, out half3 Color, out half DistanceAtten, out half ShadowAtten)
{
#if SHADERGRAPH_PREVIEW
Direction = half3(0.5, 0.5, 0);
Color = 1;
DistanceAtten = 1;
ShadowAtten = 1;
#else
#if SHADOWS_SCREEN
half4 clipPos = TransformWorldToHClip(WorldPos);
half4 shadowCoord = ComputeScreenPos(clipPos);
#else
half4 shadowCoord = TransformWorldToShadowCoord(WorldPos);
#endif
Light mainLight = GetMainLight(shadowCoord);
Direction = mainLight.direction;
Color = mainLight.color;
DistanceAtten = mainLight.distanceAttenuation;
ShadowAtten = mainLight.shadowAttenuation;
#endif
}