Differential D13910 Diff 47374 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_shader_interface_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) | ||||
| #ifndef WORKBENCH_SHADER_SHARED_H | |||||
| /* Revealage is actually stored in transparentAccum alpha channel. | |||||
| * This is a workaround to older hardware not having separate blend equation per render target. */ | |||||
| layout(location = 0) out vec4 transparentAccum; | |||||
| layout(location = 1) out vec4 revealageAccum; | |||||
| /* NOTE: Blending will be skipped on objectId because output is a non-normalized integer buffer. */ | |||||
| layout(location = 2) out uint objectId; | |||||
| #endif | |||||
| /* 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, vec4 viewvecs[2], 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 { | ||||
| Show All 37 Lines | void main() | ||||
| vec3 color = color_interp; | vec3 color = color_interp; | ||||
| #ifdef V3D_SHADING_TEXTURE_COLOR | #ifdef V3D_SHADING_TEXTURE_COLOR | ||||
| color = workbench_image_color(uv_interp); | color = workbench_image_color(uv_interp); | ||||
| #endif | #endif | ||||
| #ifdef V3D_LIGHTING_MATCAP | #ifdef V3D_LIGHTING_MATCAP | ||||
| vec3 shaded_color = get_matcap_lighting(color, N, I); | vec3 shaded_color = get_matcap_lighting(matcap_diffuse_tx, matcap_specular_tx, color, N, I); | ||||
| #endif | #endif | ||||
| #ifdef V3D_LIGHTING_STUDIO | #ifdef V3D_LIGHTING_STUDIO | ||||
| vec3 shaded_color = get_world_lighting(color, roughness, metallic, N, I); | vec3 shaded_color = get_world_lighting(color, roughness, metallic, N, I); | ||||
| #endif | #endif | ||||
| #ifdef V3D_LIGHTING_FLAT | #ifdef V3D_LIGHTING_FLAT | ||||
| vec3 shaded_color = color; | vec3 shaded_color = color; | ||||
| #endif | #endif | ||||
| shaded_color *= get_shadow(N); | shaded_color *= get_shadow(N, forceShadowing); | ||||
| /* Listing 4 */ | /* Listing 4 */ | ||||
| float weight = calculate_transparent_weight() * alpha_interp; | float weight = calculate_transparent_weight() * alpha_interp; | ||||
| transparentAccum = vec4(shaded_color * weight, alpha_interp); | transparentAccum = vec4(shaded_color * weight, alpha_interp); | ||||
| revealageAccum = vec4(weight); | revealageAccum = vec4(weight); | ||||
| objectId = uint(object_id); | objectId = uint(object_id); | ||||
| } | } | ||||