a9c84e11aa66124a5924d59314509ea99ea5f299
[blender.git] / source / blender / draw / engines / workbench / shaders / workbench_forward_transparent_accum_frag.glsl
1 #ifdef OB_TEXTURE
2 uniform sampler2D image;
3 #endif
4 uniform mat3 normalWorldMatrix;
5 uniform float alpha = 0.5;
6
7 #ifdef NORMAL_VIEWPORT_PASS_ENABLED
8 in vec3 normal_viewport;
9 #endif /* NORMAL_VIEWPORT_PASS_ENABLED */
10 #ifdef OB_TEXTURE
11 in vec2 uv_interp;
12 #endif
13
14 layout(std140) uniform world_block {
15         WorldData world_data;
16 };
17
18 layout(std140) uniform material_block {
19         MaterialData material_data;
20 };
21
22 layout(location=0) out vec4 transparentAccum;
23
24
25 void main()
26 {
27         vec4 diffuse_color;
28 #ifdef OB_SOLID
29         diffuse_color = material_data.diffuse_color;
30 #endif /* OB_SOLID */
31 #ifdef OB_TEXTURE
32         diffuse_color = texture(image, uv_interp);
33 #endif /* OB_TEXTURE */
34
35 #ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
36         vec3 specular_color = get_world_specular_lights(world_data, vec4(material_data.specular_color.rgb, material_data.roughness), normal_viewport, vec3(0.0, 0.0, 1.0));
37 #else
38         vec3 specular_color = vec3(0.0);
39 #endif
40
41 #ifdef V3D_LIGHTING_STUDIO
42 #  ifdef STUDIOLIGHT_ORIENTATION_CAMERA
43         vec3 diffuse_light = get_camera_diffuse_light(world_data, normal_viewport);
44 #  endif
45 #  ifdef STUDIOLIGHT_ORIENTATION_WORLD
46         vec3 normal_world = normalWorldMatrix * normal_viewport;
47         vec3 diffuse_light = get_world_diffuse_light(world_data, normal_world);
48 #  endif
49         vec3 shaded_color = diffuse_light * diffuse_color.rgb + specular_color;
50 #else
51         vec3 shaded_color = diffuse_color.rgb + specular_color;
52 #endif
53
54         vec4 premultiplied = vec4(shaded_color.rgb * alpha, alpha);
55         transparentAccum = calculate_transparent_accum(premultiplied);
56 }
57