Giter Site home page Giter Site logo

Comments (25)

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024 1

Working on adding those now. Got a lot of random stuff being exported with the prefabs from my main project so I'm working on cleaning that up as I bring them over into this demo repo

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024 1

You are welcome, and let us know if you get some clarification from Unity or find out a good solution : )

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Ok so, I don't understand exactly when the issue arises? Is it only when instantiated on its own as a GameObject? Can you share the code for how you load it vs for how you load it when it works?

-"If I load a scene via an Asset Bundle with the prefab already instantiated inside of it, then the lighting will look correct (although I am seeing that the prefab will lose its static tag)." < This is normal, its the way it works for instantiating scenes through bundles but it still behaves as static (having combined meshes etc)

Is the project where you use the Asset bundle the same as where you make the assetbundle?

Also can you share some info on Unity version, Render pipeline, etc

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

Hi, thanks for the quick reply. I'm running this on 2019.4.26f1 with URP.
As for how I'm using the prefabs with the baked lighting... I currently have an initialization scene with nothing but a loader script which takes a scene from an Asset Bundle and loads that scene. From there, that loaded scene then asks for prefabs from another Asset Bundle to be instantiated. I want to move my prefabs with the baked lighting out of the scene being loaded in (which currently shows the baked lighting correctly) and into the Asset Bundle which the scene grabs prefabs from instead (which does not work and results in what you see above).

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Can you make sure that the other assetbundle you have your prefabs in contains all the lightmap textures? Also can you see in the hierarchy if those are properly assigned in the script?

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

temp_LightingIssue-FollowUp02
temp_LightingIssue-FollowUp

I made sure to include the lightmap textures and the LightingData.asset file in the Asset Bundle and ran it again, but see the same issue.
It seems like they may not be properly assigned. In the lighting scene I have which bakes the prefabs, I see the Baked Lightmap on the mesh, but then during runtime, I don't see the Baked Lightmap show up on that same mesh (images included). Anything else I can look for to find discrepancies?

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Can you check the top of the prefab, the object/script PrefabLightmapData.cs? that's where the lightmaps are "stored"

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

temp_LightingIssue-FollowUp03

Let me know if I should be looking at any of these dropdowns specifically. I see 185 items under Renderer Info (with valid mesh references), 20 Lightmaps (with seemingly valid entries), 20 Lightmap Dir (all labeled as null), 20 Shadow Masks (all labeled as null), and 10 items under Light Info (with valid references)

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Ok thank you, everything seems fine, would it be possible for you to make a repo project for me? And empty project with two bundles (scene one with a baked prefab in it) and a bundle of the prefab, with a couple of scenes mimicking your load method. That way I can go in and debug it and figure out the issue for you and see where its failing to load the lightmaps

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

Sure, I'll try to get that out to you sometime today. I appreciate your help

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

Okay, got a repo setup. Let me know if this works for you
https://github.com/MichaelBezzina/ExampleProject_LightingIssue

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Thank you, I am not getting anything loaded with the bool set to false
image

Let me know if I am missing something

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

I'll keep checking tomorrow, but another thing I noticed is that if I try (in the editor) to select anything in that instantiated prefab and set it to static then Unity crashes
image

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

Sorry, I shouldn't have made that bool toggleable with this demo. You can leave that set to true, because that is how it is being used in this context.
As for the crash, I'm also experiencing that not only in this demo, but in my main project as well. Not sure if that's related to the lighting issue, or simply something you are unable to do during runtime.

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

https://forum.unity.com/threads/crash-when-setting-objects-to-static.490963/
Related?

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Thanks, could you also include the prefab in your repo project? That way I can compare the instantiated one from the bundle and the regular one when debugging (need to check if the lightmap is applied at the right coordinates, or if its a shader issue, etc)

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

Okay, well, I got the prefabs added to the project and only stripped out the people to reduce the amount of assets that needed to be exported over. The asset bundles currently included in this project are still from the main project though because the process of trying to bake these prefabs in this demo is causing Unity to max out the memory for some reason so I'm unable to make asset bundles based on this repo.
And to be clear, if I move the prefab in its own asset bundle into the asset bundle with just the scene, the baked lighting will work perfectly fine. Hopefully these are somewhat helpful in the debugging process though (both located in 'Assets\Prefabs\AssetBundlePrefabs\SpawnableObjects\EnterAndExplore')

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Ok so the issue I have is that I cannot compare because the prefab you included doesn't have the same references to lightmaps
image
there are no lightmaps for me to compare and check against. I was hoping to be able to drag and drop the "Apartment" into the scene to compare.

So if I understand correctly the issue happens only when the prefab is part of the assetbundle of the scene? Or am I understanding this in a different way?

  1. Assetbundle A contains scene AND prefab - It doesn't work

  2. Assetbundle A (scene), AssetBundle B (prefab)- It works

Can you add a scene that does the case where you say its correct (what you mention of its own assetbundle), so I can compare both. With only the non-functioning case I am a bit blind on to what is happening.

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Ok, looking at the code. It is the other way around. It is when its in its own assetbundle that the prefab is not being lit up. Does the "examplebundle" only contain the apartment or does it contain the other as well? (just trying to figure out how to get the same prefab to work and not work so I can compare)

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

It's moreso this:

  • If you put the baked prefab into a scene, set the scene to be included in an asset bundle, and then grab and instantiate that scene from that asset bundle during runtime - It Works
  • If you put that prefab directly in an asset bundle and then try to grab and instantiate that prefab during runtime - It does not work

I was hoping that I could bake the prefabs in the Lighting_Scene that I created within this demo project in order to create those references for you, but when I try to bake them in this project, my Unity Editor gets stuck and uses a bunch of memory during that process. I'll try to get that fixed tonight or tomorrow so that you can properly check those references. I can also provide some screenshots from the main project we have since there seems to be some issues with this demo project at the moment.

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

In this demo repo, the examplebundle contains only the apartment. In the main project, however, it contains a bunch of other stuff as well

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Ok I am pretty sure its this same issue here:

    "Further exploration seems to show that the meshes are being stored without the UV1 information (which is used for lightmaps), I need to look to see if there is a way to force that being stored when exporting the bundles. I'll let you know if I find out.

I believe its the way URP exports that it leaves the UV1 of meshes off the assetbundle for some reason

Originally posted by @Ayfel in #53 (comment)

"

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

So this is a Unity bug that needs to be reported to Unity, hopefully they will fix it (or have fixed in future versions). It might not be present in future versions.

I still think there might be the possibility to "force" the UV1(or uv2) to be included but I haven't figured out how yet.

Here you can see the mesh in the prefab (inside the project)
image
And here the mesh included in the bundle
image

You can see the bundle mesh is missing a lot of information

from prefablightmapping.

MichaelBezzina avatar MichaelBezzina commented on July 22, 2024

Oh yeah, I remember that thread. I'll try to find a reported Unity bug regarding this or post one myself then.

If you do find out a way to force the inclusion of the UV1 or have any ideas that are worth trying out, please let me know. I'll start investigating that further and also post if I find anything promising.

Thanks for the clarification in those screenshots as well!

from prefablightmapping.

MuhammedResulBilkil avatar MuhammedResulBilkil commented on July 22, 2024

Oh yeah, I remember that thread. I'll try to find a reported Unity bug regarding this or post one myself then.

If you do find out a way to force the inclusion of the UV1 or have any ideas that are worth trying out, please let me know. I'll start investigating that further and also post if I find anything promising.

Thanks for the clarification in those screenshots as well!

Did you find any solution? I would like to use this Prefab Lightmapping with Addressables. I have not tried it yet but addressables works with asset bundles under the hood.

Unity Version: 2021.3.14f1 LTS
Addressable Version: 1.21.10

from prefablightmapping.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.