Ambient Occlusion in Editor

Hey all,

I’ve been poking around with ambient occlusion. I understand there was a recent addition to the engine in terms of AO that can be found here: PlayCanvas Examples

This looks like it will work well for my needs but it doesn’t seem to be possible in editor (no omni light, etc.). Is there an in-editor implementation of this or pointers on how someone would achieve that?

I believe @mvaligursky is the one who created that example. Maybe you have some pointers?

Thanks in advance,
Jake

2 Likes

Hi Jake … Omni light is a Point light - but those are not used for AO baking.

All functionality is there, but new properties as seen in the mentioned example are not exposed in the Editors UI, but you can easily set them using a script - assign some properties to either the scene, or a light, as needed.

Feel free to ask specific questions here as well to confirm it does what you need.

3 Likes

@mvaligursky Hey thank you so much for getting back to me.

I imagine I will have a few questions as I go forward with this. 1st Question:

Why do you need a UV1 for this? I don’t know how to set it up for my custom models but I’m sure that is just a google away so I’ll get on that.

non-overlapping UVs are required here, as for all lightmapping, and that’s most often not the case with UV0
https://developer.playcanvas.com/en/user-manual/graphics/lighting/lightmapping/#non-overlapping-uv

see more here for example Unwrapping UVs for Lightmaps | Unreal Engine Documentation

3 Likes

Thanks for the reply. So I am a bit confused on the setup here. All my models already have one UV set. Is the setup for this as simple as creating another UV set on the model and making sure that it doesn’t have overlapping UVs? I’ve got two uv sets on my model and it is still telling me UV1 is missing. Maybe you could point me to a model that has this setup correctly that I could investigate? I’m using Maya if that makes a difference.

yes, we have an open bug reporting uv1 is missing even though it is not. Ignore it. If you exported it, it should not be missing. When you’re baking lightmaps, keep an eye on the console logs - that would print out if uv1 is actually really missing. The ticket is here:

2 Likes

Oh awesome! Glad I asked instead of trying Blender :stuck_out_tongue_closed_eyes:

Got another hangup for you. Now whenever I enable Lightmapping on an object that does have a UV1, I get this error:

WebGL: ERROR: 0:445: 'dAmbientLight' : undeclared identifier

And here is the entire error from the console:


Any thoughts on this? Thanks for the help.

Not sure what the problem could be here … shader generation fails for some reason, but we have not seen that before in our test cases. Are you able to create a simple test project and share it with us to have a look?

Yes let me fork it and get that setup. One second.

There you go let me know if that works for you
https://playcanvas.com/editor/project/874794

what are the steps to repro? I don’t see the problem.

Oh interesting… What browser are you using? I am getting this on Safari but I just checked and am not getting it on Chrome. It happens on the launch of the game for me.

I tried both chrome and safari, and all is good. I tried forcing WebGl1 as well to test the case of Safari 14, and no issue there either.
But then I don’t see your scene being set up for lightmapping? Is that not what you’re testing?

When you say “set up for Lightmapping” do you mean anything other than enabling Lightmapping on the model? Sorry I forgot to leave the light mapping on when sending it to you which is what produces the error. It is on now. My bad…

I forked your project and enabled baking and that had no issue. So I cannot repro it.
You need to enable it on the render/model component and also on the light by the way,

Okay. So sorry to bother you again on the same issue but could you check on this published link? publicShaderErrorProj - PLAYCANVAS
I just had two other people check it at the office and they also got the errors (except their error numbers were 0:386 and 0:371).

In other news, it seems like the AO settings work regardless of the error. I do have one question though, is there a way to enable Global AO that takes into account the relationship between different entities? For example, a cube sitting on a plane. I’ve only been able to get it to apply to individual object. I am now noticing this might be the reason the example is only one object.

I don’t get any errors.

if you set up multiple meshes as receiving lightmaps, then AO is inbetween them - see some screenshots from the Editor here: https://github.com/playcanvas/engine/pull/2838