Level-Specific Completion Messages #
A bit of non-gameplay work today.
The level complete popup now has level-specific messages. Pretty silly stuff if you ask me.
I also added a title for each level and moved the level selector to the right side. Still keeping it for now. Maybe I’ll hide it when I cut a release, actually. Include it in the DEBUG_MODE flag?
Still getting the hang of using controls and containers. I ended up with an HBoxContainer with a Label for the title, then an empty control with Expand set to true. Then an HFlowContainer which contains all the level buttons… though now that I write it, I think an HBoxContainer might make more sense there. The FlowContainers will wrap to the next line if they run out of room, I believe..?
Splitting Red, Green, and Blue Wavelengths #
Well, with that out of the way, I started working on splitting the lasers into red, green, and blue components. Now the emitters don’t shoot one white beam, they shoot three beams that overlap. Then, for the laser’s Line2D art I added a material and set its blend mode to “Add” and boom, red + green + blue = white.
So now everything looks exactly the same but the processor is doing three times the amount of work.
They say not to do performance optimization too early but this is taking it too far.
Now’s the interesting part. I need to figure out how the refraction index changes with the wavelength. That way when these three separate but overlapping lasers hit a prism, they’ll refract at slightly different angles and we’ll actually be able to see them. Let their true colours shine through.
In 1830 Augustin-Louis Cauchy defined an equation that suits our needs.
From Wikipedia, here’s the general form of Cauchy’s Equation:
You can use whatever number of terms you want, depending on how accurate it needs to be. For our purposes I’m sure two terms are more than enough.
Now, this model only works in the visible spectrum. One more graphic straight from Wikipedia shows how the error increases after around 800 nm wavelength.
Thanks, Wikipedia!
If I needed ultraviolet rays to refract properly I’d want to use the Sellmeier equation, defined in 1872. But that’s unnecessary complexity.
For Cauchy’s two-term equation I need constants for some type of glass material for all the prisms and also for water. Wikipedia provides the former but not the latter.
The values of A are spread around the number I’m using for the refractive index of glass already, 1.52. I think I chose an option called “Window Glass” from a list of refractive indices. Probably doesn’t matter too much which of these I choose..?
But water. ResearchGate has a paper where two people measured the refraction of water at various temperatures and published the constants. Here’s the paper by Bashkatov and Genina.
Problem is, they used the four-term Cauchy equation.
The constants will be different depending on which equation you’re using. Looks like I can’t just use the constants for the first two terms and discard the rest. Too bad. (-:
But maybe I can use their measurements to work out the constants for the two-term equation.
For 20°C the readings were:
Temp °C | 226.5 nm | 361.05 nm | 404.41 nm | 589 nm | 632.8 nm | 1013.98 nm |
---|---|---|---|---|---|---|
20 | 1.39336 | 1.34795 | 1.34315 | 1.33336 | 1.33211 | 1.32524 |
Here are the points plotted in good ol’ Desmos. |
And this time with the curve from Cauchy’s equation after adjusting the sliders a bunch.
I was thinking I’d calculate the error, then calculate the derivative of the error function relative to the constants A and B. Is that how it’d work? This is getting a little heavy for what I’m doing here. Eyeballing it with sliders sounds great. (-:
I got A=1.3223 and B=3,552 nm². Also TIL micros (μm) are bigger than nanometers. I was really confused about my units for a minute there.
Well, here it is!
I tried different wavelengths for the lasers. Might adjust some more but for now I’m using: Ruby 694 Frequency-doubled Nd:YAG 532 Frequency-trebled Nd:YAG 355
No, I do not know what those laser names mean. Not yet, anyway.
Oh right. I’m using the values for water.
Barium Crown Glass BaK4 I can’t even get the rays to split. They keep doing internal reflection instead. Huh.
Even Fused Silica which I think has the closest values to water—doesn’t work. Hmm.
I can get it to aberrate with total internal reflection. Check this out:
The actual refractive indices being calculated for Fused Silica are: 1.46534359861931 1.47050777319238 1.48608966474906
And for water: 1.32966849217395 1.33485017242354 1.3504848839516
And the refractive index I was using before: 1.52
But before I didn’t have any rays to split at all.
Okay, I gotta go but this is exciting! And also a little unexpected. Maybe this is one of those times where it makes sense to warp the physics a bit to get better game play.
…
I’m still here. Wikipedia says Crown glasses have small dispersion but flint glass dispersion is larger. In hindsight that makes sense. The value of A and thus the resulting value n being similar to my previous value doesn’t matter. It’s the value of B. Larger values mean more dispersion. And I didn’t try the materials with higher values of B yet so.
Hmm. I was hoping that’d be it but no dice. And actually water’s value for B is pretty small. I’ll have to follow up on this next time.