armory3d / armory

3D Engine with Blender Integration
https://armory3d.org/engine
zlib License
3.08k stars 319 forks source link

fix normalize issue. #3006

Closed e2002e closed 7 months ago

e2002e commented 8 months ago

The use of normalize() on the getPosView() function is making strange refractions on flat surfaces. Instead, just use the negative return of getPosView() Passing 1.0 / ior to refract() is also not good.

After changing this the render is correct. Capture du 2024-03-25 14-05-37

I've set the opacity to 0.0 for glass, if user wan't a mix they can use the alpha value of principled.

@luboslenco this is fixing a broken feature that I introduced, and is compatible with the voxels pull request (voxelization of refractive objects). You should merge this one before

e2002e commented 8 months ago

@MoritzBrueckner I need your help again to review this fix.

e2002e commented 7 months ago

Using normalized positive value of getPosView an 1.0 / ior for the refract function gives good result for all kind of surfaces. Capture du 2024-04-01 10-16-21 Capture du 2024-04-01 10-21-07

e2002e commented 7 months ago

@MoritzBrueckner @luboslenco I changed the way refract is done a little. Now it's like translucent pass, meaning that it's a forward pass, and instead of translucent resolve, the refraction shader is dispatched. It did this because I noticed that shadowmaps are only generated for objects that have a "mesh" pass. This is still discarded but when we have transparent shadows I think this will be usefull.