@woosh/meep-engine 3.65.0 → 3.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/engine/graphics3/GraphicsEngine.d.ts.map +1 -1
- package/src/engine/graphics3/GraphicsEngine.js +4 -9
- package/src/engine/graphics3/load_cube_environment.js +3 -3
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/format/lut/cube/CubeLut.d.ts +38 -0
- package/src/format/lut/cube/CubeLut.d.ts.map +1 -0
- package/src/format/lut/cube/CubeLut.js +23 -0
- package/src/format/lut/cube/cube_read.d.ts +23 -0
- package/src/format/lut/cube/cube_read.d.ts.map +1 -0
- package/src/format/lut/cube/cube_read.js +199 -0
- package/src/format/lut/cube/cube_write.d.ts +15 -0
- package/src/format/lut/cube/cube_write.d.ts.map +1 -0
- package/src/format/lut/cube/cube_write.js +90 -0
- package/src/shade/playground/probe_clipmap/README.md +1 -0
- package/src/shade/playground/probe_clipmap/index.html +48 -0
- package/src/shade/playground/probe_clipmap/main.d.ts.map +1 -1
- package/src/shade/playground/probe_clipmap/main.js +36 -0
- package/src/shade/renderer/Renderer.d.ts +7 -0
- package/src/shade/renderer/Renderer.d.ts.map +1 -1
- package/src/shade/renderer/Renderer.js +225 -27
- package/src/shade/renderer/ShadeIndirectLightingMode.d.ts +1 -0
- package/src/shade/renderer/ShadeIndirectLightingMode.js +9 -0
- package/src/shade/renderer/atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.d.ts +22 -0
- package/src/shade/renderer/atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.js +160 -0
- package/src/shade/renderer/atmosphere/ATMOSPHERE_UNIT_SCALE.d.ts +45 -0
- package/src/shade/renderer/atmosphere/ATMOSPHERE_UNIT_SCALE.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/ATMOSPHERE_UNIT_SCALE.js +57 -0
- package/src/shade/renderer/atmosphere/GPUSky.d.ts +23 -8
- package/src/shade/renderer/atmosphere/GPUSky.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/GPUSky.js +91 -34
- package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts +17 -0
- package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/SAMPLER_SKY_LUT.js +55 -25
- package/src/shade/renderer/atmosphere/SceneAtmosphere.d.ts +164 -0
- package/src/shade/renderer/atmosphere/SceneAtmosphere.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/SceneAtmosphere.js +308 -0
- package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts +3 -12
- package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/chunk_get_multiscatter_values.js +52 -89
- package/src/shade/renderer/atmosphere/chunk_raymarch_sky_scattering.d.ts +14 -0
- package/src/shade/renderer/atmosphere/chunk_raymarch_sky_scattering.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/chunk_raymarch_sky_scattering.js +103 -0
- package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts +10 -4
- package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/chunk_sample_multiscatter_lut.js +95 -57
- package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts +10 -14
- package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/chunk_sample_transmittance_lut.js +97 -69
- package/src/shade/renderer/atmosphere/chunk_sky_irradiance_lut_encode_uv.d.ts +17 -0
- package/src/shade/renderer/atmosphere/chunk_sky_irradiance_lut_encode_uv.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/chunk_sky_irradiance_lut_encode_uv.js +117 -48
- package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts +8 -0
- package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/chunk_sky_lut_compute_uv.js +65 -35
- package/src/shade/renderer/atmosphere/compute_mie_absorption.d.ts +2 -1
- package/src/shade/renderer/atmosphere/compute_mie_absorption.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/compute_mie_absorption.js +6 -6
- package/src/shade/renderer/atmosphere/resolve_atmosphere_sun.d.ts +41 -0
- package/src/shade/renderer/atmosphere/resolve_atmosphere_sun.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/resolve_atmosphere_sun.js +123 -0
- package/src/shade/renderer/atmosphere/shader_multiscatter_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/shader_multiscatter_lut.js +21 -64
- package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.d.ts +6 -2
- package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/shader_sky_irradiance_lut.js +55 -179
- package/src/shade/renderer/atmosphere/shader_sky_view_lut.d.ts +7 -0
- package/src/shade/renderer/atmosphere/shader_sky_view_lut.d.ts.map +1 -0
- package/src/shade/renderer/atmosphere/shader_sky_view_lut.js +111 -0
- package/src/shade/renderer/atmosphere/shader_transmittance_lut.d.ts +0 -1
- package/src/shade/renderer/atmosphere/shader_transmittance_lut.d.ts.map +1 -1
- package/src/shade/renderer/atmosphere/shader_transmittance_lut.js +68 -79
- package/src/shade/renderer/deferred/shader_background.js +1 -1
- package/src/shade/renderer/deferred/shader_background_sky.d.ts +5 -0
- package/src/shade/renderer/deferred/shader_background_sky.d.ts.map +1 -0
- package/src/shade/renderer/deferred/shader_background_sky.js +130 -0
- package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +73 -4
- package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/ColorGrade.js +113 -7
- package/src/shade/renderer/deferred/tonemap/TONEMAP_PURKINJE_SHIFT.d.ts +12 -0
- package/src/shade/renderer/deferred/tonemap/TONEMAP_PURKINJE_SHIFT.d.ts.map +1 -0
- package/src/shade/renderer/deferred/tonemap/TONEMAP_PURKINJE_SHIFT.js +12 -0
- package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +15 -1
- package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/ToneMapper.js +31 -3
- package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.d.ts +26 -0
- package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.d.ts.map +1 -0
- package/src/shade/renderer/deferred/tonemap/chunk_tonemap_purkinje.js +55 -0
- package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts +2 -2
- package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/shader_tonemap_HDR_lut.js +6 -3
- package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts +3 -2
- package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/shader_tonemap_LDR_lut.js +7 -3
- package/src/shade/renderer/extension/ViewTextures.d.ts +3 -2
- package/src/shade/renderer/extension/ViewTextures.d.ts.map +1 -1
- package/src/shade/renderer/extension/ViewTextures.js +3 -2
- package/src/shade/renderer/fluid/GPUFluidCascade.d.ts +3 -3
- package/src/shade/renderer/fluid/GPUFluidCascadeStack.d.ts +1 -1
- package/src/shade/renderer/fluid/forcing/GPUFluidForcing.d.ts +6 -6
- package/src/shade/renderer/fluid/pressure/GPUFluidPressureSolve.d.ts +1 -1
- package/src/shade/renderer/fluid/query/GPUFluidQueries.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe/octahedral/shader_lpv_build_gbuffer.js +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts +20 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/GPUProbeClipmapGI.js +29 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_light.d.ts +47 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_light.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/chunk_probe_clipmap_hit_light.js +246 -0
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts +4 -15
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_light.js +8 -148
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts +4 -9
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/probe/shader_probe_clipmap_trace.js +9 -58
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +142 -0
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +938 -0
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +192 -0
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +231 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts +11 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeDebugView.js +25 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +110 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +197 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts +150 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +408 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.d.ts +23 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.js +63 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brick_origin.d.ts +24 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brick_origin.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brick_origin.js +61 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts +39 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.js +126 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.d.ts +21 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.js +74 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_march_distance.d.ts +20 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_march_distance.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_march_distance.js +26 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_ray_sort.d.ts +24 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_ray_sort.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_ray_sort.js +57 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.d.ts +22 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.js +53 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts +62 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.js +156 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_workgroup_sum.d.ts +18 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_workgroup_sum.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_workgroup_sum.js +50 -0
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts +21 -0
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/graph_screen_probe_debug_view.js +54 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts +67 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.js +509 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_debug.d.ts +20 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_debug.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_debug.js +128 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +62 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +478 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts +69 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.js +457 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts +27 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_indirect_lighting.js +219 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.d.ts +22 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.js +151 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.d.ts +66 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.js +301 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +59 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +364 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts +40 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts.map +1 -0
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.js +275 -0
- package/src/shade/renderer/grass/blade/GPUGrassBlades.d.ts.map +1 -1
- package/src/shade/renderer/grass/blade/GPUGrassBlades.js +17 -2
- package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts +18 -8
- package/src/shade/renderer/grass/blade/grass_blade_resolve.d.ts.map +1 -1
- package/src/shade/renderer/grass/blade/grass_blade_resolve.js +114 -32
- package/src/shade/renderer/light/GPULightCollection.d.ts +1 -1
- package/src/shade/renderer/light/GPULightCollection.d.ts.map +1 -1
- package/src/shade/renderer/light/GPULightCollection.js +213 -80
- package/src/shade/renderer/{atmosphere → light/environment}/chunk_sample_environment_color.d.ts +1 -2
- package/src/shade/renderer/light/environment/chunk_sample_environment_color.d.ts.map +1 -0
- package/src/shade/renderer/{atmosphere → light/environment}/chunk_sample_environment_color.js +3 -4
- package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
- package/src/shade/renderer/path_tracer/shader/chunk_render_trace_path.js +1 -1
- package/src/shade/renderer/postprocess/denoise/debug/graph_pass_debug_reprojection.js +1 -1
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts +35 -9
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.js +81 -11
- package/src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/eye/shader_autoexposure_adapt.js +4 -1
- package/src/shade/renderer/postprocess/motion_blur/MotionBlur.d.ts +1 -1
- package/src/shade/renderer/postprocess/motion_blur/MotionBlur.js +1 -1
- package/src/shade/renderer/postprocess/motion_blur/graph_postprocess_motion_blur.d.ts +1 -1
- package/src/shade/renderer/postprocess/motion_blur/graph_postprocess_motion_blur.js +1 -1
- package/src/shade/renderer/postprocess/motion_blur/shader_motion_blur_reconstruct.js +1 -1
- package/src/shade/renderer/postprocess/nss/NSS.d.ts +1 -1
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_add_hit_irradiance.js +2 -0
- package/src/shade/renderer/postprocess/ssr/resolve/chunk_ssr_sample_radiance.js +2 -0
- package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts +6 -0
- package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.js +9 -1
- package/src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/taa/shader_depth_occlusion_clip.js +4 -3
- package/src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.d.ts +17 -0
- package/src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/velocity/VELOCITY_BUFFER.js +16 -0
- package/src/shade/renderer/postprocess/velocity/chunk_velocity_texel.d.ts +21 -0
- package/src/shade/renderer/postprocess/velocity/chunk_velocity_texel.d.ts.map +1 -0
- package/src/shade/renderer/postprocess/velocity/chunk_velocity_texel.js +30 -0
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts +7 -5
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/velocity/graph_add_per_object_velocity.js +19 -17
- package/src/shade/renderer/rasterize/forward/chunk_forward_sample_indirect.js +2 -0
- package/src/shade/renderer/scene/GPUSceneContext.d.ts.map +1 -1
- package/src/shade/renderer/scene/GPUSceneContext.js +2 -1
- package/src/shade/renderer/scene/Scene.d.ts +9 -2
- package/src/shade/renderer/scene/Scene.d.ts.map +1 -1
- package/src/shade/renderer/scene/Scene.js +10 -2
- package/src/shade/renderer/shader/ImageShader.d.ts +24 -12
- package/src/shade/renderer/shader/ImageShader.d.ts.map +1 -1
- package/src/shade/renderer/shader/ImageShader.js +11 -8
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.d.ts +3 -1
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_HEIGHT_DECLARATION.js +11 -3
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts +2 -11
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_RADII_DECLARATION.js +23 -32
- package/src/shade/renderer/shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.d.ts +6 -0
- package/src/shade/renderer/shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/atmosphere/PLANET_RADIUS_DECLARATION.js +14 -2
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_height.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_height.js +4 -2
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_intersection.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_intersection.js +11 -3
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_atmosphere_ray_bounds.js +68 -69
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.d.ts +4 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_get_sun_transmittance.js +46 -39
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js +5 -3
- package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +6 -0
- package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +7 -0
- package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts +4 -4
- package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +86 -5
- package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts +73 -0
- package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.js +139 -0
- package/src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.d.ts +14 -0
- package/src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.js +30 -0
- package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.d.ts +21 -0
- package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.js +60 -0
- package/src/shade/renderer/shader/chunk/light/{sky/chunk_sample_sky_color.d.ts → io/chunk_light_get_sun.d.ts} +3 -6
- package/src/shade/renderer/shader/chunk/light/io/chunk_light_get_sun.d.ts.map +1 -0
- package/src/shade/renderer/shader/chunk/light/{sky/chunk_sample_sky_color.js → io/chunk_light_get_sun.js} +6 -26
- package/src/shade/renderer/shadow/sdf/cascade/shader_scene_sdf_soft_shadows.js +1 -1
- package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts +3 -1
- package/src/shade/renderer/volumetrics/GPUViewVolumetrics.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/GPUViewVolumetrics.js +4 -2
- package/src/shade/renderer/volumetrics/graph_build_volumetrics.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/graph_build_volumetrics.js +743 -739
- package/src/shade/renderer/volumetrics/irradiance_clipmap/chunk_irradiance_clipmap_gi_sample.js +2 -0
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +19 -17
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.d.ts.map +1 -1
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_scattering_lut.js +5 -3
- package/src/shade/renderer/water/chunk_water_gi.js +2 -0
- package/src/shade/renderer/water/query/GPUWaterQueries.d.ts +1 -1
- package/src/shade/renderer/wind/GPUSceneWind.d.ts +1 -1
- package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.d.ts +0 -2
- package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/make_sky_hosek.js +0 -45
- package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.d.ts +0 -2
- package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/make_sky_rtiw.js +0 -17
- package/src/engine/graphics/sh3/sky/hosek/README.md +0 -4
- package/src/engine/graphics/sh3/sky/hosek/data.d.ts +0 -17
- package/src/engine/graphics/sh3/sky/hosek/data.d.ts.map +0 -1
- package/src/engine/graphics/sh3/sky/hosek/data.js +0 -3744
- package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.d.ts +0 -2
- package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.d.ts.map +0 -1
- package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.js +0 -71
- package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.d.ts +0 -26
- package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.d.ts.map +0 -1
- package/src/engine/graphics/sh3/sky/hosek/render_hosek_sky_to_equirectangular.js +0 -70
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts +0 -22
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts.map +0 -1
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +0 -388
- package/src/engine/graphics3/make_default_environment.d.ts +0 -15
- package/src/engine/graphics3/make_default_environment.d.ts.map +0 -1
- package/src/engine/graphics3/make_default_environment.js +0 -111
- package/src/shade/renderer/atmosphere/MIE_G.d.ts +0 -6
- package/src/shade/renderer/atmosphere/MIE_G.d.ts.map +0 -1
- package/src/shade/renderer/atmosphere/MIE_G.js +0 -5
- package/src/shade/renderer/atmosphere/chunk_sample_environment_color.d.ts.map +0 -1
- package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_EARTH.d.ts +0 -4
- package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_EARTH.d.ts.map +0 -1
- package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_EARTH.js +0 -44
- package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_PARAMETERS_STRUCT.d.ts +0 -2
- package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_PARAMETERS_STRUCT.d.ts.map +0 -1
- package/src/shade/renderer/atmosphere/hillaire/ATMOSPHERE_PARAMETERS_STRUCT.js +0 -43
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_DENSITY_DECLARATION.d.ts +0 -3
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_DENSITY_DECLARATION.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/atmosphere/ATMOSPHERE_DENSITY_DECLARATION.js +0 -6
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_absorb.d.ts +0 -3
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_absorb.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_absorb.js +0 -18
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_optical_depth.d.ts +0 -14
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_optical_depth.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_optical_depth.js +0 -86
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.d.ts +0 -8
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_integrate_scattering.js +0 -125
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_planet_intersection.d.ts +0 -3
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_planet_intersection.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_planet_intersection.js +0 -17
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_sphere_intersection_nearest.d.ts +0 -3
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_sphere_intersection_nearest.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/atmosphere/chunk_sphere_intersection_nearest.js +0 -38
- package/src/shade/renderer/shader/chunk/atmosphere/hillaire/DENSITY_PROFILE_LAYER_STRUCT.d.ts +0 -16
- package/src/shade/renderer/shader/chunk/atmosphere/hillaire/DENSITY_PROFILE_LAYER_STRUCT.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/atmosphere/hillaire/DENSITY_PROFILE_LAYER_STRUCT.js +0 -28
- package/src/shade/renderer/shader/chunk/color/tonemap/purkinjie/chunk_apply_purkinjie_shift.d.ts +0 -11
- package/src/shade/renderer/shader/chunk/color/tonemap/purkinjie/chunk_apply_purkinjie_shift.d.ts.map +0 -1
- package/src/shade/renderer/shader/chunk/color/tonemap/purkinjie/chunk_apply_purkinjie_shift.js +0 -56
- package/src/shade/renderer/shader/chunk/light/sky/chunk_sample_sky_color.d.ts.map +0 -1
- package/src/shade/renderer/view/GPUViewSkyContext.d.ts +0 -26
- package/src/shade/renderer/view/GPUViewSkyContext.d.ts.map +0 -1
- package/src/shade/renderer/view/GPUViewSkyContext.js +0 -170
|
@@ -1,59 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ATMOSPHERE_PARAMETERS_STRUCT,
|
|
3
|
+
chunk_atmosphere_parameters
|
|
4
|
+
} from "../../../atmosphere/ATMOSPHERE_PARAMETERS_STRUCT.js";
|
|
1
5
|
import { CodeChunk } from "../../compiler/CodeChunk.js";
|
|
2
|
-
import { chunk_atmosphere_density } from "./chunk_atmosphere_density.js";
|
|
3
|
-
import { chunk_atmosphere_height } from "./chunk_atmosphere_height.js";
|
|
4
|
-
import { chunk_atmosphere_intersection } from "./chunk_atmosphere_intersection.js";
|
|
5
|
-
import { chunk_compute_extinction } from "./chunk_compute_extinction.js";
|
|
6
|
-
import { chunk_sphere_intersection } from "./chunk_sphere_intersection.js";
|
|
7
|
-
import { PLANET_CENTER_DECLARATION } from "./PLANET_CENTER_DECLARATION.js";
|
|
8
|
-
import { PLANET_RADIUS_DECLARATION } from "./PLANET_RADIUS_DECLARATION.js";
|
|
9
6
|
|
|
10
7
|
/**
|
|
11
|
-
*
|
|
8
|
+
* Integrates direct solar transmittance from `pos` along `sunDir` to the top of the atmosphere,
|
|
9
|
+
* returning zero when the ray intersects the planet sphere.
|
|
10
|
+
*
|
|
11
|
+
* @see "A Scalable and Production Ready Sky and Atmosphere Rendering Technique", Hillaire (2020)
|
|
12
12
|
* @type {CodeChunk}
|
|
13
13
|
*/
|
|
14
14
|
export const chunk_get_sun_transmittance = CodeChunk.from(
|
|
15
15
|
//language=WGSL
|
|
16
16
|
`
|
|
17
|
-
fn
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
fn get_sun_transmittance_rel_for(
|
|
18
|
+
atm: ${ATMOSPHERE_PARAMETERS_STRUCT.wgsl_ref},
|
|
19
|
+
rel: vec3<f32>,
|
|
20
|
+
sunDir: vec3<f32>,
|
|
21
|
+
sunTransmittanceSteps: f32
|
|
22
|
+
) -> vec3<f32> {
|
|
23
|
+
let bounds = atmosphere_ray_bounds_for(atm, rel, sunDir);
|
|
24
|
+
|
|
25
|
+
if (bounds.hits_ground) {
|
|
26
|
+
return vec3<f32>(0.0);
|
|
22
27
|
}
|
|
23
|
-
|
|
24
|
-
let ray_length =
|
|
28
|
+
|
|
29
|
+
let ray_length = bounds.t_max;
|
|
25
30
|
var t = 0.0;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// integrate optical depth
|
|
31
|
+
var transmittance = vec3<f32>(1.0);
|
|
32
|
+
|
|
30
33
|
for (var i = 0.0; i < sunTransmittanceSteps; i += 1.0) {
|
|
31
34
|
let f = (i + 0.3) / sunTransmittanceSteps;
|
|
32
|
-
|
|
33
35
|
let newT = f * ray_length;
|
|
34
36
|
let dt = newT - t;
|
|
35
37
|
t = newT;
|
|
36
|
-
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
transmittance *= exp(-dt * extinction);
|
|
45
|
-
|
|
38
|
+
|
|
39
|
+
let step_rel = rel + t * sunDir;
|
|
40
|
+
let local_height = length(step_rel) - atm.planet_radius;
|
|
41
|
+
let local_density = atmosphere_density_for(atm, local_height);
|
|
42
|
+
let extinction = atmosphere_extinction_for(atm, local_density);
|
|
43
|
+
|
|
44
|
+
transmittance *= exp(-dt * extinction);
|
|
46
45
|
}
|
|
47
|
-
|
|
46
|
+
|
|
48
47
|
return transmittance;
|
|
49
48
|
}
|
|
49
|
+
|
|
50
|
+
fn get_sun_transmittance_for(
|
|
51
|
+
atm: ${ATMOSPHERE_PARAMETERS_STRUCT.wgsl_ref},
|
|
52
|
+
pos_ws: vec3<f32>,
|
|
53
|
+
sunDir: vec3<f32>,
|
|
54
|
+
sunTransmittanceSteps: f32
|
|
55
|
+
) -> vec3<f32> {
|
|
56
|
+
let rel = atmosphere_position_relative_for(atm, pos_ws);
|
|
57
|
+
return get_sun_transmittance_rel_for(atm, rel, sunDir, sunTransmittanceSteps);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fn get_sun_transmittance(pos_ws: vec3<f32>, sunDir: vec3<f32>, sunTransmittanceSteps: f32) -> vec3<f32> {
|
|
61
|
+
return get_sun_transmittance_for(atmosphere_earth_parameters(), pos_ws, sunDir, sunTransmittanceSteps);
|
|
62
|
+
}
|
|
50
63
|
`, [
|
|
51
|
-
|
|
52
|
-
chunk_atmosphere_height,
|
|
53
|
-
chunk_atmosphere_density,
|
|
54
|
-
PLANET_RADIUS_DECLARATION,
|
|
55
|
-
PLANET_CENTER_DECLARATION,
|
|
56
|
-
chunk_atmosphere_intersection,
|
|
57
|
-
chunk_compute_extinction,
|
|
64
|
+
chunk_atmosphere_parameters,
|
|
58
65
|
]
|
|
59
|
-
);
|
|
66
|
+
);
|
package/src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_position_relative_to_planet_center.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunk_position_relative_to_planet_center.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js"],"names":[],"mappings":"AAIA,iEAUE;0BAbwB,6BAA6B"}
|
package/src/shade/renderer/shader/chunk/atmosphere/chunk_position_relative_to_planet_center.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { ATMOSPHERE_UNIT_SCALE_DECLARATION } from "../../../atmosphere/ATMOSPHERE_UNIT_SCALE.js";
|
|
1
2
|
import { CodeChunk } from "../../compiler/CodeChunk.js";
|
|
2
3
|
import { PLANET_CENTER_DECLARATION } from "./PLANET_CENTER_DECLARATION.js";
|
|
3
4
|
|
|
4
5
|
export const chunk_position_relative_to_planet_center = CodeChunk.from(
|
|
5
|
-
//language=WGSL
|
|
6
|
+
//language=WGSL
|
|
6
7
|
`
|
|
7
|
-
fn position_relative_to_planet_center(pos:vec3<f32>) -> vec3<f32> {
|
|
8
|
-
return pos - PLANET_CENTER;
|
|
8
|
+
fn position_relative_to_planet_center(pos: vec3<f32>) -> vec3<f32> {
|
|
9
|
+
return pos * METERS_TO_ATMOSPHERE_UNITS - PLANET_CENTER;
|
|
9
10
|
}
|
|
10
11
|
`, [
|
|
12
|
+
ATMOSPHERE_UNIT_SCALE_DECLARATION,
|
|
11
13
|
PLANET_CENTER_DECLARATION
|
|
12
14
|
]
|
|
13
15
|
);
|
|
@@ -9,6 +9,12 @@ export const M3_REC709_TO_AP1: Float64Array;
|
|
|
9
9
|
* @type {Float64Array}
|
|
10
10
|
*/
|
|
11
11
|
export const M3_AP1_TO_REC709: Float64Array;
|
|
12
|
+
/**
|
|
13
|
+
* AP1's contribution of each channel to Y, the row Unreal calls `AP1_RGB2Y`: the shader's `AP1_LUMINANCE`, for code that
|
|
14
|
+
* measures AP1 luma on the CPU.
|
|
15
|
+
* @type {Float64Array}
|
|
16
|
+
*/
|
|
17
|
+
export const AP1_LUMINANCE: Float64Array;
|
|
12
18
|
/**
|
|
13
19
|
* - `CRM_FROM_REC709_TO_AP1` and `CRM_FROM_AP1_TO_REC709`: {@link M3_REC709_TO_AP1} and its inverse.
|
|
14
20
|
* - `AP1_LUMINANCE`: AP1's contribution of each channel to Y, the row Unreal calls `AP1_RGB2Y`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_CRM_REC709_AP1.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,+BAFU,YAAY,CAE8B;AAIpD;;;GAGG;AACH,+BAFU,YAAY,CAE8B;
|
|
1
|
+
{"version":3,"file":"chunk_CRM_REC709_AP1.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,+BAFU,YAAY,CAE8B;AAIpD;;;GAGG;AACH,+BAFU,YAAY,CAE8B;AAGpD;;;;GAIG;AACH,4BAFU,YAAY,CAEoE;AAW1F;;;;;;;GAOG;AACH,mCAFU,SAAS,CASjB;0BAhEwB,gCAAgC"}
|
|
@@ -35,6 +35,13 @@ m3_multiply(M3_REC709_TO_AP1, XYZ_TO_AP1, M3_REC709_TO_AP1);
|
|
|
35
35
|
export const M3_AP1_TO_REC709 = new Float64Array(9);
|
|
36
36
|
m3_invert(M3_AP1_TO_REC709, M3_REC709_TO_AP1);
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
* AP1's contribution of each channel to Y, the row Unreal calls `AP1_RGB2Y`: the shader's `AP1_LUMINANCE`, for code that
|
|
40
|
+
* measures AP1 luma on the CPU.
|
|
41
|
+
* @type {Float64Array}
|
|
42
|
+
*/
|
|
43
|
+
export const AP1_LUMINANCE = Float64Array.of(AP1_TO_XYZ[3], AP1_TO_XYZ[4], AP1_TO_XYZ[5]);
|
|
44
|
+
|
|
38
45
|
/**
|
|
39
46
|
* @param {Float64Array} m row-major
|
|
40
47
|
* @returns {string} a WGSL `mat3x3<f32>` constructor, column by column
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `color_grade(scene, grade, keys)`: exposed scene-linear Rec.709 through a {@link ColorGrade}, white balance, then
|
|
3
|
-
* primaries, then hue curves, to Rec.709 again, not negative. `grade` is the grade's
|
|
4
|
-
* `keys` the curves' keyframes. See `ColorGrade` for what each stage does.
|
|
3
|
+
* primaries, then saturation against luma, then hue curves, to Rec.709 again, not negative. `grade` is the grade's
|
|
4
|
+
* {@link COLOR_GRADE_STRUCT} and `keys` the curves' keyframes. See `ColorGrade` for what each stage does.
|
|
5
5
|
*
|
|
6
|
-
* Also defines each stage on its own: `color_grade_primaries(ap1, grade)
|
|
7
|
-
* `color_grade_hue_curves(color, counts, keys)`.
|
|
6
|
+
* Also defines each stage on its own: `color_grade_primaries(ap1, grade)`,
|
|
7
|
+
* `color_grade_luma_saturation(ap1, counts, keys, first)` and `color_grade_hue_curves(color, counts, keys)`.
|
|
8
8
|
*
|
|
9
9
|
* @type {CodeChunk}
|
|
10
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk_color_grade.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,gCAFU,SAAS,
|
|
1
|
+
{"version":3,"file":"chunk_color_grade.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,gCAFU,SAAS,CA2MjB;0BAzNwB,gCAAgC"}
|
|
@@ -9,11 +9,11 @@ import { chunk_oklab_to_linear_srgb } from "../oklab/chunk_oklab_to_linear_srgb.
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* `color_grade(scene, grade, keys)`: exposed scene-linear Rec.709 through a {@link ColorGrade}, white balance, then
|
|
12
|
-
* primaries, then hue curves, to Rec.709 again, not negative. `grade` is the grade's
|
|
13
|
-
* `keys` the curves' keyframes. See `ColorGrade` for what each stage does.
|
|
12
|
+
* primaries, then saturation against luma, then hue curves, to Rec.709 again, not negative. `grade` is the grade's
|
|
13
|
+
* {@link COLOR_GRADE_STRUCT} and `keys` the curves' keyframes. See `ColorGrade` for what each stage does.
|
|
14
14
|
*
|
|
15
|
-
* Also defines each stage on its own: `color_grade_primaries(ap1, grade)
|
|
16
|
-
* `color_grade_hue_curves(color, counts, keys)`.
|
|
15
|
+
* Also defines each stage on its own: `color_grade_primaries(ap1, grade)`,
|
|
16
|
+
* `color_grade_luma_saturation(ap1, counts, keys, first)` and `color_grade_hue_curves(color, counts, keys)`.
|
|
17
17
|
*
|
|
18
18
|
* @type {CodeChunk}
|
|
19
19
|
*/
|
|
@@ -65,6 +65,78 @@ fn color_grade_primaries(ap1: vec3<f32>, grade: ${COLOR_GRADE_STRUCT.wgsl_ref})
|
|
|
65
65
|
return shadows * weight_shadows + midtones * weight_midtones + highlights * weight_highlights;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
// each AP1 channel drawn away from the luma by its factor, read at the luma's stops from middle grey: the all-channel
|
|
69
|
+
// curve times the channel's own; counts are the red, green, blue and all-channel curves' keys, in that order, starting
|
|
70
|
+
// at key 'first'
|
|
71
|
+
fn color_grade_luma_saturation(
|
|
72
|
+
ap1: vec3<f32>,
|
|
73
|
+
counts: vec4<u32>,
|
|
74
|
+
keys: ptr<storage, array<${ANIMATION_CURVE_KEYFRAME_STRUCT.wgsl_ref}>, read>,
|
|
75
|
+
first: u32,
|
|
76
|
+
) -> vec3<f32> {
|
|
77
|
+
let luma = dot(ap1, AP1_LUMINANCE);
|
|
78
|
+
|
|
79
|
+
// a colour with no luma has no tonal place to read the curves at, and nothing to saturate
|
|
80
|
+
if (all(counts == vec4<u32>(0u)) || luma <= 0.0) {
|
|
81
|
+
return ap1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
let stops = log2(luma / 0.18);
|
|
85
|
+
|
|
86
|
+
var saturation = vec3<f32>(1.0);
|
|
87
|
+
|
|
88
|
+
if (counts.x > 0u) {
|
|
89
|
+
saturation.x = animation_curve_evaluate_keys(keys, first, counts.x, stops);
|
|
90
|
+
}
|
|
91
|
+
if (counts.y > 0u) {
|
|
92
|
+
saturation.y = animation_curve_evaluate_keys(keys, first + counts.x, counts.y, stops);
|
|
93
|
+
}
|
|
94
|
+
if (counts.z > 0u) {
|
|
95
|
+
saturation.z = animation_curve_evaluate_keys(keys, first + counts.x + counts.y, counts.z, stops);
|
|
96
|
+
}
|
|
97
|
+
if (counts.w > 0u) {
|
|
98
|
+
saturation *= animation_curve_evaluate_keys(keys, first + counts.x + counts.y + counts.z, counts.w, stops);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return max(vec3<f32>(0.0), mix(vec3<f32>(luma), ap1, saturation));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// each AP1 channel multiplied by its gain, and every channel by 2^exposure, read at the luma's stops from middle grey;
|
|
105
|
+
// counts are the red, green and blue gain curves' keys and the exposure curve's, in that order, starting at key 'first'
|
|
106
|
+
fn color_grade_luma_gain(
|
|
107
|
+
ap1: vec3<f32>,
|
|
108
|
+
counts: vec4<u32>,
|
|
109
|
+
keys: ptr<storage, array<${ANIMATION_CURVE_KEYFRAME_STRUCT.wgsl_ref}>, read>,
|
|
110
|
+
first: u32,
|
|
111
|
+
) -> vec3<f32> {
|
|
112
|
+
let luma = dot(ap1, AP1_LUMINANCE);
|
|
113
|
+
|
|
114
|
+
// a colour with no luma has no tonal place to read the curves at
|
|
115
|
+
if (all(counts == vec4<u32>(0u)) || luma <= 0.0) {
|
|
116
|
+
return ap1;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let stops = log2(luma / 0.18);
|
|
120
|
+
|
|
121
|
+
var gain = vec3<f32>(1.0);
|
|
122
|
+
var exposure = 0.0;
|
|
123
|
+
|
|
124
|
+
if (counts.x > 0u) {
|
|
125
|
+
gain.x = animation_curve_evaluate_keys(keys, first, counts.x, stops);
|
|
126
|
+
}
|
|
127
|
+
if (counts.y > 0u) {
|
|
128
|
+
gain.y = animation_curve_evaluate_keys(keys, first + counts.x, counts.y, stops);
|
|
129
|
+
}
|
|
130
|
+
if (counts.z > 0u) {
|
|
131
|
+
gain.z = animation_curve_evaluate_keys(keys, first + counts.x + counts.y, counts.z, stops);
|
|
132
|
+
}
|
|
133
|
+
if (counts.w > 0u) {
|
|
134
|
+
exposure = animation_curve_evaluate_keys(keys, first + counts.x + counts.y + counts.z, counts.w, stops);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return max(vec3<f32>(0.0), ap1 * gain * exp2(exposure));
|
|
138
|
+
}
|
|
139
|
+
|
|
68
140
|
// hue shift, chroma scale and lightness against OkLCh hue; counts.xyz are the three curves' keys, in that order
|
|
69
141
|
fn color_grade_hue_curves(
|
|
70
142
|
color: vec3<f32>,
|
|
@@ -123,7 +195,16 @@ fn color_grade(
|
|
|
123
195
|
) -> vec3<f32> {
|
|
124
196
|
let white_balance = mat3x3<f32>(grade.white_balance_c0.xyz, grade.white_balance_c1.xyz, grade.white_balance_c2.xyz);
|
|
125
197
|
|
|
126
|
-
let
|
|
198
|
+
let primaries = color_grade_primaries(CRM_FROM_REC709_TO_AP1 * (white_balance * scene), grade);
|
|
199
|
+
|
|
200
|
+
// the luma curves' keys follow the hue curves': saturation's, then gain's
|
|
201
|
+
let counts = grade.curve_counts;
|
|
202
|
+
let saturation_counts = grade.luma_curve_counts;
|
|
203
|
+
let hue_keys = counts.x + counts.y + counts.z;
|
|
204
|
+
let saturation_keys = saturation_counts.x + saturation_counts.y + saturation_counts.z + saturation_counts.w;
|
|
205
|
+
|
|
206
|
+
let gained = color_grade_luma_gain(primaries, grade.luma_gain_counts, keys, hue_keys + saturation_keys);
|
|
207
|
+
let ap1 = color_grade_luma_saturation(gained, saturation_counts, keys, hue_keys);
|
|
127
208
|
|
|
128
209
|
let graded = max(CRM_FROM_AP1_TO_REC709 * ap1, vec3<f32>(0.0));
|
|
129
210
|
|
package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much of the eye's response is the rods', at an adaptation, across a response range: 1 at and below `rods_below`,
|
|
3
|
+
* 0 at and above `cones_above`, linear in log luminance in between. CIE 191's range is
|
|
4
|
+
* {@link PURKINJE_MESOPIC_MIN_NITS} to {@link PURKINJE_MESOPIC_MAX_NITS}. The share `apply_purkinje_shift` blends by,
|
|
5
|
+
* for code that needs it on the CPU.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} adaptation_luminance cd/m²
|
|
8
|
+
* @param {number} rods_below cd/m², over 0
|
|
9
|
+
* @param {number} cones_above cd/m², over `rods_below`
|
|
10
|
+
* @returns {number} 0 to 1
|
|
11
|
+
*/
|
|
12
|
+
export function purkinje_rod_share(adaptation_luminance: number, rods_below: number, cones_above: number): number;
|
|
13
|
+
/**
|
|
14
|
+
* Rec.709 photopic luminance weights: what the cones see of a linear Rec.709 colour.
|
|
15
|
+
* @type {ReadonlyArray<number>}
|
|
16
|
+
*/
|
|
17
|
+
export const PURKINJE_REC709_PHOTOPIC: ReadonlyArray<number>;
|
|
18
|
+
/**
|
|
19
|
+
* Rec.709 scotopic luminance weights: what the rods see of a linear Rec.709 colour. They sum to 1, so a grey has the
|
|
20
|
+
* same scotopic luminance as photopic.
|
|
21
|
+
* @type {ReadonlyArray<number>}
|
|
22
|
+
*/
|
|
23
|
+
export const PURKINJE_REC709_SCOTOPIC: ReadonlyArray<number>;
|
|
24
|
+
/**
|
|
25
|
+
* "Rod blue": the colour the scotopic signal is carried by. Artistic: (0.3, 0.5, 0.9) mimics the sensation of the
|
|
26
|
+
* rods' 507 nm peak.
|
|
27
|
+
* @type {ReadonlyArray<number>}
|
|
28
|
+
*/
|
|
29
|
+
export const PURKINJE_NIGHT_TINT: ReadonlyArray<number>;
|
|
30
|
+
/**
|
|
31
|
+
* CIE 191's mesopic range, cd/m²: rods alone below the lower bound (scotopic), cones alone above the upper (photopic).
|
|
32
|
+
* The response range of the tone mapper's run-time shift.
|
|
33
|
+
*/
|
|
34
|
+
export const PURKINJE_MESOPIC_MIN_NITS: 0.005;
|
|
35
|
+
export const PURKINJE_MESOPIC_MAX_NITS: 5;
|
|
36
|
+
/**
|
|
37
|
+
* Purkinje shift.
|
|
38
|
+
* Human vision system shifts color perception away from red in night-time conditions.
|
|
39
|
+
*
|
|
40
|
+
* ```wgsl
|
|
41
|
+
* fn purkinje_rod_share(adaptation_luminance: f32, rods_below: f32, cones_above: f32) -> f32
|
|
42
|
+
* fn apply_purkinje_shift(color_rec709: vec3<f32>, rod_share: f32) -> vec3<f32>
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* `purkinje_rod_share` is how much of the eye's response is the rods' at `adaptation_luminance`, the luminance the eye
|
|
46
|
+
* is adapted to, across a response range, all in cd/m²: 1 at and below `rods_below`, 0 at and above `cones_above`
|
|
47
|
+
* (which must be over `rods_below`, itself over 0), linear in log luminance in between. CIE 191's mesopic range,
|
|
48
|
+
* `PURKINJE_MESOPIC_MIN_NITS` to `PURKINJE_MESOPIC_MAX_NITS` (0.005 to 5 cd/m²), is the eye's.
|
|
49
|
+
*
|
|
50
|
+
* `apply_purkinje_shift` blends `color_rec709`, scene-linear Rec.709, towards the rod response by `rod_share`: at 0 the
|
|
51
|
+
* colour is returned as it is; at 1 it is the rod response alone, its scotopic luminance carried by a blue tint. The
|
|
52
|
+
* shift is linear in the colour, so it gives the same result ahead of the exposure as after it.
|
|
53
|
+
*
|
|
54
|
+
* The constants are the module's exports ({@link PURKINJE_REC709_SCOTOPIC} and the rest), and
|
|
55
|
+
* {@link purkinje_rod_share} is the share on the CPU.
|
|
56
|
+
*
|
|
57
|
+
* NOTE: this should go before the tonemapper.
|
|
58
|
+
*
|
|
59
|
+
* Notes on deriving it from the rod and cone responses: PURKINJE_PHYSICAL_DERIVATION_NOTES.md, beside this file.
|
|
60
|
+
*
|
|
61
|
+
* @see J. Patry, "Real-Time Samurai Cinema: Lighting, Atmosphere, and Tonemapping in Ghost of Tsushima", Advances in
|
|
62
|
+
* Real-Time Rendering in Games, SIGGRAPH 2021 — the primary reference.
|
|
63
|
+
* https://www.advances.realtimerendering.com/s2021/jpatry_advances2021/index.html
|
|
64
|
+
* @see A. G. Kirk, J. F. O'Brien, "Perceptually based tone mapping for low-light conditions", ACM TOG 30(4), 2011.
|
|
65
|
+
* https://www2.eecs.berkeley.edu/Pubs/TechRpts/2011/EECS-2011-91.pdf
|
|
66
|
+
* @see D. Cao, J. Pokorny, V. C. Smith, A. J. Zele, "Rod contributions to color perception: linear with rod
|
|
67
|
+
* contrast", Vision Research 48(26), 2008.
|
|
68
|
+
*
|
|
69
|
+
* @type {CodeChunk}
|
|
70
|
+
*/
|
|
71
|
+
export const chunk_apply_purkinje_shift: CodeChunk;
|
|
72
|
+
import { CodeChunk } from "../../../../compiler/CodeChunk.js";
|
|
73
|
+
//# sourceMappingURL=chunk_apply_purkinje_shift.d.ts.map
|
package/src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_apply_purkinje_shift.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/shade/renderer/shader/chunk/color/tonemap/purkinje/chunk_apply_purkinje_shift.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;GAUG;AACH,yDALW,MAAM,cACN,MAAM,eACN,MAAM,GACJ,MAAM,CAQlB;AA5CD;;;GAGG;AACH,uCAFU,cAAc,MAAM,CAAC,CAEiD;AAEhF;;;;GAIG;AACH,uCAFU,cAAc,MAAM,CAAC,CAEiD;AAEhF;;;;GAIG;AACH,kCAFU,cAAc,MAAM,CAAC,CAEmC;AAElE;;;GAGG;AACH,8CAA+C;AAC/C,0CAA2C;AAsC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,yCAFU,SAAS,CAwCjB;0BA1IwB,mCAAmC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../../compiler/CodeChunk.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rec.709 photopic luminance weights: what the cones see of a linear Rec.709 colour.
|
|
5
|
+
* @type {ReadonlyArray<number>}
|
|
6
|
+
*/
|
|
7
|
+
export const PURKINJE_REC709_PHOTOPIC = Object.freeze([0.2126, 0.7152, 0.0722]);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Rec.709 scotopic luminance weights: what the rods see of a linear Rec.709 colour. They sum to 1, so a grey has the
|
|
11
|
+
* same scotopic luminance as photopic.
|
|
12
|
+
* @type {ReadonlyArray<number>}
|
|
13
|
+
*/
|
|
14
|
+
export const PURKINJE_REC709_SCOTOPIC = Object.freeze([0.0070, 0.5190, 0.4740]);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* "Rod blue": the colour the scotopic signal is carried by. Artistic: (0.3, 0.5, 0.9) mimics the sensation of the
|
|
18
|
+
* rods' 507 nm peak.
|
|
19
|
+
* @type {ReadonlyArray<number>}
|
|
20
|
+
*/
|
|
21
|
+
export const PURKINJE_NIGHT_TINT = Object.freeze([0.3, 0.5, 0.9]);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* CIE 191's mesopic range, cd/m²: rods alone below the lower bound (scotopic), cones alone above the upper (photopic).
|
|
25
|
+
* The response range of the tone mapper's run-time shift.
|
|
26
|
+
*/
|
|
27
|
+
export const PURKINJE_MESOPIC_MIN_NITS = 0.005;
|
|
28
|
+
export const PURKINJE_MESOPIC_MAX_NITS = 5;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* How much of the eye's response is the rods', at an adaptation, across a response range: 1 at and below `rods_below`,
|
|
32
|
+
* 0 at and above `cones_above`, linear in log luminance in between. CIE 191's range is
|
|
33
|
+
* {@link PURKINJE_MESOPIC_MIN_NITS} to {@link PURKINJE_MESOPIC_MAX_NITS}. The share `apply_purkinje_shift` blends by,
|
|
34
|
+
* for code that needs it on the CPU.
|
|
35
|
+
*
|
|
36
|
+
* @param {number} adaptation_luminance cd/m²
|
|
37
|
+
* @param {number} rods_below cd/m², over 0
|
|
38
|
+
* @param {number} cones_above cd/m², over `rods_below`
|
|
39
|
+
* @returns {number} 0 to 1
|
|
40
|
+
*/
|
|
41
|
+
export function purkinje_rod_share(adaptation_luminance, rods_below, cones_above) {
|
|
42
|
+
const low = Math.log(rods_below);
|
|
43
|
+
const high = Math.log(cones_above);
|
|
44
|
+
const t = (Math.log(Math.min(Math.max(adaptation_luminance, rods_below), cones_above)) - low) / (high - low);
|
|
45
|
+
|
|
46
|
+
return 1 - Math.min(1, Math.max(0, t));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {number} value
|
|
51
|
+
* @returns {string} as a WGSL float literal, with a point
|
|
52
|
+
*/
|
|
53
|
+
function wgsl_float(value) {
|
|
54
|
+
const text = String(value);
|
|
55
|
+
return /[.e]/.test(text) ? text : `${text}.0`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {ReadonlyArray<number>} v
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
function wgsl_vec3(v) {
|
|
63
|
+
return `vec3<f32>(${v.map(wgsl_float).join(", ")})`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Purkinje shift.
|
|
68
|
+
* Human vision system shifts color perception away from red in night-time conditions.
|
|
69
|
+
*
|
|
70
|
+
* ```wgsl
|
|
71
|
+
* fn purkinje_rod_share(adaptation_luminance: f32, rods_below: f32, cones_above: f32) -> f32
|
|
72
|
+
* fn apply_purkinje_shift(color_rec709: vec3<f32>, rod_share: f32) -> vec3<f32>
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* `purkinje_rod_share` is how much of the eye's response is the rods' at `adaptation_luminance`, the luminance the eye
|
|
76
|
+
* is adapted to, across a response range, all in cd/m²: 1 at and below `rods_below`, 0 at and above `cones_above`
|
|
77
|
+
* (which must be over `rods_below`, itself over 0), linear in log luminance in between. CIE 191's mesopic range,
|
|
78
|
+
* `PURKINJE_MESOPIC_MIN_NITS` to `PURKINJE_MESOPIC_MAX_NITS` (0.005 to 5 cd/m²), is the eye's.
|
|
79
|
+
*
|
|
80
|
+
* `apply_purkinje_shift` blends `color_rec709`, scene-linear Rec.709, towards the rod response by `rod_share`: at 0 the
|
|
81
|
+
* colour is returned as it is; at 1 it is the rod response alone, its scotopic luminance carried by a blue tint. The
|
|
82
|
+
* shift is linear in the colour, so it gives the same result ahead of the exposure as after it.
|
|
83
|
+
*
|
|
84
|
+
* The constants are the module's exports ({@link PURKINJE_REC709_SCOTOPIC} and the rest), and
|
|
85
|
+
* {@link purkinje_rod_share} is the share on the CPU.
|
|
86
|
+
*
|
|
87
|
+
* NOTE: this should go before the tonemapper.
|
|
88
|
+
*
|
|
89
|
+
* Notes on deriving it from the rod and cone responses: PURKINJE_PHYSICAL_DERIVATION_NOTES.md, beside this file.
|
|
90
|
+
*
|
|
91
|
+
* @see J. Patry, "Real-Time Samurai Cinema: Lighting, Atmosphere, and Tonemapping in Ghost of Tsushima", Advances in
|
|
92
|
+
* Real-Time Rendering in Games, SIGGRAPH 2021 — the primary reference.
|
|
93
|
+
* https://www.advances.realtimerendering.com/s2021/jpatry_advances2021/index.html
|
|
94
|
+
* @see A. G. Kirk, J. F. O'Brien, "Perceptually based tone mapping for low-light conditions", ACM TOG 30(4), 2011.
|
|
95
|
+
* https://www2.eecs.berkeley.edu/Pubs/TechRpts/2011/EECS-2011-91.pdf
|
|
96
|
+
* @see D. Cao, J. Pokorny, V. C. Smith, A. J. Zele, "Rod contributions to color perception: linear with rod
|
|
97
|
+
* contrast", Vision Research 48(26), 2008.
|
|
98
|
+
*
|
|
99
|
+
* @type {CodeChunk}
|
|
100
|
+
*/
|
|
101
|
+
export const chunk_apply_purkinje_shift = CodeChunk.from(
|
|
102
|
+
//language=WGSL
|
|
103
|
+
`
|
|
104
|
+
const PURKINJE_REC709_PHOTOPIC = ${wgsl_vec3(PURKINJE_REC709_PHOTOPIC)}; // Day (Cones)
|
|
105
|
+
const PURKINJE_REC709_SCOTOPIC = ${wgsl_vec3(PURKINJE_REC709_SCOTOPIC)}; // Night (Rods) - Validated
|
|
106
|
+
const PURKINJE_NIGHT_TINT = ${wgsl_vec3(PURKINJE_NIGHT_TINT)};
|
|
107
|
+
const PURKINJE_MESOPIC_MIN_NITS = ${wgsl_float(PURKINJE_MESOPIC_MIN_NITS)}; // Rods dominate below this
|
|
108
|
+
const PURKINJE_MESOPIC_MAX_NITS = ${wgsl_float(PURKINJE_MESOPIC_MAX_NITS)}; // Cones dominate above this
|
|
109
|
+
|
|
110
|
+
// how much of the response is the rods', linear in log luminance across the response range: a perceptually linear
|
|
111
|
+
// transition
|
|
112
|
+
fn purkinje_rod_share(adaptation_luminance: f32, rods_below: f32, cones_above: f32) -> f32 {
|
|
113
|
+
let logLum = log(clamp(adaptation_luminance, rods_below, cones_above));
|
|
114
|
+
|
|
115
|
+
let logLow = log(rods_below);
|
|
116
|
+
let logHigh = log(cones_above);
|
|
117
|
+
let logDelta = logHigh - logLow;
|
|
118
|
+
|
|
119
|
+
return 1.0 - saturate( (logLum - logLow) / logDelta );
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fn apply_purkinje_shift(
|
|
123
|
+
color_rec709: vec3<f32>,
|
|
124
|
+
rod_share: f32
|
|
125
|
+
) -> vec3<f32>{
|
|
126
|
+
// 1. Calculate Rod Luminance (Night)
|
|
127
|
+
// Note: Red objects will have a near-zero Y_night, making them turn black.
|
|
128
|
+
// Blue objects will have a high Y_night, making them appear brighter.
|
|
129
|
+
let Y_night = dot(color_rec709, PURKINJE_REC709_SCOTOPIC);
|
|
130
|
+
|
|
131
|
+
// 2. Construct the Night Vision Image
|
|
132
|
+
// We treat the rod signal as a scalar intensity applied to our blue tint
|
|
133
|
+
let color_night = Y_night * PURKINJE_NIGHT_TINT;
|
|
134
|
+
|
|
135
|
+
// 3. Lerp from Day view to Night view, by the rods' share
|
|
136
|
+
return mix(color_rec709, color_night, rod_share);
|
|
137
|
+
}
|
|
138
|
+
`
|
|
139
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The device depth a camera's projection gives a view depth, the inverse of {@link chunk_get_view_space_depth}:
|
|
3
|
+
*
|
|
4
|
+
* ```wgsl
|
|
5
|
+
* fn get_device_depth(view_depth: f32, camera: CameraUniforms) -> f32
|
|
6
|
+
* ```
|
|
7
|
+
*
|
|
8
|
+
* Reverse Z, as `device_depth_to_view_space` is ({@link compute_device_depth_to_view_space_depth_params}).
|
|
9
|
+
*
|
|
10
|
+
* @type {CodeChunk}
|
|
11
|
+
*/
|
|
12
|
+
export const chunk_get_device_depth: CodeChunk;
|
|
13
|
+
import { CodeChunk } from "../../compiler/CodeChunk.js";
|
|
14
|
+
//# sourceMappingURL=chunk_get_device_depth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_get_device_depth.d.ts","sourceRoot":"","sources":["../../../../../../../src/shade/renderer/shader/chunk/depth/chunk_get_device_depth.js"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,qCAFU,SAAS,CAiBjB;0BA5BwB,6BAA6B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CAMERA_UNIFORM_STRUCT } from "../../../camera/CAMERA_UNIFORM_STRUCT.js";
|
|
2
|
+
import { CodeChunk } from "../../compiler/CodeChunk.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The device depth a camera's projection gives a view depth, the inverse of {@link chunk_get_view_space_depth}:
|
|
6
|
+
*
|
|
7
|
+
* ```wgsl
|
|
8
|
+
* fn get_device_depth(view_depth: f32, camera: CameraUniforms) -> f32
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Reverse Z, as `device_depth_to_view_space` is ({@link compute_device_depth_to_view_space_depth_params}).
|
|
12
|
+
*
|
|
13
|
+
* @type {CodeChunk}
|
|
14
|
+
*/
|
|
15
|
+
export const chunk_get_device_depth = CodeChunk.from(
|
|
16
|
+
//language=WGSL
|
|
17
|
+
`
|
|
18
|
+
fn get_device_depth(
|
|
19
|
+
view_depth: f32,
|
|
20
|
+
camera: ${CAMERA_UNIFORM_STRUCT.wgsl_ref}
|
|
21
|
+
) -> f32 {
|
|
22
|
+
|
|
23
|
+
let device_to_view_depth = camera.device_depth_to_view_space;
|
|
24
|
+
|
|
25
|
+
return device_to_view_depth.y / view_depth - device_to_view_depth.x;
|
|
26
|
+
}
|
|
27
|
+
`, [
|
|
28
|
+
CAMERA_UNIFORM_STRUCT.declaration_chunk,
|
|
29
|
+
]
|
|
30
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clarberg's equal-area mapping between the unit square and the unit sphere, octahedrally folded: every
|
|
3
|
+
* region of the square covers 4π times its area of the sphere, so a regular n×n grid of texels splits the
|
|
4
|
+
* sphere into texels of 4π/n² steradians each, and a point drawn uniformly inside a texel is a direction drawn
|
|
5
|
+
* uniformly over that texel's solid angle.
|
|
6
|
+
*
|
|
7
|
+
* ```wgsl
|
|
8
|
+
* fn uv_equal_area_sphere_decode(uv: vec2<f32>) -> vec3<f32> // the square [0, 1]² to a unit vector
|
|
9
|
+
* fn uv_equal_area_sphere_encode(direction: vec3<f32>) -> vec2<f32> // any non-zero vector to the square
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* The square's diamond |2u−1| + |2v−1| ≤ 1 is the +z hemisphere and its centre +z; the four corners meet at −z.
|
|
13
|
+
* The fold is the standard octahedral one, so the square's edges join as an octahedral map's do.
|
|
14
|
+
*
|
|
15
|
+
* @see Petrik Clarberg, "Fast Equal-Area Mapping of the (Hemi)Sphere using SIMD", Journal of Graphics Tools
|
|
16
|
+
* 13(3), 2008
|
|
17
|
+
* @type {CodeChunk}
|
|
18
|
+
*/
|
|
19
|
+
export const chunk_uv_equal_area_sphere: CodeChunk;
|
|
20
|
+
import { CodeChunk } from "../../../compiler/CodeChunk.js";
|
|
21
|
+
//# sourceMappingURL=chunk_uv_equal_area_sphere.d.ts.map
|
package/src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk_uv_equal_area_sphere.d.ts","sourceRoot":"","sources":["../../../../../../../../src/shade/renderer/shader/chunk/geometry/octahedron/chunk_uv_equal_area_sphere.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,yCAFU,SAAS,CAwCZ;0BA3DmB,gCAAgC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { CodeChunk } from "../../../compiler/CodeChunk.js";
|
|
2
|
+
import { PI_DECLARATION } from "../../math/PI_DECLARATION.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Clarberg's equal-area mapping between the unit square and the unit sphere, octahedrally folded: every
|
|
6
|
+
* region of the square covers 4π times its area of the sphere, so a regular n×n grid of texels splits the
|
|
7
|
+
* sphere into texels of 4π/n² steradians each, and a point drawn uniformly inside a texel is a direction drawn
|
|
8
|
+
* uniformly over that texel's solid angle.
|
|
9
|
+
*
|
|
10
|
+
* ```wgsl
|
|
11
|
+
* fn uv_equal_area_sphere_decode(uv: vec2<f32>) -> vec3<f32> // the square [0, 1]² to a unit vector
|
|
12
|
+
* fn uv_equal_area_sphere_encode(direction: vec3<f32>) -> vec2<f32> // any non-zero vector to the square
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* The square's diamond |2u−1| + |2v−1| ≤ 1 is the +z hemisphere and its centre +z; the four corners meet at −z.
|
|
16
|
+
* The fold is the standard octahedral one, so the square's edges join as an octahedral map's do.
|
|
17
|
+
*
|
|
18
|
+
* @see Petrik Clarberg, "Fast Equal-Area Mapping of the (Hemi)Sphere using SIMD", Journal of Graphics Tools
|
|
19
|
+
* 13(3), 2008
|
|
20
|
+
* @type {CodeChunk}
|
|
21
|
+
*/
|
|
22
|
+
export const chunk_uv_equal_area_sphere = CodeChunk.from(
|
|
23
|
+
//language=WGSL
|
|
24
|
+
`
|
|
25
|
+
fn uv_equal_area_sphere_decode(uv: vec2<f32>) -> vec3<f32> {
|
|
26
|
+
let s = fma(uv, vec2<f32>(2.0), vec2<f32>(-1.0));
|
|
27
|
+
let d = 1.0 - (abs(s.x) + abs(s.y));
|
|
28
|
+
let r = 1.0 - abs(d);
|
|
29
|
+
|
|
30
|
+
// the square's centre and corners are the poles, where r is zero and the azimuth is any
|
|
31
|
+
let phi = select((PI * 0.25) * ((abs(s.y) - abs(s.x)) / r + 1.0), 0.0, r == 0.0);
|
|
32
|
+
let f = r * sqrt(2.0 - r * r);
|
|
33
|
+
|
|
34
|
+
return vec3<f32>(
|
|
35
|
+
f * sign(s.x) * abs(cos(phi)),
|
|
36
|
+
f * sign(s.y) * abs(sin(phi)),
|
|
37
|
+
sign(d) * (1.0 - r * r),
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fn uv_equal_area_sphere_encode(direction: vec3<f32>) -> vec2<f32> {
|
|
42
|
+
let n = normalize(direction);
|
|
43
|
+
let a = abs(n);
|
|
44
|
+
let r = sqrt(max(1.0 - a.z, 0.0));
|
|
45
|
+
|
|
46
|
+
// the azimuth in the quadrant, 0 along x to 1 along y; on the z axis r is zero and it is never read
|
|
47
|
+
let tangent = min(a.x, a.y) / max(max(a.x, a.y), 1e-30);
|
|
48
|
+
let half_turn = atan(tangent) * (2.0 / PI);
|
|
49
|
+
let phi = select(half_turn, 1.0 - half_turn, a.x < a.y);
|
|
50
|
+
|
|
51
|
+
var folded = vec2<f32>(r - phi * r, phi * r);
|
|
52
|
+
|
|
53
|
+
folded = select(folded, 1.0 - folded.yx, n.z < 0.0);
|
|
54
|
+
folded = select(folded, -folded, n.xy < vec2<f32>(0.0));
|
|
55
|
+
|
|
56
|
+
return fma(folded, vec2<f32>(0.5), vec2<f32>(0.5));
|
|
57
|
+
}
|
|
58
|
+
`, [
|
|
59
|
+
PI_DECLARATION,
|
|
60
|
+
]);
|