chunky icon indicating copy to clipboard operation
chunky copied to clipboard

2.1 Glass reduces intensity of emitters significantly

Open jackjt8 opened this issue 5 years ago • 4 comments

Similar to https://github.com/llbit/chunky/issues/528 but with glass instead.

1.4.5 NoiseTest_a_1_water_glass-256

2.0beta6 NoiseTest_a_2_water_glass-256

2.1-274 NoiseTest_a_274_water_glass-256

2.1-308 NoiseTest2_water_glass-256

jackjt8 avatar Jun 07 '20 22:06 jackjt8

Scene scenes.zip

jackjt8 avatar Jun 08 '20 05:06 jackjt8

NoiseTest2_water_glass-256 I went back to see when that was introduced. It was when localIntersect for class was made to be false. Setting it back to true fixes this issue but we don't get refraction anymore and we can see the inside. So i'll have to look further

aTom3333 avatar Jun 08 '20 13:06 aTom3333

@aTom3333 We would need to remember that the ray already hit a glass block of that color (previousMaterial of the ray) and then skip intersection in the intersect method of the glass model. This could make glass blocks behind glass blocks (glass air glass, like in your image) invisible, I'll have to try it out.

Refraction shouldn't be affected by this change. :thinking: It works fine for e.g. slime blocks which also use local intersection.

By the way: localIntersect means that instead of using a cube with the block's texture, the intersect method of the block gets called.

leMaik avatar Jun 08 '20 20:06 leMaik

If localIntersect is true then the ray goes through the glass instead of generating an intersection that can refract. This is because TexturedBlockModel.intersect(…) makes a decision about intersecting the glass block based on the texture alpha but not the refraction index. https://github.com/llbit/chunky/blob/ed0d57550d6f836690b4ae5ade465f2b7eac42ed/chunky/src/java/se/llbit/chunky/model/TexturedBlockModel.java#L60-L65 As you can see that only happens when the texture is fully transparent which is probably why refraction still works with other blocks like slime. Maybe TexturedBlockModel should intersect even when the texture alpha is zero and let the path tracer decide what to do based on the texture alpha and refractive index?

EDIT: I've experimented a bit with removing that if condition and I'm correctly getting refraction (and that emitter light reduction bug) no matter the value of localIntersect for glass, though there is an inconsistency with ray bounces inside the glass. I think this means the problem here is a loss of energy with refracted rays.

localIntersect = false (same as OP) localIntersect_false

localIntersect = true localIntersect_true Notice the darker ground under the glass.

Stenodyon avatar Jun 10 '20 11:06 Stenodyon

tested on 2.4.3

default_2022-12-05_22-07-25.zip image

jackjt8 avatar Dec 05 '22 22:12 jackjt8

From my testing it seems like the effect is most significant when the light source is directly adjacent to the glass. image image

JustinTimeCuber avatar Dec 10 '22 06:12 JustinTimeCuber