Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
| #pragma BLENDER_REQUIRE(engine_eevee_legacy_shared.h) | |||||
| #pragma BLENDER_REQUIRE(common_math_geom_lib.glsl) | #pragma BLENDER_REQUIRE(common_math_geom_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(common_view_lib.glsl) | #pragma BLENDER_REQUIRE(common_view_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(common_utiltex_lib.glsl) | #pragma BLENDER_REQUIRE(common_utiltex_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(common_uniforms_lib.glsl) | #pragma BLENDER_REQUIRE(common_uniforms_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(cubemap_lib.glsl) | #pragma BLENDER_REQUIRE(cubemap_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(ambient_occlusion_lib.glsl) | #pragma BLENDER_REQUIRE(ambient_occlusion_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(irradiance_lib.glsl) | #pragma BLENDER_REQUIRE(irradiance_lib.glsl) | ||||
| /* ----------- Uniforms --------- */ | /* ----------- Uniforms --------- */ | ||||
| #if !defined(USE_GPU_SHADER_CREATE_INFO) | |||||
| uniform sampler2DArray probePlanars; | uniform sampler2DArray probePlanars; | ||||
| uniform samplerCubeArray probeCubes; | uniform samplerCubeArray probeCubes; | ||||
| /* ----------- Structures --------- */ | #endif | ||||
| struct CubeData { | /* ----------- Structures --------- */ | ||||
| vec4 position_type; | |||||
| vec4 attenuation_fac_type; | |||||
| mat4 influencemat; | |||||
| mat4 parallaxmat; | |||||
| }; | |||||
| #define PROBE_PARALLAX_BOX 1.0 | #define PROBE_PARALLAX_BOX 1.0 | ||||
| #define PROBE_ATTENUATION_BOX 1.0 | #define PROBE_ATTENUATION_BOX 1.0 | ||||
| #define p_position position_type.xyz | #define p_position position_type.xyz | ||||
| #define p_parallax_type position_type.w | #define p_parallax_type position_type.w | ||||
| #define p_atten_fac attenuation_fac_type.x | #define p_atten_fac attenuation_fac_type.x | ||||
| #define p_atten_type attenuation_fac_type.y | #define p_atten_type attenuation_fac_type.y | ||||
| struct PlanarData { | |||||
| vec4 plane_equation; | |||||
| vec4 clip_vec_x_fade_scale; | |||||
| vec4 clip_vec_y_fade_bias; | |||||
| vec4 clip_edges; | |||||
| vec4 facing_scale_bias; | |||||
| mat4 reflectionmat; /* transform world space into reflection texture space */ | |||||
| mat4 unused; | |||||
| }; | |||||
| #define pl_plane_eq plane_equation | #define pl_plane_eq plane_equation | ||||
| #define pl_normal plane_equation.xyz | #define pl_normal plane_equation.xyz | ||||
| #define pl_facing_scale facing_scale_bias.x | #define pl_facing_scale facing_scale_bias.x | ||||
| #define pl_facing_bias facing_scale_bias.y | #define pl_facing_bias facing_scale_bias.y | ||||
| #define pl_fade_scale clip_vec_x_fade_scale.w | #define pl_fade_scale clip_vec_x_fade_scale.w | ||||
| #define pl_fade_bias clip_vec_y_fade_bias.w | #define pl_fade_bias clip_vec_y_fade_bias.w | ||||
| #define pl_clip_pos_x clip_vec_x_fade_scale.xyz | #define pl_clip_pos_x clip_vec_x_fade_scale.xyz | ||||
| #define pl_clip_pos_y clip_vec_y_fade_bias.xyz | #define pl_clip_pos_y clip_vec_y_fade_bias.xyz | ||||
| #define pl_clip_edges clip_edges | #define pl_clip_edges clip_edges | ||||
| struct GridData { | |||||
| mat4 localmat; | |||||
| ivec4 resolution_offset; | |||||
| vec4 ws_corner_atten_scale; /* world space corner position */ | |||||
| vec4 ws_increment_x_atten_bias; /* world space vector between 2 opposite cells */ | |||||
| vec4 ws_increment_y_lvl_bias; | |||||
| vec4 ws_increment_z; | |||||
| vec4 vis_bias_bleed_range; | |||||
| }; | |||||
| #define g_corner ws_corner_atten_scale.xyz | #define g_corner ws_corner_atten_scale.xyz | ||||
| #define g_atten_scale ws_corner_atten_scale.w | #define g_atten_scale ws_corner_atten_scale.w | ||||
| #define g_atten_bias ws_increment_x_atten_bias.w | #define g_atten_bias ws_increment_x_atten_bias.w | ||||
| #define g_level_bias ws_increment_y_lvl_bias.w | #define g_level_bias ws_increment_y_lvl_bias.w | ||||
| #define g_increment_x ws_increment_x_atten_bias.xyz | #define g_increment_x ws_increment_x_atten_bias.xyz | ||||
| #define g_increment_y ws_increment_y_lvl_bias.xyz | #define g_increment_y ws_increment_y_lvl_bias.xyz | ||||
| #define g_increment_z ws_increment_z.xyz | #define g_increment_z ws_increment_z.xyz | ||||
| #define g_resolution resolution_offset.xyz | #define g_resolution resolution_offset.xyz | ||||
| #define g_offset resolution_offset.w | #define g_offset resolution_offset.w | ||||
| #define g_vis_bias vis_bias_bleed_range.x | #define g_vis_bias vis_bias_bleed_range.x | ||||
| #define g_vis_bleed vis_bias_bleed_range.y | #define g_vis_bleed vis_bias_bleed_range.y | ||||
| #define g_vis_range vis_bias_bleed_range.z | #define g_vis_range vis_bias_bleed_range.z | ||||
| #ifndef MAX_PROBE | #ifndef MAX_PROBE | ||||
| # define MAX_PROBE 1 | # define MAX_PROBE 1 | ||||
| #endif | #endif | ||||
| #ifndef MAX_GRID | #ifndef MAX_GRID | ||||
| # define MAX_GRID 1 | # define MAX_GRID 1 | ||||
| #endif | #endif | ||||
| #ifndef MAX_PLANAR | #ifndef MAX_PLANAR | ||||
| # define MAX_PLANAR 1 | # define MAX_PLANAR 1 | ||||
| #endif | #endif | ||||
| #if !defined(USE_GPU_SHADER_CREATE_INFO) | |||||
| layout(std140) uniform probe_block | layout(std140) uniform probe_block | ||||
| { | { | ||||
| CubeData probes_data[MAX_PROBE]; | ProbeBlock _probe_block; | ||||
| }; | }; | ||||
| layout(std140) uniform grid_block | layout(std140) uniform grid_block | ||||
| { | { | ||||
| GridData grids_data[MAX_GRID]; | GridBlock _grid_block; | ||||
| }; | }; | ||||
| layout(std140) uniform planar_block | layout(std140) uniform planar_block | ||||
| { | { | ||||
| PlanarData planars_data[MAX_PLANAR]; | PlanarBlock _planar_block; | ||||
| }; | }; | ||||
| # define probes_data _probe_block.probes_data | |||||
| # define grids_data _grid_block.grids_data | |||||
| # define planars_data _planar_block.planars_data | |||||
| #endif | |||||
| /* ----------- Functions --------- */ | /* ----------- Functions --------- */ | ||||
| float probe_attenuation_cube(int pd_id, vec3 P) | float probe_attenuation_cube(int pd_id, vec3 P) | ||||
| { | { | ||||
| vec3 localpos = transform_point(probes_data[pd_id].influencemat, P); | vec3 localpos = transform_point(probes_data[pd_id].influencemat, P); | ||||
| float probe_atten_fac = probes_data[pd_id].p_atten_fac; | float probe_atten_fac = probes_data[pd_id].p_atten_fac; | ||||
| float fac; | float fac; | ||||
| ▲ Show 20 Lines • Show All 204 Lines • Show Last 20 Lines | |||||