guycalledfrank / bakery-issues

Bug tracker for Bakery
4 stars 0 forks source link

Can not get bounced lighting from one sector to another sector #152

Open HakuWang opened 1 year ago

HakuWang commented 1 year ago

I wanted to test-out Bakery's sectors, but am having issues on getting bounced lighting from one sector to another sector.

Here is the simple test scene baked by sector: image

and the same scene baked fully: image

and the previewed results: image

image

In preview mode, the models of other sectors could be seen, but the "white sector" could not receive the bounced lighting from the "Red Sector". Could you give me some suggestions to fix this problem? Thanks a lot!

PS. I used custom shaders with custom renderpipeline.

guycalledfrank commented 1 year ago

Ah yes, I think it's related to this:

https://geom.io/bakery/wiki/index.php?title=Partial_scene_baking#Material_compatibility

Internally, capture points render the scene in 6 directions using special shaders that output albedo, normal and depth. As these shaders don't have original shaders' logic, procedural albedos may be lost. Currently every rendered object will draw _MainTex/_BaseMap/_BaseColorMap of the material (whichever is present). As capture points draw objects directly as seen (with perspective projection), they can't, unlike the lightmapper or the RTPreview, use the Meta Pass

TBH, I'm not sure how to fix this in some universal way, but you can replace my built-in shader (ftFarSphereRender.shader) with yours and e.g. read color from your own constants.

HakuWang commented 1 year ago

Thank you for quick reply!

I modified your ftFarSphereRender.shader to apply the _Color property and tried to modify the static function GenerateFarSphereData in ftBuildGraphics.cs and found that i could not set color property to the farSphereMat successfully. I do not know its unity's api bug or the Material.SetColor function can not be used with Graphics.DrawMeshNow. I also tried to use meterial block with Graphics.Draw Mesh, but i could not see the mesh drawn when clicked Preview.

Another problem is that if i change the _Maintex property to _Basemap in ftFarSphereRender.shader and use farSphereMat.SetTexture() with the _Basemap, the main texture could not be applied either. Here is the snapshot of where I modified the code: image

I was wondering if I found the wrong place to modify or is there other places i need to modify ? Thanks again!

guycalledfrank commented 1 year ago

Hmmm not sure what you're doing wrong. Just tried it and it worked (there is no bug in DrawMeshNow):

image

image

What seems like a bug on my side though is that I'm checking for _BaseMap AFTER I check for mats[s].HasProperty("_MainTex")! D'oh!

Just removed that check completely. https://github.com/guycalledfrank/bakery-csharp/commit/26a7ed217d370bec3c0261db7655648a5a455c99

HakuWang commented 1 year ago

What seems like a bug on my side though is that I'm checking for _BaseMap AFTER I check for mats[s].HasProperty("_MainTex")! D'oh!

Actually i had removed the checking you mentioned here.

I also tried to use SetVector but failed before. Since you made it work i will try to foucus on why my SetColor and SetVector not worked. Thanks for your reply and quick test!