Differential D15898 Diff 56015 source/blender/draw/engines/workbench/shaders/workbench_transparent_accum_frag.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/shaders/workbench_transparent_accum_frag.glsl
| #pragma BLENDER_REQUIRE(common_view_lib.glsl) | #pragma BLENDER_REQUIRE(common_view_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(workbench_common_lib.glsl) | #pragma BLENDER_REQUIRE(workbench_common_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(workbench_image_lib.glsl) | #pragma BLENDER_REQUIRE(workbench_image_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(workbench_matcap_lib.glsl) | #pragma BLENDER_REQUIRE(workbench_matcap_lib.glsl) | ||||
| #pragma BLENDER_REQUIRE(workbench_world_light_lib.glsl) | #pragma BLENDER_REQUIRE(workbench_world_light_lib.glsl) | ||||
| /* Special function only to be used with calculate_transparent_weight(). */ | /* Special function only to be used with calculate_transparent_weight(). */ | ||||
| float linear_zdepth(float depth, vec4 viewvecs[2], mat4 proj_mat) | float linear_zdepth(float depth, mat4 proj_mat) | ||||
| { | { | ||||
| if (proj_mat[3][3] == 0.0) { | if (proj_mat[3][3] == 0.0) { | ||||
| float d = 2.0 * depth - 1.0; | float d = 2.0 * depth - 1.0; | ||||
| return -proj_mat[3][2] / (d + proj_mat[2][2]); | return -proj_mat[3][2] / (d + proj_mat[2][2]); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Return depth from near plane. */ | /* Return depth from near plane. */ | ||||
fclem: Better replace local `viewvecs` with `drw_view.viewvecs` directly to avoid this issue in this… | |||||
Not Done Inline ActionsWill replace this case. This is a compilation error currently. The passing of array syntax is invalid in MSL, and instead the data type would need to be treated as a pointer, rather than a scalar type. As this is a pointer, address space is required. Pointers in MSL are implicitly thread local unless otherwise specified. In this case, as the data comes from a uniform constant buffer, the data type is of "constant" to global memory, and thus needs to be explicitly specified. One other way around this would be to instead pack the type into a struct and pass by value. MichaelPW: Will replace this case.
This is a compilation error currently. The passing of array syntax is… | |||||
| return depth * viewvecs[1].z; | return depth * drw_view.viewvecs[1].z; | ||||
| } | } | ||||
| } | } | ||||
| /* Based on : | /* Based on : | ||||
| * McGuire and Bavoil, Weighted Blended Order-Independent Transparency, Journal of | * McGuire and Bavoil, Weighted Blended Order-Independent Transparency, Journal of | ||||
| * Computer Graphics Techniques (JCGT), vol. 2, no. 2, 122–141, 2013 | * Computer Graphics Techniques (JCGT), vol. 2, no. 2, 122–141, 2013 | ||||
| */ | */ | ||||
| float calculate_transparent_weight(void) | float calculate_transparent_weight(void) | ||||
| { | { | ||||
| float z = linear_zdepth(gl_FragCoord.z, drw_view.viewvecs, drw_view.winmat); | float z = linear_zdepth(gl_FragCoord.z, drw_view.winmat); | ||||
| #if 0 | #if 0 | ||||
| /* Eq 10 : Good for surfaces with varying opacity (like particles) */ | /* Eq 10 : Good for surfaces with varying opacity (like particles) */ | ||||
| float a = min(1.0, alpha * 10.0) + 0.01; | float a = min(1.0, alpha * 10.0) + 0.01; | ||||
| float b = -gl_FragCoord.z * 0.95 + 1.0; | float b = -gl_FragCoord.z * 0.95 + 1.0; | ||||
| float w = a * a * a * 3e2 * b * b * b; | float w = a * a * a * 3e2 * b * b * b; | ||||
| #else | #else | ||||
| /* Eq 7 put more emphasis on surfaces closer to the view. */ | /* Eq 7 put more emphasis on surfaces closer to the view. */ | ||||
| // float w = 10.0 / (1e-5 + pow(abs(z) / 5.0, 2.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 7 */ | // float w = 10.0 / (1e-5 + pow(abs(z) / 5.0, 2.0) + pow(abs(z) / 200.0, 6.0)); /* Eq 7 */ | ||||
| ▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines | |||||
Better replace local viewvecs with drw_view.viewvecs directly to avoid this issue in this particular case.
However, I'm curious to know if this is a performance issue or a compilation error?