#Lighting Issues within URP in Unity

1 messages ยท Page 1 of 1 (latest)

storm barn
#

How can i show you what you need to see?

near moon
#

You can select your lights in the scene hiearchy and in the inspector itll tell you the modes

#

Thsts the light type, not the mode

feral sparrow
#

"scene turns dark on scene change" is fixed by generating ambient lighting for a scene
baked lightmapping is not necessary for it

storm barn
#

I got you, sorry, its been a long day:

#

Ok, i'll look up generating ambient lighting as well, Thanks for the tip Spazi

near moon
#

Back sorry, was in the middle of something

#

So you have lights set to mixed which means they'll get included in the bake

#

Which is good

#

I suppose the next thing to do is to configure your lighting settings

#

Then doing a bake and see what comes up @storm barn

#

so for your scene creating a lighting settings asset is needed

#

and to speed things up i'll just list off what to tick (these can be changed later of course)

#
  1. set lighting mode (which is under mixed lighting) to subtractive
  2. under lightmapping settings set the lightmapper to Progressive GPU
  3. tick off progressive updates
  4. set direct samples to 16
  5. set indirect samples to 32
  6. set enviorment samples to 32
  7. set filtering to advanced
  8. for each of the denoising types that pop up set them to open image denoise
#

again, all of these can be changed and configured later, but basically just doing a somewhat low res lightmap to see how things look and what issues come up so we can fix them

storm barn
#

Ok 2 ticks and i'll try this, when i was searching about ambient lighting i stumbled across a post that said that it only happens in the editor, and not when its built, i wanted to see if that was apllicable.

#

nearly finished building

#

Hmm, something isnt right here! - didnt restart the scene at all in build mode, yet it invoked the screenfader.. in editor.. restarts but turns everything dark

#

So, onto your solution and then i'll check that out later

#

I dont see a denoise option for any of these drop downs:

near moon
#

those are the denoise options

#

open image denoise

#

for both Direct Denoiser and Indirect Denoiser

storm barn
#

Yep got that.

#

now generate?

near moon
#

yep

storm barn
#

ooh, i just got this i need to change the other scene to this setting, question is, will that affect this light generation?

near moon
#

no it wont

storm barn
#

ok comp is working really hard so i'll give it two mins to complete

near moon
#

you can drop the sample counts numbers even lower if you want it to go faster

#

i.e. instead of 32 can just drop to 16

#

but worth nothing that depending on how the scene looks this can sometimes lead to noisy results, but those can be fixed with denoising/higher sample counts

#

currently right now its just prioritizing what the baked lighting will look like roughly

#

and adjust/tune/fix issues until it looks good

storm barn
#

Its finished and it looks good!

#

lets test it ๐Ÿ™‚

#

Just snacking, back in 5, and again, really appreciate your help, thank you

near moon
#

screenshot?

storm barn
#

Getting some strangeness actually:

#

i changed all the floor tiles to cast shadows no before the bake thinking about it

near moon
#

I saw some lights you have aren't casting shadows also

#

whoops worded that wrong, fixed it ๐Ÿ˜›

storm barn
#

Hmm

near moon
#

but lights that don't cast shadows will be treated the same in lightmaps, but since your baking them I'd go ahead and enable shadow casting on all lights

#

I wouldn't worry about the overlapping UVs, I never found those warnings to be much of a problem

storm barn
#

Ok ill do that now

#

Like here?

near moon
#

yes

storm barn
#

This is what i have, it looking right?

near moon
#

mhm

storm barn
#

K, now all changed, bake again?

near moon
#

yes

#

thats the downside of lightmapping, any changes made to lights need to be rebaked

storm barn
#

it destroys my computer, slow to move mouse, slow to type. need to upgrade

#

Ok, not as bright.. but this discolouration of some of the textures is strange:

#

If i click on both a light tile, and a darker tile, they both the same values, materials, everything.

#

spotted something

#

Darker tile has this lightmaps tab:

#

lighter one doesnt have it:

near moon
#

yep thats about right

#

since there is a lightmap and even after adding shadows, none what so ever only leads me to believe that most of your scene objects are not actually marked contribute GI in the static flags

storm barn
#

And i take it they need to be then

near moon
#

yes

#

very much so

storm barn
#

So i could select the full enviroment prefab i created and change those?

near moon
#

I'm not sure how your scene is setup but all I can tell you is that most of your meshes (those that are not dynamic or moveable props) should be marked static

storm barn
#

I see, you mean here:

#

They are for the navmesh?

near moon
#

nope

#

you can also mark it on the top right in the inspector when an object is selected

storm barn
#

So pretty much, i would just go anything Static, contribute GI right?

#

walls, roof, everything?

near moon
#

yes

storm barn
#

Ok

near moon
#

if its not marked static it won't be included in the bake

storm barn
#

It was already ticked

near moon
#

tick it again

#

should override

#

the general rule of thumb I tell everyone for lightmapping, mark everything static that isn't dynamic (i.e. doesn't move, get destroyed/disabled/hidden) because again if it isn't the lightmapper is never going to see it

storm barn
#

Ok, but you are right in that most of the floor tiles do not have "Contribute" In the compnent tickbox

#

Ok, so i disabled, and renabled it

#

before i bake im sensing i should allign all objects to have contribute ticked in their component properties

near moon
# near moon

that field should be ticked automatically honestly when its done through this menu

storm barn
#

You're right it did, all ticked

near moon
#

but if you want to be certain

storm barn
#

so rebake now

near moon
#

you can go by hand and double check if you want to be certain

storm barn
#

screw that

#

๐Ÿ˜„ i trust you

#

K, Baking, back in 4

#

350 objects with overlapping UV's lol

near moon
#

I wouldn't worry so much about it, generally in my experience the only time I've had issues with overlapping UVs are with complex objects that I auto generated lightmap UVs for in unity where sometimes you'll get random black/white texels and sitching issues, but there are ways to get around it

storm barn
#

Ok, so the floor is evenly coloured but looks more duller than id like, i guess i can fix that in material. but.. some of the walls in one room appear very black:

#

They're all supposed to be the same material/colour

near moon
#

something is still wrong... there is still tons of light leaking through

#

are you sure they are all marked contribute GI static? and are casting/reciving shadows?

storm barn
#

I did just notice a small gap in the roof

#

between the window and the top plane

#

Ah..

#

no its a cube.. i was thinking Plane only render one side dont they.. but its a cube so its not that

near moon
#

are you sure your lights in your scene are casting shadows?

storm barn
#

cAsting shadows and Contribute on

#

was before last bake

near moon
#

static shadow caster is off

storm barn
#

Ahh crap

#

was that it?

#

So fix that for all walls

near moon
#

either that or you still have tons of lights in your scene that aren't casting shadows

storm barn
#

Im pretty sure all lights were sorted and youre right there were plenty of walls without static shadows

#

rebake again

#

Rebake present the same results:

near moon
#

confused but have some solutions in mind, first off do your meshes all have auto generate lightmap uvs enabled?

storm barn
#

Im looking in the mesh components and i dont see that setting?

#

Got it, was ticked:

#

No thats optimise you said auto-generate

#

I think we can assume they all have these settings:

#

I guess "Generate"?

#

Tickign that Generate bock made them look hoorendous:

#

But i havent rebaked..

#

You know you said about light leakage? there are gaps in the windows, you can see light leaking through the bottom, do you think that could be it?

near moon
#

sorry

#

was doing something

storm barn
#

Rebake with all of those checked right? Generate Uvs..

tame root
#

Looking at those last images I think the geometry may have some serious issues with texel validity, especially the walls.

storm barn
#

Probably.. i modelled them in blender...

tame root
#

What that means is that some of the faces may be backwards

storm barn
#

thinking about it i could switch them for cube objects

#

and resize/scale

tame root
#

Ah! Okay can you go and solidify them

#

You have the right idea here

storm barn
#

I'm actually terrible at Blender and havent used it in a long time, i mean, effectively thats import and add solidify modifer, right? i could do that. do i just take Solidify at its default settings?

#

clueless at this, even more so when it comes to Unity

#

Blender i mean!

#

long day..

#

instersting observation, since ticking that box and re-baking, the overlapping UV's as decremented by 50%

tame root
storm barn
#

Rebake:

#

I'll switch those walls out for Cubes and see if that helps

tame root
#

At the top of the scene view can you click that moon-looking icon and select Texel Validity from the list?

storm barn
#

its weird how the other walls are fine though? around the lebel

#

level*

#

It seems attributed to direction of light

#

bout outside all around the back

tame root
#

Maybe you just have no indirect light in your scene

#

Are those light probes?

storm barn
#

Directional light here?

storm barn
tame root
storm barn
#

Waypoint markers for mesting AI navmesh

#

i just had a little sphere model on them so i could see them ๐Ÿ™‚

#

No sorry!

#

that one is a bowling ball

tame root
#

Okay great

storm barn
#

With my mates face on it:

tame root
#

I love my job

storm barn
#

I love this community tbf.. cant believe how helpful everyone is

#

Makes it easy to want to jump aboard the train really

tame root
#

Yeah it's pretty great!

#

Okay so did you change the env lighting to have a 0 indirect multiplier?

#

In the settings you showed above

storm barn
#

Ahh you could be onto something here

tame root
storm barn
#

0 , 0

tame root
#

Go for 1 let's see what happens

storm barn
#

Rebake on change?

tame root
#

Yes

storm barn
#

Ok, 5 mins, potato laptop

tame root
#

And I guess the skybox color should also have indirect intensity 1? Did you change that intentionally?

#

You can also make bakes faster by reducing the Lightmap Resolution and Max Size (you don't have to bake 4K Lightmaps while we troubleshoot)

storm barn
#

Ok will do! lol. every day is a school day ๐Ÿ™‚

tame root
#

Those are in the Scene tab in the Lighting Window

storm barn
tame root
#

happens to all of us, no worries

storm barn
#

Sorry which settings to reduce?

#

lightmap res currently at 40, should i put 5 for now?

tame root
#

Yeah that should be ok

#

It will be a little blurry but much faster

#

And max lightmap size at 512 looks good, nice UnityChanThumbsUp

storm barn
#

So rebaking at those settings again

#

though after the bake just done, still the same black walls

#

intensity now at 1 as well

#

for this new bake

tame root
#

Can you focus the scene view on that wall

storm barn
#

jesus thats almost instant

tame root
#

Select the object and look at the inspector

storm barn
tame root
#

There should be a Baked Lightmap thumbnail, click on it (In the inspector window to the right)

storm barn
#

Yep links over here:

tame root
#

Can you go back to the Lighting Window and uncheck "Realtime Global Illumination"

storm barn
tame root
#

It's at the top

storm barn
#

Done and rebaked:

tame root
#

okay can you show what material you're using for this object (in the meshrenderer)

storm barn
#

I tried a different material before this hoping that would fix it

#

same result

tame root
#

Can you select Render Face "both"

#

(and rebake)

#

you're sure that the model has "Generate Lightmap UVs" checked right?

storm barn
#

I did a cube with the same texture as well in the test:

#

Baked a cube in with the texture and it looks fine

#

I sleected all my models and clicked Generate UV's

#

that was done in Davids advice previously

#

i could progress with the cubes for these walls but the glass ones.. could really do with fixing those

#

Internally, a slightly weirder output

tame root
#

It looks like that because of the lower resolution

#

In this view can you go to the Texel Validity mode again?

storm barn
#

no materials on these ones:

#

yeah thats eye bleach:

tame root
tame root
storm barn
#

So i can't really use these models without fixing the backfaces?

#

Its the same here though:

tame root
storm barn
#

Yet it looks exactly as id like it do:

#

Thats what i cant get ๐Ÿ˜‚

#

All the way around:

#

Then that corner.. dark

#

Office next door starts getting darker:

near moon
#

wait...

#

you have a directional light in the scene yes?

storm barn
#

Yep

near moon
#

whats the shadow strength

storm barn
near moon
#

aaaah

#

the directional light is only realtime

#

make it mixed

#

and do a quick bake

tame root
#

๐Ÿ˜‚ I thought it was set above I was just scrolling to see that

near moon
#

yep me too lol

tame root
storm barn
#

That did make the scene a tad brighter:

near moon
#

did you do a bake?

storm barn
#

yes mate

near moon
#

is your roof marked static?

storm barn
near moon
#

hmmm

storm barn
#

Could for good measure do a untick/retick on all if you think it could help

near moon
#

can you switch the scene to baked lightmap view

storm barn
near moon
#

turn off the checkerboarding pattern

#

which should be at the bottom of the menu of scene modes

storm barn
#

Still in this menu?

near moon
#

yes

#

I can sort of see that the lightmapping is working

tame root
#

"Show Lightmap Resolution"

near moon
#

which tells me a few things

#

we might need to switch the mixed lighting mode

#

orrr

storm barn
near moon
#

switch the lights to fully baked modes

#

yeah so that confirms some of my suspicions

tame root
#

Most of the light you have in there is realtime direct light then

near moon
#

yep

storm barn
#

Did you mean from components sorry?

#

or lighting inspector?

near moon
#

the lightmapping window

storm barn
near moon
#

yeah thats one way to do it

tame root
#

So I am seeing a bit of a fundamental issue with how this is set up, which is that you are using one light from the outside to light the entire scene through windows

#

Do you have any more lights?

near moon
#

he has alot of localized ceiling lights which hes showing off there

tame root
#

Ah sorry

near moon
#

one note also, for some of your ceiling lights make sure they are not placed inside objects @storm barn

#

otherwise they will be occluded

storm barn
#

Ok

#

so did another bake after changing to Baked:

near moon
#

probably because the lights are occluded like I just mentioned

storm barn
#

how would i verify that please?

near moon
#

select one of the ceiling lights, press f or double click in inspector and check its position

#

if its inside the ceiling light mesh

#

its being occluded

#

the position of the light that is

storm barn
#

Reemmerb i still had realtime off from when Girgo asked to untick:

near moon
#

yeah thats fine

storm barn
#

kk

#

Like that you mean?

#

beucase its sat inside it a bit?

near moon
#

thats the mesh, not the light

storm barn
near moon
#

yep

tame root
#

bingo

near moon
#

called it

#

so to fix it either 1. unmark the lightbulb mesh as contribute GI or 2. move the light so its not inside the mesh

storm barn
#

Ok but these lights are duplicated all over the level, wouldnt we see similar issues on other walls?

near moon
#

potentially

#

depends where the lights are placed

tame root
#

I think that you need to block the realtime light from your directional

#

It's the model that's at fault here I think and it's causing all the weird artifacts

storm barn
#

When i went to untick that, it asked to change children

#

i guess not?

near moon
#

the child object is just the light so it doesn't matter

storm barn
tame root
near moon
#

the light at the end of the tunnel

#

its in sight

#

๐Ÿ˜›

storm barn
#

LMFAO

#

How much you want

#

take my money

#

Thank you SO much!

near moon
#

the problems are not gone just yet though

#

still have some issues left

#

for one that directional light

storm barn
#

werid stuff still to look at but i bet its not the same issue

near moon
#

so I would actually start by disabling the directional light

#

and tune your local lights and make sure they are actually working first

#

and doing some iterative bakes

#

making sure of course each light you have placed is actually being cast and not occluded

storm barn
#

Disabling directional makes it look even weirder:

tame root
#

Disable and bake

storm barn
#

Yeah i made sure to change every lightbulb when you said the solution

near moon
#

see a couple of things going on, the obvious being the low lightmap resolution but that makes sense with what im seeing, but I'm seeing alot of ambient light + the skybox reflection

#

can you disable your enviorment reflections for now?

storm barn
#

Spaced out a few lights:

near moon
storm barn
#

changed to this

near moon
#

I would just drop the intensity multiplier

tame root
#

We turned that up before, I suppose it should be turned down for now. I really thought this was a one-light scene ๐Ÿคท

near moon
#

yeah I don't blame you lol

#

but yeah enviorment reflections off and at 0

#

so we can hopefully look at just the diffuse lighting

storm barn
#

.5? or all the way?

near moon
#

0

storm barn
#

K

near moon
#

with it how does it look now

storm barn
#

Currently set at this pre-bake

near moon
#

you don't have to rebake when changing those

storm barn
#

Ah ok

near moon
#

there we go, so we can see the ugliness more clearly, thats good

#

lightmap UVs front and center seem the be the biggest issue here

#

are you auto generating them for your meshes?

storm barn
near moon
storm barn
#

you mean like this?

near moon
#

yes

#

hmm

tame root
# storm barn

from here it looked like the UV scale is quite off, right?

near moon
#

true it does look inconsistent

#

though im more confused by the walls/ceiling and how they seem unaffected

#

they look completely unlit

#

what shader are you using on them?

storm barn
tame root
#

URP lit I believe ^

storm barn
#

Yep!

near moon
#

thats for a floor tile, not the walls/ceiling

storm barn
#

O....M....G

near moon
#

?

storm barn
#

No materal/Shader

#

i guess thats why its unaffected

near moon
#

no thats just the parent you have selected

#

there are children objects for it

storm barn
#

im tired, sorry daved

near moon
#

its ok lol

storm barn
#

David*

near moon
storm barn
#

I mean, i sleected all materials and did the "Convert to URP" when i had all the pink issues

tame root
#

The wall not the window ๐Ÿ˜‚

storm barn
#

so they should all be using the same shader

tame root
storm barn
near moon
#

so that confirms that

storm barn
near moon
#

worth mentioning a bit unrelated but when it comes to modular meshes like I see how your environment is constructed in the future I would avoid that since you can run into alot of lightmap seam issues

#

but anyways

storm barn
#

Yeah i didn't know anything i just dove in. How would you do it? like long cubes for a wall and just change tiling offsets for material?

near moon
storm barn
#

Fair enough, i should read up on some level design really

near moon
#

so now that were here

#

go back to the baked lightmap view

#

I wanna see how the area looks

#

even though we can sort of already see it I wanna verify some things

storm barn
#

Thats not offering much:

near moon
#

your sure your not inside the ceiling?

storm barn
#

Exact view:

near moon
#

move the camera lower

storm barn
#

ffs...

#

whys that do that!?

near moon
#

you did mention your celing was a cube

#

in baked lightmap view there is no backface culling for a reason

storm barn
#

Aaah ok

near moon
#

so good news is I can see its working

#

some obvious low sample ocunts and low resolution artifacts but that is to be expected

#

no directional light though

#

but we did disable that

storm barn
#

thats still disabled

#

yep

near moon
#

can you do another bake?

#

but double your lightmap resolution?

#

not the atlas size

storm barn
near moon
#

now do a bake

storm barn
#

New reuslt:

near moon
#

can you deselect the floor

storm barn
near moon
#

the highlight gizmos are sort of in the way

#

yeah there we go

storm barn
#

stitching issues you was referring to it looks like

#

leaky

near moon
#

yep

#

thinking...

#

the brighter areas look decent

#

don't see too much issues there

#

its just the floor meshes that are a problem

#

re-enable the checkerboard pattern

storm barn
#

Learnt a lot tonight!

tame root
#

Can you reduce your indirect filter to 2

#

Aggressive filtering can lead to leaking

storm barn
#

Done that and rebaked:

tame root
#

Hmm can you go back to the texel validity mode?

storm barn
near moon
#

could try something actually...

#

can you do us a favor and zoom out to show your whole scene?

storm barn
near moon
#

one thing I've typically done with interior scenes to stop leaking is to encase them in large oclcuding cubes/meshes

#

that are quite thick

storm barn
#

That sounds really clever i have to admit

#

so, do a massive cube? that encases the scnee?

tame root
#

More like 6 cubes

near moon
#

^

tame root
#

Because if you do one the inside of it will be backfaces which is bad news

near moon
#

think of it like housing the scene in a cardboard box, its not completely solid inside

#

now granted

#

your scene has windows

#

so you'll have to model your blocker mesh around that

storm barn
#

Got ya

tame root
#

That's why I recommended doing the solidify before

storm barn
#

This is going to be something i have to pick up tomorrow gentlemen, if i yawn anymore i'll swallow my tongue ๐Ÿ˜‚

#

I'll encase it in the 6 Cubes like you said tomorrow

tame root
#

Get some rest! Great work with the project so far ๐Ÿ™‚

storm barn
#

Thanks guys! - really appreciate the support!

#

I'll be on in the morning, not sure about you guys ๐Ÿ™‚

#

cheers!

near moon
#

just a quick example to show you when you get up later to show what an exterior solid mesh can do for an interior scene to alleviate light leaks

#

and another

#

worth showing this since this solution in some instances like you can see won't completely 100% alleviate light leaks but it can help quite a bit

#

example of a blocker

#

doesn't have to be this messy, but just an example

storm barn
#

Thanks David, and good morning both!

Up a bit earlier than i like, wind decided to throw a bin at my house and it woke me up.

Wasn't a great start, i got to my laptop and as soon as i touched it, it crashed... and heres the clanger.. i disabled the autosave script thinking it was causing an issue, forgot to re-enabled it when i ruled it out.

Lost all changes..

Anyway.. loaded it up this morning, changed all the lightbulbs again like you suggested and tinkered with light according to yours and giorgios latest.

Here is the miracle part.

I fixed the SceneLoading Issue at build, i changed the scene name and forgot to update it. I then checked position of directional and it was semi inside the roof and too close to the building. So i moved it around the side to where the faces were blackened:
and Voila, It looks Ok.

Play, restart, looks ok. Build, restart, looks Ok.

Absolutely clueless, and astounded, as to how this issue has gone away. But Grateful none the less!

It isn't perfect, but its a first project for me i only started a few weeks ago. (i modeled the pieces a year ago, spent 2 weeks in unity and gave up) Its just a mock up of my office at work so i can have some fun with it and test my capabilities.

I'm hoping i can make something semi-comical, and use it as some team-building exercise when i'm out visiting teams ๐Ÿ™‚

I would again, like you sincerely thank you for the amount of time you spent with me on my issue, i recognise thats some serious dedicated time out of your life! - Happy to throw you a few beers! - DM me an email address and i'll paypal, it won't be much i'm not rich though lol.

tame root
#

That is quite the story, very happy to hear it all worked out! Kudos to you for persevering and seeing this through despite the issues.

#

As we sometimes say, Unity works in mysterious ways and I am glad it chose miracle today ๐Ÿ‘ผ