Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1 Glass reduces intensity of emitters significantly #608

Closed
jackjt8 opened this issue Jun 7, 2020 · 6 comments · Fixed by #1514
Closed

2.1 Glass reduces intensity of emitters significantly #608

jackjt8 opened this issue Jun 7, 2020 · 6 comments · Fixed by #1514

Comments

@jackjt8
Copy link
Member

jackjt8 commented Jun 7, 2020

Similar to #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
Copy link
Member Author

jackjt8 commented Jun 8, 2020

Scene
scenes.zip

@aTom3333
Copy link
Member

aTom3333 commented Jun 8, 2020

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

@leMaik
Copy link
Member

leMaik commented Jun 8, 2020

@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. 🤔 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.

@Stenodyon
Copy link
Contributor

Stenodyon commented Jun 10, 2020

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.

@jackjt8
Copy link
Member Author

jackjt8 commented Dec 5, 2022

tested on 2.4.3

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

@JustinTimeCuber
Copy link
Contributor

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

JustinTimeCuber added a commit to JustinTimeCuber/chunky that referenced this issue Dec 10, 2022
JustinTimeCuber added a commit to JustinTimeCuber/chunky that referenced this issue Dec 10, 2022
leMaik pushed a commit that referenced this issue Aug 10, 2023
* fix translucent coloring

* Add Redox's code for emitter lighting (fix #608)

* Create a method (translucentRayColor) for code that was previously duplicated

* Bring more of the duplicated code into translucentRayColor

* Remove Redox's fix for #608, additional testing needed

* Cap each color's transmissivity at 1
Example: RGBA = 0.8, 0.35, 0.05, 0.2
Uncapped transmissivity RGB = 1.6, 0.7, 0.1
Capped transmissivity RGB = 1, 0.775, 0.625

* Extract transmissivity cap from formula into a constant (for future configurability)
Also, select the highest transmissivity value properly this time

* improve translucent coloring

* Create a method (translucentRayColor) for code that was previously duplicated

* Bring more of the duplicated code into translucentRayColor

* Cap each color's transmissivity at 1
Example: RGBA = 0.8, 0.35, 0.05, 0.2
Uncapped transmissivity RGB = 1.6, 0.7, 0.1
Capped transmissivity RGB = 1, 0.775, 0.625

* Extract transmissivity cap from formula into a constant (for future configurability)
Also, select the highest transmissivity value properly this time

* block half-ish of the light on the diffuse pass and another half-ish on the translucent pass (actually 1 - sqrt(1-x))

* Add a slider for `Transmissivity cap` value

- Added a slider for the `Transmissivity cap` value with range [1, 3].
- Added a `group-label` CSS class for group labels.

* Move `Transmissivity cap` to the `Advanced` tab

* Ensure that total energy is never amplified, even when transmissivityCap > 1.

* you just got vectored

* Revert changes to MaterialsTab.java

`Transmissivity cap` had been moved to the `Advanced` tab, but other changes to the `Materials` tab were not reverted then.

---------

Co-authored-by: Peregrine05 <[email protected]>
leMaik pushed a commit to leMaik/chunky that referenced this issue Sep 9, 2023
* fix translucent coloring

* Add Redox's code for emitter lighting (fix chunky-dev#608)

* Create a method (translucentRayColor) for code that was previously duplicated

* Bring more of the duplicated code into translucentRayColor

* Remove Redox's fix for chunky-dev#608, additional testing needed

* Cap each color's transmissivity at 1
Example: RGBA = 0.8, 0.35, 0.05, 0.2
Uncapped transmissivity RGB = 1.6, 0.7, 0.1
Capped transmissivity RGB = 1, 0.775, 0.625

* Extract transmissivity cap from formula into a constant (for future configurability)
Also, select the highest transmissivity value properly this time

* improve translucent coloring

* Create a method (translucentRayColor) for code that was previously duplicated

* Bring more of the duplicated code into translucentRayColor

* Cap each color's transmissivity at 1
Example: RGBA = 0.8, 0.35, 0.05, 0.2
Uncapped transmissivity RGB = 1.6, 0.7, 0.1
Capped transmissivity RGB = 1, 0.775, 0.625

* Extract transmissivity cap from formula into a constant (for future configurability)
Also, select the highest transmissivity value properly this time

* block half-ish of the light on the diffuse pass and another half-ish on the translucent pass (actually 1 - sqrt(1-x))

* Add a slider for `Transmissivity cap` value

- Added a slider for the `Transmissivity cap` value with range [1, 3].
- Added a `group-label` CSS class for group labels.

* Move `Transmissivity cap` to the `Advanced` tab

* Ensure that total energy is never amplified, even when transmissivityCap > 1.

* you just got vectored

* Revert changes to MaterialsTab.java

`Transmissivity cap` had been moved to the `Advanced` tab, but other changes to the `Materials` tab were not reverted then.

---------

Co-authored-by: Peregrine05 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants