APV not baking shadows on URP

Man, i have to admit i’m really bad with APV -.-"
So, i’m tried APV on URP with my main project on Unity 6 (just testing to see if i can update it to Unity 6), but it sks, is not baking shadows, i already did what the documentation says, i tried some settings from some posts, also some youtube videos. everything is on “Light probes” APV is active on “project settings > blablabla > Light probe lighting” Even with Min probe spacing at .01 and at 0.9 i get this:

There is a Directional light (mixed)

Probes

There is also this bug( ? )
hg

APV for me is always a complicated weird thing that never let me satisfied -.-

So, you want shadows cast by the directional light, from the tree, onto the ground plane?

Setting a light to mixed means to bake direct contribution into probes. How shadows are handled depends on your chosen Mixed Lighting Mode.

If you are using baked indirect mode, you’ll never get baked shadows - static objects will only cast realtime shadows.

If you are using shadowmask or subtractive mode, you will get baked shadows. In shadowmask mode you only see the baked shadows by default after a certain cutoff distance, otherwise the shadows are realtime. This is known as distance shadowmask mode.

In other words, if you want shadows baked into probes, use subtractive or shadowmask mode. If you only want realtime shadows, use baked indirect. Other than that, make sure the tree and plane are marked as static, and that both the light and tree have shadows enabled. If you’ve done all that and it still isn’t working, let me know.

As for that bug you show - haven’t seen that before. Feel free to submit a bug report. Looks like it could be an issue with streaming (are you using disk/gpu streaming?)

Hope this helps

To me it looks like the scene isn’t baked at all.

Part of it is the density isn’t collected around the objects you have.

I also tried with the directional light mode at Baked, I also tried Shadowmask and Subtractive and i got the same results, also, the tree and the plane are marked as static.
The camera is very close, that’s not a tree, it is a bush, for reference here is an image with a placeholder for cars

That is just a test scene, an scene i use to try new stuffs without breaking my main scene

Ahmm…

Baked:

Not Baked:

Yeah that’s just baking the skybox info, in newer versions of unity the ambient light is not baked automatically.

Something is wrong in the setup. Especially if the ground is included.

I would try smaller scale scene until you figure out the problem.

Update:
Wouldn’t that supposed to be shadows there on the grey probes?

Oh yeah that looks more correct…
Are the shaders custom? Maybe they don’t support APV? Or maybe don’t support Vertext or Pixel mode?

Actually maybe it’s on vertex mode, and you don’t have enough polys to cast shadows

Wait, i forgot to reply:

Ok, so, i went to enviroment and i put all colors on black, i’m not using skybox material either and this is the result:


Is the same

Is there any other settings for enviroment on unity (i would not be surprised if it is -.-)
BTW; shaders are simple lit

My theory is you’re using vertex mode and don’t have enough polys on the ground to get shadows

Toggle advanced properties and change the SH evaluation mode to pixel.

1 Like

Advance pro giga chad user right there… thanks @sacb0y
now, i have this pretty ugly dithering noise, any chance you know why? or how to get rid of it?

it’s worse in editor view than game view, I think another thread went over how to smooth that out cause it depends on needs.

You might want to use Volumes or APV adjustment volumes to correct it.

1 Like

Just a quick question, is there a way to change all my objects to recieve GI from lightmaps to light probes at the same time? because, you know, i have lots and lots of objects in the scene, all prefabs are “lightmaps” but the objects in the scene are “light probes” and now, i want to going back to “Lighmaps”
Is there a way to do it for lots ob objects at the same time?

I didn’t wait and i asked Chatgpt to make me an script for that, it appear on the top menu, on Tools, there are two options: Set GI to Light Probes and Set GI to Lightmaps.

If you need it (edited for unity 6):

using UnityEngine;
using UnityEditor;

public class SetLightmapGI : EditorWindow
{
    [MenuItem("Tools/Set GI to Lightmaps")]
    public static void SetGILightmap()
    {
        // Get all the objects in the scene
        GameObject[] allObjects = FindObjectsOfType<GameObject>();

        foreach (GameObject obj in allObjects)
        {
            Renderer renderer = obj.GetComponent<Renderer>();
            if (renderer != null && renderer.gameObject.activeInHierarchy)
            {
                // Set "Receive Global Illumination" to Lightmaps (1 in Unity 6)
                SerializedObject so = new SerializedObject(renderer);
                SerializedProperty receiveGI = so.FindProperty("m_ReceiveGI");
                if (receiveGI != null)
                {
                    receiveGI.intValue = 1;  // 1 corresponds to receiving GI from Lightmaps
                    so.ApplyModifiedProperties();
                }

                // Ensure the object is marked as Static for GI contribution
                StaticEditorFlags currentFlags = GameObjectUtility.GetStaticEditorFlags(obj);
                currentFlags |= StaticEditorFlags.ContributeGI; // Keep Contribute GI checked
                GameObjectUtility.SetStaticEditorFlags(obj, currentFlags);
            }
        }
        Debug.Log("All objects set to receive GI from Lightmaps.");
    }

    [MenuItem("Tools/Set GI to Light Probes")]
    public static void SetGILightProbes()
    {
        // Get all the objects in the scene
        GameObject[] allObjects = FindObjectsOfType<GameObject>();

        foreach (GameObject obj in allObjects)
        {
            Renderer renderer = obj.GetComponent<Renderer>();
            if (renderer != null && renderer.gameObject.activeInHierarchy)
            {
                // Set "Receive Global Illumination" to Light Probes (2 in Unity 6)
                SerializedObject so = new SerializedObject(renderer);
                SerializedProperty receiveGI = so.FindProperty("m_ReceiveGI");
                if (receiveGI != null)
                {
                    receiveGI.intValue = 2;  // 2 corresponds to receiving GI from Light Probes
                    so.ApplyModifiedProperties();
                }

                // Ensure the Contribute GI checkbox is still checked
                StaticEditorFlags currentFlags = GameObjectUtility.GetStaticEditorFlags(obj);
                currentFlags |= StaticEditorFlags.ContributeGI; // Keep Contribute GI checked
                GameObjectUtility.SetStaticEditorFlags(obj, currentFlags);
            }
        }
        Debug.Log("All objects set to receive GI from Light Probes, with Contribute GI intact.");
    }
}


1 Like

So how I think they expect you to do it instead is to hit the drop down menu on the right of the bake button when I the APV tab to bake only APV.

But this is silly and also doesn’t work properly (currently it won’t flag lights as baked).

I’ve been working around it by disabling baked lighting in the light map panel before hitting bake. But that’s also silly.

The bug with the drop down has been reported and confirmed, I hope they just fix it and make a proper button or something by Unity 6 release.

Your method also works XD.

Sorry i don’t understand… Are you talking about the script i shared? The only options i have on Unity 6 on that drop down menu are: Bake Probe Volumes, Bake Reflection Probes and Clear Baked Data (which i just selected by error -.-" XD)

I was talking about this drop down menu on every asset

sdasda(1)

Nice catch with the vertex sampling, @sacb0y ! :slight_smile:

@impheris

i have this pretty ugly dithering noise, any chance you know why? or how to get rid of it?

The dithering noise is to make the transitions between neighboring bricks with different values less harsh. You can adjust it or remove it using a volume with some overrides.

image

Keep in mind that baking direct occlusion into probes (ie. using subtractive or non-distance shadowmask mode) will always look a bit blocky, since direct occlusion is a high frequency signal, but is being quantized to the probe grid. You can see what I mean by using the “Probe Occlusion” debug mode in the rendering debugger:

Baked probe occlusion is most suitable for distant objects. If you need more crisp shadow penumbras, you can either:

  • Use a lightmap on the relevant surfaces
  • Lower the min probe spacing by a lot
  • Use realtime shadows

I don’t know if you remember a previous posts when i was trying APV on 2023 (i think) you said that i can use a mixed between lightmaps and APV, well, that’s what i’m doing now and yes i need not exactly perfect shadows because is not a realistic style, is more like toys, but the ones with APV are pretty blocky and ugly imo XD… I tried the “Sampling noise” thanks, i didn’t know about that, but is still bad:

This is Min probes spacing at 0.1, Lightmaps size: 1024 and resolution: 40


The only way that i can get rid of those blocks is if i increase to almost max that “Sampling Noise” property but is too much noise and not even Blurred Antialiassing (TAA) at maximun can work with it haha, so that’s the best i can get with APV

This is lightmaps 512 size:

I can use an higher angle on “baked shadows angle” on the light properties, but it then lacks details and the shadows from buildings looks really bad.

So, is there a case where backing shadows with APV is good? as you can see i’m pretty noob with APV i’m probably missing something or maybe APV is not useful for shadows… ? Thanks in advance.

So, is there a case where backing shadows with APV is good? as you can see i’m pretty noob with APV i’m probably missing something or maybe APV is not useful for shadows…

Baked shadows with APV don’t look great up-close. Initially the system didn’t support them at all, but I implemented it since it’s better than the alternative - no shadows at all! Subtractive and Shadowmask mode mean to bake shadows from mixed lights either into probes or lightmaps. Before APV supported this, these shadows would simply be missing and affected objects would be fully unshadowed.

Personally I would only recommend using baked shadows in APV with distance shadowmask mode. This was the primary intention: Close to the camera, you use crisp realtime shadows. Far from the camera, you use the more blocky shadows from APV. But since the affected objects are far from the camera, it doesn’t matter so much that the shadows are blocky.

If you can’t afford realtime shadows, your options are to either accept the inherent blocky-ness or to use lightmaps. Depending on the style of your game, you may also be able to mitigate the blocky-ness a bit with vertex sampling. That should smooth out the shadows a bit but in turn also lower their fidelity. Same goes for baked shadow angle as you have noted.

1 Like

The reason I write “inherent” blocky-ness is because this is a consequence of quantizing direct occlusion to a sparse grid, you will get this kind of aliasing. Direct occlusion is a high frequency signal (it varies a lot spatially). It’s kind of like trying to get crisp baked shadows on a lightmap with super low resolution.