Giter Site home page Giter Site logo

Comments (13)

Ayfel avatar Ayfel commented on July 22, 2024 1

So when the system applies the lightmaps it reassigns shaders, as this was needed in certain cases and certain materials. For these HDRP shaders it seems like that is causing the "transparent" keyword to be lost. So I added a new bool to the script, you can uncheck this in your prefabs and it seems to work well.

image

image

Download the latest version from master to access that. I left it true by default but you can uncheck it.

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Hi,

If you bake a regular transparent object and build a scene with that object (without instantiation, to rule out the prefab light mapping) does it work properly? I am not sure why this would be happening so let's dig a bit on how things are setup. Are you loading your prefabs from disk, from assetbundles?

from prefablightmapping.

Baltzs avatar Baltzs commented on July 22, 2024

Hey, thanks for the quick response,

So were not using assetbundle, were loading prefab directly from the disk.

I did a test of creating a new scene, two cube with 2 transparent mtl (the one were using on our windows, and a new one I did.)

Both worked correctly in the build.

I did another test of building the exact same scene but with the prefab of one of our room loaded inside (nothing else but the player), and the issue was up again, our window was opaque.

To be extra sure, i did another build with unpacking the prefab and deleting the lightmap prefab component, and this time it worked.

So my guess is that the issue come from the light map prefab, might be because of the way lightmaps are merged with the base color of the elements. For opaque objects you can just multiply the lightmap to the base color of the material, but for material with alpha it dosen't work the same since unity is reading the image alpha as the alpha of the material.

Now why it dosen't work in the build while it works well in the editor, i'm not sure, once again I don't exactly know how all of this works!

pbsdles2
pbsdles3
pbsdles4

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Can you take a look at your graphics settings in project settings, it might look different in HDRP but you should take a look at shader stripping etc to make sure all modes you need are included

image

from prefablightmapping.

Baltzs avatar Baltzs commented on July 22, 2024

Yes, sorry i should have mentionned i did the thing you suggested on other posts before submitting.

Here is it under HDRP, does it looks okay to you?

image

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Thanks, can you change the instancing variants to not strip?

image

from prefablightmapping.

Baltzs avatar Baltzs commented on July 22, 2024

I set it up to "keep all", built the same scene again, stil did not work, but it did took some time to build (~20 min).

image

image

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

can you make a small repo project for me to check? just same version of unity, hdrp and settings with a simple model/material and prefab for me to check. I suspect something in the HDRP shaders is making it do this, but its probably version specific too

from prefablightmapping.

Baltzs avatar Baltzs commented on July 22, 2024

Okay, sorry for the delay.

I've created a specific repo based on our main one, I've sent you an invitation.

I've set up three windows: one which has a prefab lightmap, another one that shares the same material as the prefab but is not a prefab, and a last one which has its own material and not a prefab.

The prefab lightmap is opaque again, and the interesting thing is that the material on the other window that is not supposed to have the lightmap prefab is also opaque.

This means that if a mesh shares the same transparent material as a prefab lightmap, it also loses its transparency

Hope you can check that and understand something about it! Thanks again!

image

from prefablightmapping.

Baltzs avatar Baltzs commented on July 22, 2024

Thank you so much for your quick answer and reaction!!

Just made another build and it works perfectly! This is awsome and a great load off of our shoulders!

Hope you have a wonderfull day, thanks again !!

image

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

Happy to help : )

from prefablightmapping.

Nattuhan avatar Nattuhan commented on July 22, 2024

@Ayfel
Hi, thank you for the great source code.
I faced the same problem and came across this issue and solution.
If possible, I would like to know what the purpose of the few lines of processing that are skipped when the bool is set to false are originally written for ("release shaders" are needed in specific cases, for optimization, etc...). ).
Thanks.

from prefablightmapping.

Ayfel avatar Ayfel commented on July 22, 2024

So that line just reassigns the shaders to the materials, and it is (was) necessary in certain cases where the lightmap wouldn't show up unless the shader was reassigned/reset. I have found that different versions of Unity behave differently in some cases and this is a regression that happens in some cases when loading from assetbundles etc. Technically it shouldn't be necessary but sometimes it is unfortunately.

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.