Comments (13)
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.
Download the latest version from master to access that. I left it true by default but you can uncheck it.
from prefablightmapping.
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.
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.
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!
from prefablightmapping.
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
from prefablightmapping.
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?
from prefablightmapping.
Thanks, can you change the instancing variants to not strip?
from prefablightmapping.
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).
from prefablightmapping.
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.
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!
from prefablightmapping.
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 !!
from prefablightmapping.
Happy to help : )
from prefablightmapping.
@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.
Related Issues (20)
- Light probes in Interior scenes HOT 1
- Baking lightning on a prefab overwrite other prefabs lightmaps HOT 2
- URP AssetBundle lighting corrupted HOT 5
- "IndexOutOfRangeException: Index was outside the bounds of the array." on MaterialPostprocessor. HOT 5
- As I bake new prefab the old lightmaps gets deleted even they are moved in separate folder
- About Android HOT 2
- Baked lighting is broken upon instantiating from Asset Bundle HOT 25
- Baked light probes
- Baked lighting doesn't work in the build version if Screen Space Shadows is enabled
- Lightmap breaks in the build on a single prefab HOT 1
- lightmaps in the build aren't mapped correctly HOT 2
- Not working on unity 2022.2.13 HOT 4
- I try to bake but it has already taken about 4 and half hours HOT 1
- Trying to set shader on a Material Variant HOT 3
- Lightmaps Too Bright on Android Bundle HOT 2
- Incorrect light maps being assigned on instantiation HOT 2
- Prefab only baking/loading one light HOT 1
- How to merge LightingData assets for correct shading working? HOT 10
- Normal maps not showing properly on instantiated prefab HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prefablightmapping.