Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl
| Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | float probe_attenuation_planar(PlanarData pd, vec3 W, vec3 N, float roughness) | ||||
| fac *= step(2.0, dot(step(pd.pl_clip_edges, dist_to_clip.xxyy), vec2(-1.0, 1.0).xyxy)); | fac *= step(2.0, dot(step(pd.pl_clip_edges, dist_to_clip.xxyy), vec2(-1.0, 1.0).xyxy)); | ||||
| /* Decrease influence for high roughness */ | /* Decrease influence for high roughness */ | ||||
| fac *= saturate(1.0 - roughness * 10.0); | fac *= saturate(1.0 - roughness * 10.0); | ||||
| return fac; | return fac; | ||||
| } | } | ||||
| float probe_attenuation_grid(GridData gd, mat4 localmat, vec3 W, out vec3 localpos) | float probe_attenuation_grid(GridData gd, vec3 W, out vec3 localpos) | ||||
| { | { | ||||
| localpos = transform_point(localmat, W); | localpos = transform_point(gd.localmat, W); | ||||
| vec3 pos_to_edge = max(vec3(0.0), abs(localpos) - 1.0); | vec3 pos_to_edge = max(vec3(0.0), abs(localpos) - 1.0); | ||||
| float fade = length(pos_to_edge); | float fade = length(pos_to_edge); | ||||
| return saturate(-fade * gd.g_atten_scale + gd.g_atten_bias); | return saturate(-fade * gd.g_atten_scale + gd.g_atten_bias); | ||||
| } | } | ||||
| vec3 probe_evaluate_cube(int pd_id, vec3 W, vec3 R, float roughness) | vec3 probe_evaluate_cube(int pd_id, vec3 W, vec3 R, float roughness) | ||||
| { | { | ||||
| /* Correct reflection ray using parallax volume intersection. */ | /* Correct reflection ray using parallax volume intersection. */ | ||||
| Show All 27 Lines | vec3 probe_evaluate_cube(int pd_id, vec3 W, vec3 R, float roughness) | ||||
| return textureLod_cubemapArray(probeCubes, vec4(R, float(pd_id)), roughness * prbLodCubeMax).rgb; | return textureLod_cubemapArray(probeCubes, vec4(R, float(pd_id)), roughness * prbLodCubeMax).rgb; | ||||
| } | } | ||||
| vec3 probe_evaluate_world_spec(vec3 R, float roughness) | vec3 probe_evaluate_world_spec(vec3 R, float roughness) | ||||
| { | { | ||||
| return textureLod_cubemapArray(probeCubes, vec4(R, 0.0), roughness * prbLodCubeMax).rgb; | return textureLod_cubemapArray(probeCubes, vec4(R, 0.0), roughness * prbLodCubeMax).rgb; | ||||
| } | } | ||||
| vec3 probe_evaluate_planar( | vec3 probe_evaluate_planar(int id, PlanarData pd, vec3 W, vec3 N, vec3 V, float roughness) | ||||
| float id, PlanarData pd, vec3 W, vec3 N, vec3 V, float roughness, inout float fade) | |||||
| { | { | ||||
| /* Find view vector / reflection plane intersection. */ | /* Find view vector / reflection plane intersection. */ | ||||
| vec3 point_on_plane = line_plane_intersect(W, V, pd.pl_plane_eq); | vec3 point_on_plane = line_plane_intersect(W, V, pd.pl_plane_eq); | ||||
| /* How far the pixel is from the plane. */ | /* How far the pixel is from the plane. */ | ||||
| float ref_depth = 1.0; /* TODO parameter */ | float ref_depth = 1.0; /* TODO parameter */ | ||||
| /* Compute distorded reflection vector based on the distance to the reflected object. | /* Compute distorded reflection vector based on the distance to the reflected object. | ||||
| Show All 25 Lines | void fallback_cubemap(vec3 N, | ||||
| inout vec4 spec_accum) | inout vec4 spec_accum) | ||||
| { | { | ||||
| /* Specular probes */ | /* Specular probes */ | ||||
| vec3 spec_dir = specular_dominant_dir(N, V, roughnessSquared); | vec3 spec_dir = specular_dominant_dir(N, V, roughnessSquared); | ||||
| #ifdef SSR_AO | #ifdef SSR_AO | ||||
| vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy); | vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy); | ||||
| vec3 bent_normal; | vec3 bent_normal; | ||||
| float final_ao = occlusion_compute(N, viewPosition, 1.0, rand, bent_normal); | float final_ao = occlusion_compute(N, viewPosition, rand, bent_normal); | ||||
| final_ao = specular_occlusion(dot(N, V), final_ao, roughness); | final_ao = specular_occlusion(dot(N, V), final_ao, roughness); | ||||
| #else | #else | ||||
| const float final_ao = 1.0; | const float final_ao = 1.0; | ||||
| #endif | #endif | ||||
| /* Starts at 1 because 0 is world probe */ | /* Starts at 1 because 0 is world probe */ | ||||
| for (int i = 1; i < MAX_PROBE && i < prbNumRenderCube && spec_accum.a < 0.999; i++) { | for (int i = 1; i < MAX_PROBE && i < prbNumRenderCube && spec_accum.a < 0.999; i++) { | ||||
| float fade = probe_attenuation_cube(i, W); | float fade = probe_attenuation_cube(i, W); | ||||
| ▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines | |||||