guycalledfrank / bakery-issues

Bug tracker for Bakery
4 stars 0 forks source link

baking results inconsistent in realtime preview and also in bake #71

Closed laurentopia closed 3 years ago

laurentopia commented 3 years ago

image this object is using that shader image which should bake properly since those objects are also using this shader image

laurentopia commented 3 years ago

and if i add a plane with URP baked lit, it doesn't get baked in preview. image and if i bake it i get this scramble image

guycalledfrank commented 3 years ago

URP Baked Lit shader seems to work for me (testing in 2020.2.7, URP 10.3.2):

image

So the shader is not the cause. No UVs or something?

laurentopia commented 3 years ago

The metallic strawberry clearly has UV so that's not the cause. When I switch it to baked lit it still doesn't light up so shader isn't the issue. Maybe a setting? Here is mine. image image

guycalledfrank commented 3 years ago

Not sure. Can you bake the strawberry in a separate scene? If it still doesn't bake (related to single mesh/material), then it should be easy to track down the problem.

laurentopia commented 3 years ago

isolated scene, one bakery direct light, real time preview: image

guycalledfrank commented 3 years ago

Can you send me a unitypackage with this model/material/maps to check?

laurentopia commented 3 years ago

here it is strawberry.zip

guycalledfrank commented 3 years ago

Hi. Your graph doesn't compile because it can't find MeshAnimatorSubGraph. I removed it to test. It also used some different version of BakeryDecodeLightmap.hlsl, as you were feeding occlusion parameter to it. Removed it as well. I also had to re-export the model to FBX on a different PC, because I don't have Maya here. Unity doesn't have a built-in Maya importer, it just looks for Maya on your machine and asks it to export to fbx...

After that (with stuff cut from the graph and model coming from fbx), I tested the strawberry, and it... seems to work:

RTPreview:

image

Here it is with Baked Lit:

image

And with your graph (baked with strawberry not being static to prevent voxel self-occlusion):

image

So not sure how to reproduce the bug above.

laurentopia commented 3 years ago

That was quite an ordeal I put you through. Thanks for bearing with me. So you're recommending that I remove the occlusion? What data does preview use for render? I tested things with a simple cube. It turns black with the strawberrie's texture and material settings then if I switch smoothness from metallic off and set metallic and smoothness to 0 it works image but here is where it gets fun: if set the material parameters back to original it now works! image With this stunt the strawberry still look borked like bad UV. might be UV that you got right in by doing a separate fbx pass and the unity+maya importer being super borked, lemme try that. nope. Might be related, maybe not related but what I see is preview keeps stuff that's been changed. image here the foliage has disappeared after i changed the shader to what you have and then I brought that old shader back from git and it's still gone. Also these green things at the top were erroneously set to bake, I switched that off but they still show up in preview. I use version ... no idea... maybe add the version number in the preview window like you did with bake. image or if it's easier, in the console.

guycalledfrank commented 3 years ago

Not sure if occlusion is the problem. But maybe it is. Preview reflects "how lightmapper sees the world", i.e. GI will bounce from the same color; the color is from Meta Pass of every shader; in case of graphs it should come from what you put to albedo/emission outputs.

if set the material parameters back to original it now works!

OK wow this is confusing :) I'm not sure why it can be this way. Unity forgets to reset something on the shader?

Preview version doesn't matter in this case, it didn't change that much. Scene exporting is on the lightmapper's C# side.

Here is some idea:

... but my bet it's related, in case you CAN'T reproduce it with Baked Lit or other built-in shaders.

Possible resolution: I can make some switch to force Bakery extract albedo/emission for GI not from the Meta Pass (your graph), but directly via common texture names (_BaseMap, _BaseColorMap, _MainTex, etc). Very easy to do globally. Less easy to do per-material. Maybe you can add some specially-named property to the shader and I can scan for it?

laurentopia commented 3 years ago

Maybe you can add some specially-named property to the shader and I can scan for it?

That would work very well.

guycalledfrank commented 3 years ago

OK, I added a little patch.

Now if your shader has a property named BAKERY_FORCE_NO_META, it will ignore the meta pass and use _MainTex/_BaseColorMap/_BaseMap instead.

e.g. BAKERY_FORCE_NO_META ("BAKERY_FORCE_NO_META", Float) = 0.0

Here is how it can look in a graph:

image

Can you try it?

laurentopia commented 3 years ago

absolutely amazing, man, thank you so much! image image