diff --git a/src/net/torvald/colourutil/CIEXYZUtil.kt b/src/net/torvald/colourutil/CIEXYZUtil.kt index eb0c84378..935b8fb90 100644 --- a/src/net/torvald/colourutil/CIEXYZUtil.kt +++ b/src/net/torvald/colourutil/CIEXYZUtil.kt @@ -204,8 +204,11 @@ object CIEXYZUtil { /** Range: X, Y, Z: 0 - 1.0+ (One-based-plus) */ data class CIEXYZ(var X: Float = 0f, var Y: Float = 0f, var Z: Float = 0f, var alpha: Float = 1f) { init { - if (X !in -5f..5f || Y!in -5f..5f || Z !in -5f..5f) - throw IllegalArgumentException("Value range error - this version of CIEXYZ is one-based (0.0 - 1.0+): ($X, $Y, $Z)") + if (X.isNaN() && Y.isNaN() && Z.isNaN()) { + this.X = 0f; this.Y = 0f; this.Z = 0f + } + //if (X !in -5f..5f || Y!in -5f..5f || Z !in -5f..5f) + // throw IllegalArgumentException("Value range error - this version of CIEXYZ is one-based (0.0 - 1.0+): ($X, $Y, $Z)") } } diff --git a/src/net/torvald/parametricsky/Application.kt b/src/net/torvald/parametricsky/Application.kt index 58646290f..263852bb1 100644 --- a/src/net/torvald/parametricsky/Application.kt +++ b/src/net/torvald/parametricsky/Application.kt @@ -5,14 +5,18 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.Screen import com.badlogic.gdx.backends.lwjgl.LwjglApplication import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration +import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Pixmap import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.math.Affine2 +import com.jme3.math.FastMath import net.torvald.colourutil.CIEYXY import net.torvald.colourutil.CIEXYZUtil.toXYZ import net.torvald.colourutil.CIEXYZUtil.toColorRaw import net.torvald.colourutil.CIEXYZUtil.toColor +import net.torvald.colourutil.RGB +import net.torvald.terrarum.gameworld.fmod import net.torvald.terrarum.inUse import java.awt.BorderLayout import java.awt.Dimension @@ -20,8 +24,8 @@ import javax.swing.* import kotlin.math.pow -const val WIDTH = 720 -const val HEIGHT = 720 +const val WIDTH = 1200 +const val HEIGHT = 600 /** * Created by minjaesong on 2018-08-01. @@ -35,10 +39,15 @@ class Application : Game() { * 4. Turbidity * * Sampling rate: - * theta in 70 downTo 0 step 10 (8 entries) // canvas - * gamma in -90..90 step 12 (16 entries) // canvas - * theta_s in 0..70 step 10 (8 entries) // time of the day - * turbidity in {1.5, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64} (12 entries) // weather of the day + * theta in 0..90 total 32 entries // canvas + * gamma in 0..90 total 32 entries // canvas + * theta_s in 0..90 total 16 entries // time of the day + * turbidity in {1.5, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64} total 12 entries // weather of the day + * + * + * out atlas dimension: + * X = (32 * 16) = 512 + * Y = (32 * 12) = 384 */ @@ -47,8 +56,8 @@ class Application : Game() { private lateinit var testTex: Texture - var turbidity = 7.0 - var thetaOfSun = 0.0 + var turbidity = 5.0 + //var thetaOfSun = 0.0 override fun getScreen(): Screen { return super.getScreen() @@ -61,7 +70,7 @@ class Application : Game() { override fun render() { Gdx.graphics.setTitle("Daylight Model — F: ${Gdx.graphics.framesPerSecond}") - genTexLoop(turbidity, thetaOfSun) + genTexLoop(turbidity) val tex = Texture(oneScreen) @@ -90,44 +99,143 @@ class Application : Game() { oneScreen.dispose() } + val outTexWidth = 32 + val outTexHeight = 16 + /** * Generated texture is as if you took the panorama picture of sky: up 70deg to horizon, east-south-west; * with sun not moving (sun is at exact south, sun's height is adjustable) */ - private fun genTexLoop(T: Double, theta_s: Double) { + private fun genTexLoop(T: Double) { + + fun normaliseY(y: Double): Float { + var v = y.coerceAtLeast(0.0) + + if (v < 0) println("$y -> $v (should not be negative)") + + return v.toFloat() + } + + val theta = Math.toRadians(45.0) // of observer + + // loop DAY + for (x in 0 until outTexWidth) { // theta_s (time of day) + for (y in 0 until outTexHeight) { // gamma + val theta_s = Math.toRadians(x * (90.0 / outTexWidth.toDouble())) + val gamma = Math.toRadians((outTexHeight - y) * (90.0 / outTexHeight.toDouble())) // of observer + + val Y_z = Model.getAbsoluteZenithLuminance(T, theta_s).coerceAtLeast(0.0) / 88.0 + val x_z = Model.getZenithChromaX(T, theta_s) + val y_z = Model.getZenithChromaY(T, theta_s) + + val Y_p = Y_z * Model.getFforLuma(theta, gamma, T) / Model.getFforLuma(0.0, theta_s, T) + val Y_oc = Y_z * (1.0 + 2.0 * Math.cos(theta)) / 3.0 + val x_p = (x_z * Model.getFforChromaX(theta, gamma, T) / Model.getFforChromaX(0.0, theta_s, T)).coerceIn(0.0, 1.0) + val y_p = (y_z * Model.getFforChromaY(theta, gamma, T) / Model.getFforChromaY(0.0, theta_s, T)).coerceIn(0.0, 1.0) + + val normalisedY = normaliseY(Y_p) + + //println("$Y_p -> $normalisedY, $x_p, $y_p") + + val rgbColour = CIEYXY(normalisedY, x_p.toFloat(), y_p.toFloat()).toXYZ().toColorRaw() + + oneScreen.setColor(rgbColour) + oneScreen.drawPixel(x, y) + } + } + // end loop DAY + + // loop NIGHT + for (x in outTexWidth until outTexWidth * 2) { + for (y in 0 until outTexHeight) { + val theta_s = Math.toRadians(90.0 - (x - outTexWidth) * (90.0 / outTexWidth.toDouble())) // 90 downTo 0 + val theta_sReal = Math.toRadians(120.0) + val gamma = Math.toRadians((outTexHeight - y) * (90.0 / outTexHeight.toDouble())) // of observer + + val Y_z = Model.getAbsoluteZenithLuminance(T, theta_sReal) + val x_z = Model.getZenithChromaX(T, theta_s) + val y_z = Model.getZenithChromaY(T, theta_s) + + val Y_p = Y_z * Model.getFforLuma(theta, gamma, T) / Model.getFforLuma(0.0, theta_sReal, T) + val Y_oc = Y_z * (1.0 + 2.0 * Math.cos(theta)) / 3.0 + val x_p = (x_z * Model.getFforChromaX(theta, gamma, T) / Model.getFforChromaX(0.0, theta_s, T)).coerceIn(0.0, 1.0) + val y_p = (y_z * Model.getFforChromaY(theta, gamma, T) / Model.getFforChromaY(0.0, theta_s, T)).coerceIn(0.0, 1.0) + + val normalisedY = normaliseY(Y_p) + + //println("$Y_p -> $normalisedY, $x_p, $y_p") + + val rgbColour = CIEYXY(normalisedY, x_p.toFloat(), y_p.toFloat()).toXYZ().toColorRaw() + + oneScreen.setColor(rgbColour) + oneScreen.drawPixel(x, y) + } + } + // end loop NIGHT + } + + /** + * Generated texture is as if you took the panorama picture of sky: up 70deg to horizon, east-south-west; + * with sun not moving (sun is at exact south, sun's height is adjustable) + */ + /*private fun genTexLoop2(T: Double, theta_s: Double) { + + fun hazeFun(T: Double): Double { + val T = T - 1 + if (T >= 10) return 1.0 + else return 2.0.pow(T).div(1024.0) + } + // loop thru gamma and theta - for (y in 0..90) { // theta - for (x in 0..90) { // gamma - val theta = Math.toRadians(y.toDouble()) // of observer - val gamma = Math.toRadians(90 - x.toDouble()) // of observer + for (y in 0..outTexDim) { // theta + for (x in 0..outTexDim) { // gamma + val theta = Math.toRadians(y * (90.0 / outTexDim.toDouble())) // of observer + val gamma = Math.toRadians(x * (90.0 / outTexDim.toDouble())) // of observer val Y_z = Model.getAbsoluteZenithLuminance(T, theta_s) val x_z = Model.getZenithChromaX(T, theta_s) val y_z = Model.getZenithChromaY(T, theta_s) val Y_p = Y_z * Model.getFforLuma(theta, gamma, T) / Model.getFforLuma(0.0, theta_s, T) + val Y_oc = Y_z * (1.0 + 2.0 * Math.cos(theta)) / 3.0 val x_p = (x_z * Model.getFforChromaX(theta, gamma, T) / Model.getFforChromaX(0.0, theta_s, T)).coerceIn(0.0, 1.0) val y_p = (y_z * Model.getFforChromaY(theta, gamma, T) / Model.getFforChromaY(0.0, theta_s, T)).coerceIn(0.0, 1.0) val normalisedY = Y_p.toFloat().pow(0.5f).div(10f) + val normalisedY_oc = Y_oc.toFloat().pow(0.5f).div(10f) //println("$Y_p -> $normalisedY, $x_p, $y_p") - val rgbColour = CIEYXY(normalisedY, x_p.toFloat(), y_p.toFloat()).toXYZ().toColor() - //val rgbColour = CIEYXY(normalisedY, 0.3128f, 0.3290f).toXYZ().toColorRaw() + if (T < 11) { + val rgbColour = CIEYXY(normalisedY, x_p.toFloat(), y_p.toFloat()).toXYZ().toColorRaw() + val hazeColour = CIEYXY(normalisedY_oc, 0.3128f, 0.3290f).toXYZ().toColorRaw() - oneScreen.setColor(rgbColour) - oneScreen.drawPixel(x, y) + val hazeAmount = hazeFun(T).toFloat() + val newColour = Color( + FastMath.interpolateLinear(hazeAmount, rgbColour.r, hazeColour.r), + FastMath.interpolateLinear(hazeAmount, rgbColour.g, hazeColour.g), + FastMath.interpolateLinear(hazeAmount, rgbColour.b, hazeColour.b), + 1f + ) + + oneScreen.setColor(newColour) + oneScreen.drawPixel(x, y) + } + else { + val hazeColour = CIEYXY(normalisedY_oc, 0.3128f, 0.3290f).toXYZ().toColorRaw() + oneScreen.setColor(hazeColour) + oneScreen.drawPixel(x, y) + } } } // end loop - } + }*/ override fun create() { batch = SpriteBatch() testTex = Texture(Gdx.files.internal("assets/test_texture.tga")) - oneScreen = Pixmap(90, 90, Pixmap.Format.RGBA8888) + oneScreen = Pixmap(outTexWidth * 2, outTexHeight, Pixmap.Format.RGBA8888) ApplicationController(this) @@ -139,11 +247,14 @@ class Application : Game() { val mainPanel = JPanel() - val turbidityControl = JSlider(2, 25, 7) - val theta_sControl = JSlider(0, 85, 0) + val turbidityControl = JSlider(2, 64, 5) + //val theta_sControl = JSlider(0, 15, 0) val turbidityValueDisp = JLabel() - val theta_sValueDisp = JLabel() + //val theta_sValueDisp = JLabel() + + //val theta_sValue: Double + // get() = theta_sControl.value * (90.0 / theta_sControl.maximum) init { val turbidityPanel = JPanel() @@ -154,11 +265,11 @@ class Application : Game() { turbidityPanel.add(turbidityValueDisp) turbidityValueDisp.text = turbidityControl.value.toString() - theta_sValueDisp.text = theta_sControl.value.toString() + //theta_sValueDisp.text = theta_sValue.toString() - theta_sPanel.add(JLabel("Theta_s")) - theta_sPanel.add(theta_sControl) - theta_sPanel.add(theta_sValueDisp) + //theta_sPanel.add(JLabel("Theta_s")) + //theta_sPanel.add(theta_sControl) + //theta_sPanel.add(theta_sValueDisp) mainPanel.add(turbidityPanel) mainPanel.add(theta_sPanel) @@ -175,10 +286,10 @@ class Application : Game() { app.turbidity = turbidityControl.value.toDouble() } - theta_sControl.addChangeListener { - theta_sValueDisp.text = theta_sControl.value.toString() - app.thetaOfSun = Math.toRadians(theta_sControl.value.toDouble()) - } + //theta_sControl.addChangeListener { + // theta_sValueDisp.text = theta_sValue.toString() + // app.thetaOfSun = Math.toRadians(theta_sValue) + //} } diff --git a/src/net/torvald/parametricsky/Model.kt b/src/net/torvald/parametricsky/Model.kt index c7822d0c8..cc9d81927 100644 --- a/src/net/torvald/parametricsky/Model.kt +++ b/src/net/torvald/parametricsky/Model.kt @@ -36,9 +36,8 @@ object Model { /*private*/ fun _getFbyPerez(theta: Double, gamma: Double, dc: DistributionCoeff): Double { val A = dc.A; val B = dc.B; val C = dc.C; val D = dc.D; val E = dc.E - val e = Math.E - return (1.0 + A * e.pow(B / cos(theta))) * - (1.0 + C * e.pow(D * gamma) + E * cos2(gamma)) + return (1.0 + A * Math.exp(B / cos(theta))) * + (1.0 + C * Math.exp(D * gamma) + E * cos2(gamma)) } /////////////////////////////////////////////////////////////////////////// @@ -124,7 +123,8 @@ object Model { * @return Luminance in candela per metre squared */ fun getAbsoluteZenithLuminance(T: Double, theta_s: Double): Double { - return (4.0453 * T - 4.9710) * tan((4.0 / 9.0 - T / 120.0) * (PI - 2 * theta_s)) - 0.2155 * T + 2.4192 + return (4.0453 * T - 4.9710) * tan((4.0 / 9.0 - T / 120.0) * (PI - 2 * theta_s)) - 0.2155 * T + + 2.4192 } /** @@ -341,7 +341,6 @@ object Model { /////////////////////////////////////////////////////////////////////////// - private val E = Math.E private val HALFPI = 0.5 * Math.PI private val PI = Math.PI private val TWOPI = 2.0 * Math.PI diff --git a/work_files/TerrarumStructure.pptx b/work_files/TerrarumStructure.pptx new file mode 100644 index 000000000..fe936c8f8 Binary files /dev/null and b/work_files/TerrarumStructure.pptx differ diff --git a/work_files/graphics/fonts/ascii_variable.psd b/work_files/graphics/fonts/ascii_variable.psd index d391bbc3f..e3d7369d1 100644 --- a/work_files/graphics/fonts/ascii_variable.psd +++ b/work_files/graphics/fonts/ascii_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:add9ad5ad33224c6c06c8c671a75089a32f2f65f88910c2eaf03f1f74f893ea1 -size 327061 +oid sha256:13bb042fba6801461d6e6f0d551cbb0bac493987822eda5e3cff7f8664eb0efe +size 341937 diff --git a/work_files/graphics/fonts/ascii_variable_small.psd b/work_files/graphics/fonts/ascii_variable_small.psd index a94d6a752..ed8c0b250 100644 --- a/work_files/graphics/fonts/ascii_variable_small.psd +++ b/work_files/graphics/fonts/ascii_variable_small.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f692b302a0f76478c4c4ccb533b6f89b9d0bf5d09ce114b49cd731452cce337f -size 41313 +oid sha256:0aa959b3ee7e0b7206b762566fdeabeee4068459e54efddd349304e5e1b04a53 +size 56474 diff --git a/work_files/graphics/fonts/cyrilic_variable.psd b/work_files/graphics/fonts/cyrilic_variable.psd index 2b07c2a7f..ec25efb48 100644 --- a/work_files/graphics/fonts/cyrilic_variable.psd +++ b/work_files/graphics/fonts/cyrilic_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b8ba8605fd9049e277ba4c30f74c5a4004d3ec213dc27e2540d38d78608bb98 -size 410644 +oid sha256:136df09ab1ebaa0045bc795dd843f461b9c4a197262713380a0673d50643a4f2 +size 391950 diff --git a/work_files/graphics/fonts/devanagari_bengali_variable.psd b/work_files/graphics/fonts/devanagari_bengali_variable.psd index bca5e97af..8e5804192 100644 --- a/work_files/graphics/fonts/devanagari_bengali_variable.psd +++ b/work_files/graphics/fonts/devanagari_bengali_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2ca3b00d017df526b6458b88a592926b07fcad7e8026f9803d87376eeab2a702 -size 274200 +oid sha256:6a9fc149c97be3c180564460968ca6a94aefc9f0deea045b799bfed28bfb3cea +size 340404 diff --git a/work_files/graphics/fonts/devanagari_conjoiners.psd b/work_files/graphics/fonts/devanagari_conjoiners.psd deleted file mode 100644 index 071112087..000000000 --- a/work_files/graphics/fonts/devanagari_conjoiners.psd +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a1f43136dfc8c3380fc816b7a7ab551eac9af430f7a7675a17b90a9e303fc17a -size 262591 diff --git a/work_files/graphics/fonts/diacritical_marks_variable.psd b/work_files/graphics/fonts/diacritical_marks_variable.psd new file mode 100644 index 000000000..e9b081a6d --- /dev/null +++ b/work_files/graphics/fonts/diacritical_marks_variable.psd @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2cb9eb8fb87b19b151e9679647e5eae0ddfd20cf3b983c1fa1c0c18acdff9247 +size 155304 diff --git a/work_files/graphics/fonts/insular_variable.psd b/work_files/graphics/fonts/insular_variable.psd index 10c794627..cec6f2f63 100644 --- a/work_files/graphics/fonts/insular_variable.psd +++ b/work_files/graphics/fonts/insular_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7364d60f62852cf425b460284362dbfc094a3754800229d2e57d8e3ca97db197 -size 59227 +oid sha256:d778f30d9eecba98eb0b426f8294a64b628c33ed515f6adbee9a473a82ceaa1c +size 59453 diff --git a/work_files/graphics/fonts/ipa_ext_variable.psd b/work_files/graphics/fonts/ipa_ext_variable.psd index 7466e656a..79a5c292a 100644 --- a/work_files/graphics/fonts/ipa_ext_variable.psd +++ b/work_files/graphics/fonts/ipa_ext_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8111486f337b42a332d32f1afd6b8411d5acf84ea3bc5930b046f26d7f85522f -size 141290 +oid sha256:1b38fca7d91c91390d9bbb193492a7a140c465cb9e955f9da132e1898c4099dd +size 247419 diff --git a/work_files/graphics/fonts/kana.psd b/work_files/graphics/fonts/kana.psd index c33da7080..37b094133 100644 --- a/work_files/graphics/fonts/kana.psd +++ b/work_files/graphics/fonts/kana.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4162d6f6f1dd76a9175a00a0e2eba33b08cf009f836a340e2bbe81ab89b3193 -size 129736 +oid sha256:ad9317140c298616dc44254297d8d0c4e16b8827ab777eb0ef0f599f82daee5d +size 235217 diff --git a/work_files/graphics/fonts/kartuli_allcaps_variable.psd b/work_files/graphics/fonts/kartuli_allcaps_variable.psd new file mode 100644 index 000000000..ea7031bb1 --- /dev/null +++ b/work_files/graphics/fonts/kartuli_allcaps_variable.psd @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c4c8c0fbd5a636ce5e0f0b2939f489e82fbf0d9c787d107adfefd981eb129bb +size 82476 diff --git a/work_files/graphics/fonts/thai_variable.psd b/work_files/graphics/fonts/thai_variable.psd index 0fcd2e8a4..fc1131f86 100644 --- a/work_files/graphics/fonts/thai_variable.psd +++ b/work_files/graphics/fonts/thai_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d9766bc65f072b421b5fc68d6a646f1c5bef4361dc12856e5aff4cfd1fb9b0c3 -size 131208 +oid sha256:0ac5658a4ee17f77b8aa0facd2279a590266069549e8fbac7a02603f15f857cc +size 139642 diff --git a/work_files/graphics/fonts/unipunct_variable.psd b/work_files/graphics/fonts/unipunct_variable.psd index feb9e0188..b7b1f800c 100644 --- a/work_files/graphics/fonts/unipunct_variable.psd +++ b/work_files/graphics/fonts/unipunct_variable.psd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d68c0c4adf6f51314e32586857bfb7e1ad1f51ebd3abec2f0e47592caed2375 -size 121173 +oid sha256:2e95a4878b55d3863aafbaed32afeea9cb9290b48d9cb0f45b1693d5d6059fae +size 213802 diff --git a/work_files/spatialAudioMixMat.xlsx b/work_files/spatialAudioMixMat.xlsx index 2658ccf92..72978a4d9 100644 Binary files a/work_files/spatialAudioMixMat.xlsx and b/work_files/spatialAudioMixMat.xlsx differ