render: expose all params in mie sky shader
parent
2e643e69c3
commit
aa66b03929
|
@ -104,7 +104,7 @@
|
||||||
canvas.height = window.innerHeight;
|
canvas.height = window.innerHeight;
|
||||||
|
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
if (canvas.canResize) {
|
if (canvas.canResize && !window.isFullscreen) {
|
||||||
canvas.width = window.innerWidth;
|
canvas.width = window.innerWidth;
|
||||||
canvas.height = window.innerHeight;
|
canvas.height = window.innerHeight;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,19 @@
|
||||||
} else if (elem.msRequestFullscreen) { /* IE11 */
|
} else if (elem.msRequestFullscreen) { /* IE11 */
|
||||||
elem.msRequestFullscreen();
|
elem.msRequestFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// window.isFullscreen = 1; /* assume we have entered fullscreen mode. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function exitFullscreen() {
|
||||||
|
if (!document.webkitIsFullScreen && !document.mozFullScreen && !document.msFullscreenElement)
|
||||||
|
window.isFullscreen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// document.addEventListener('fullscreenchange', exitFullscreen, false);
|
||||||
|
// document.addEventListener('mozfullscreenchange', exitFullscreen, false);
|
||||||
|
// document.addEventListener('MSFullscreenChange', exitFullscreen, false);
|
||||||
|
// document.addEventListener('webkitfullscreenchange', exitFullscreen, false);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="index.worker.coi.min.js"></script>
|
<script src="index.worker.coi.min.js"></script>
|
||||||
|
|
|
@ -1,4 +1,13 @@
|
||||||
uniform vec3 uSunPos;// = vec3( 0, 0.1, -1 ); // = [0, Math.cos(theta) * 0.3 + 0.2, -1];
|
uniform vec3 uSunPos;
|
||||||
|
uniform vec3 uRayOrigin;
|
||||||
|
uniform float uSunIntensity;
|
||||||
|
uniform float uPlanetRadius;
|
||||||
|
uniform float uAtmosphereRadius;
|
||||||
|
uniform vec3 uRayleighScattering;
|
||||||
|
uniform float uMieScattering;
|
||||||
|
uniform float uRayleighScaleHeight;
|
||||||
|
uniform float uMieScaleHeight;
|
||||||
|
uniform float uMiePreferredDirection;
|
||||||
|
|
||||||
|
|
||||||
in vec3 v_direction;
|
in vec3 v_direction;
|
||||||
|
@ -10,17 +19,17 @@ vec3 atmosphere(vec3 r, vec3 r0, vec3 pSun, float iSun, float rPlanet, float rAt
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 color = atmosphere(
|
vec3 color = atmosphere(
|
||||||
normalize(v_direction), // normalized ray direction
|
normalize(v_direction), // normalized ray direction
|
||||||
vec3(0,6372e3,0), // ray origin
|
uRayOrigin, // ray origin
|
||||||
uSunPos, // position of the sun
|
uSunPos, // position of the sun
|
||||||
22.0, // intensity of the sun
|
uSunIntensity, // intensity of the sun
|
||||||
6371e3, // radius of the planet in meters
|
uPlanetRadius, // radius of the planet in meters
|
||||||
6471e3, // radius of the atmosphere in meters
|
uAtmosphereRadius, // radius of the atmosphere in meters
|
||||||
vec3(5.5e-6, 13.0e-6, 22.4e-6), // Rayleigh scattering coefficient
|
uRayleighScattering, // Rayleigh scattering coefficient
|
||||||
21e-6, // Mie scattering coefficient
|
uMieScattering, // Mie scattering coefficient
|
||||||
8e3, // Rayleigh scale height
|
uRayleighScaleHeight, // Rayleigh scale height
|
||||||
1.2e3, // Mie scale height
|
uMieScaleHeight, // Mie scale height
|
||||||
0.758 // Mie preferred scattering direction
|
uMiePreferredDirection // Mie preferred scattering direction
|
||||||
);
|
);
|
||||||
|
|
||||||
// Apply exposure.
|
// Apply exposure.
|
||||||
|
|
|
@ -341713,6 +341713,15 @@ skybox_t skybox(const char *asset, int flags) {
|
||||||
// set up mie defaults
|
// set up mie defaults
|
||||||
shader_bind(sky.program);
|
shader_bind(sky.program);
|
||||||
shader_vec3("uSunPos", vec3( 0, 0.1, -1 ));
|
shader_vec3("uSunPos", vec3( 0, 0.1, -1 ));
|
||||||
|
shader_vec3("uRayOrigin", vec3(0.0, 6372000.0, 0.0));
|
||||||
|
shader_float("uSunIntensity", 22.0);
|
||||||
|
shader_float("uPlanetRadius", 6371000.0);
|
||||||
|
shader_float("uAtmosphereRadius", 6471000.0);
|
||||||
|
shader_vec3("uRayleighScattering", vec3(5.5e-6, 13.0e-6, 22.4e-6));
|
||||||
|
shader_float("uMieScattering", 21e-6);
|
||||||
|
shader_float("uRayleighScaleHeight", 8000.0);
|
||||||
|
shader_float("uMieScaleHeight", 1200.0);
|
||||||
|
shader_float("uMiePreferredDirection", 0.758);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sky;
|
return sky;
|
||||||
|
|
|
@ -2399,6 +2399,15 @@ skybox_t skybox(const char *asset, int flags) {
|
||||||
// set up mie defaults
|
// set up mie defaults
|
||||||
shader_bind(sky.program);
|
shader_bind(sky.program);
|
||||||
shader_vec3("uSunPos", vec3( 0, 0.1, -1 ));
|
shader_vec3("uSunPos", vec3( 0, 0.1, -1 ));
|
||||||
|
shader_vec3("uRayOrigin", vec3(0.0, 6372000.0, 0.0));
|
||||||
|
shader_float("uSunIntensity", 22.0);
|
||||||
|
shader_float("uPlanetRadius", 6371000.0);
|
||||||
|
shader_float("uAtmosphereRadius", 6471000.0);
|
||||||
|
shader_vec3("uRayleighScattering", vec3(5.5e-6, 13.0e-6, 22.4e-6));
|
||||||
|
shader_float("uMieScattering", 21e-6);
|
||||||
|
shader_float("uRayleighScaleHeight", 8000.0);
|
||||||
|
shader_float("uMieScaleHeight", 1200.0);
|
||||||
|
shader_float("uMiePreferredDirection", 0.758);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sky;
|
return sky;
|
||||||
|
|
|
@ -12623,6 +12623,15 @@ skybox_t skybox(const char *asset, int flags) {
|
||||||
// set up mie defaults
|
// set up mie defaults
|
||||||
shader_bind(sky.program);
|
shader_bind(sky.program);
|
||||||
shader_vec3("uSunPos", vec3( 0, 0.1, -1 ));
|
shader_vec3("uSunPos", vec3( 0, 0.1, -1 ));
|
||||||
|
shader_vec3("uRayOrigin", vec3(0.0, 6372000.0, 0.0));
|
||||||
|
shader_float("uSunIntensity", 22.0);
|
||||||
|
shader_float("uPlanetRadius", 6371000.0);
|
||||||
|
shader_float("uAtmosphereRadius", 6471000.0);
|
||||||
|
shader_vec3("uRayleighScattering", vec3(5.5e-6, 13.0e-6, 22.4e-6));
|
||||||
|
shader_float("uMieScattering", 21e-6);
|
||||||
|
shader_float("uRayleighScaleHeight", 8000.0);
|
||||||
|
shader_float("uMieScaleHeight", 1200.0);
|
||||||
|
shader_float("uMiePreferredDirection", 0.758);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sky;
|
return sky;
|
||||||
|
|
Loading…
Reference in New Issue