Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl')
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl140
1 files changed, 52 insertions, 88 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
index 0a3252f0b9b..c7e74a789ac 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
@@ -1,110 +1,74 @@
-#ifndef HAIR_SHADER
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(workbench_common_lib.glsl)
+
+IN_OUT ShaderStageInterface
+{
+ vec3 normal_interp;
+ vec3 color_interp;
+ vec2 uv_interp;
+ flat float packed_rough_metal;
+ flat int object_id;
+};
+
+#ifdef GPU_VERTEX_SHADER
+
in vec3 pos;
in vec3 nor;
-in vec2 au; /* active texture layer */
-# ifdef V3D_SHADING_VERTEX_COLOR
in vec4 ac; /* active color */
-# endif
-# define uv au
-#else /* HAIR_SHADER */
+in vec2 au; /* active texture layer */
-# ifdef V3D_SHADING_TEXTURE_COLOR
-uniform samplerBuffer au; /* active texture layer */
-# endif
-# ifdef V3D_SHADING_VERTEX_COLOR
-uniform samplerBuffer ac; /* active color layer */
+void main()
+{
+ vec3 world_pos = point_object_to_world(pos);
+ gl_Position = point_world_to_ndc(world_pos);
+
+# ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance(world_pos);
# endif
-flat out float hair_rand;
-#endif /* HAIR_SHADER */
+ uv_interp = au;
+ color_interp = vec3(0.9); // ac.rgb;
-#ifdef NORMAL_VIEWPORT_PASS_ENABLED
-out vec3 normal_viewport;
-#endif
+ normal_interp = normalize(normal_object_to_view(nor));
-#ifdef V3D_SHADING_TEXTURE_COLOR
-out vec2 uv_interp;
-#endif
-#ifdef V3D_SHADING_VERTEX_COLOR
-out vec3 vertexColor;
-#endif
+ // float metallic = materialColorAndMetal.a;
+ // float roughness = materialRoughness;
-#ifdef OBJECT_ID_PASS_ENABLED
-RESOURCE_ID_VARYING
-#endif
+ float metallic = 0.0;
+ float roughness = 0.0;
-/* From http://libnoise.sourceforge.net/noisegen/index.html */
-float integer_noise(int n)
-{
- n = (n >> 13) ^ n;
- int nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
- return (float(nn) / 1073741824.0);
-}
+ if (metallic == -1.0) {
+ /* Matcap Case. */
+ packed_rough_metal = -1.0;
+ }
+ else {
+ packed_rough_metal = workbench_float_pair_encode(roughness, metallic);
+ }
-vec3 workbench_hair_hair_normal(vec3 tan, vec3 binor, float rand)
-{
- /* To "simulate" anisotropic shading, randomize hair normal per strand. */
- vec3 nor = cross(tan, binor);
- nor = normalize(mix(nor, -tan, rand * 0.1));
- float cos_theta = (rand * 2.0 - 1.0) * 0.2;
- float sin_theta = sqrt(max(0.0, 1.0 - cos_theta * cos_theta));
- nor = nor * sin_theta + binor * cos_theta;
- return nor;
+ object_id = int((uint(resource_id) + 1u) & 0xFFu);
}
+#else
+
+layout(location = 0) out vec4 materialData;
+layout(location = 1) out WB_Normal normalData;
+layout(location = 2) out uint objectId;
+
void main()
{
-#ifdef HAIR_SHADER
-# ifdef V3D_SHADING_TEXTURE_COLOR
- vec2 uv = hair_get_customdata_vec2(au);
-# endif
- float time, thick_time, thickness;
- vec3 world_pos, tan, binor;
- hair_get_pos_tan_binor_time((ProjectionMatrix[3][3] == 0.0),
- ModelMatrixInverse,
- ViewMatrixInverse[3].xyz,
- ViewMatrixInverse[2].xyz,
- world_pos,
- tan,
- binor,
- time,
- thickness,
- thick_time);
-
- hair_rand = integer_noise(hair_get_strand_id());
- vec3 nor = workbench_hair_hair_normal(tan, binor, hair_rand);
-#else
- vec3 world_pos = point_object_to_world(pos);
-#endif
- gl_Position = point_world_to_ndc(world_pos);
+ normalData = workbench_normal_encode(gl_FrontFacing, normal_interp);
-#ifdef V3D_SHADING_TEXTURE_COLOR
- uv_interp = uv;
-#endif
+ materialData = vec4(color_interp, packed_rough_metal);
-#ifdef V3D_SHADING_VERTEX_COLOR
-# ifndef HAIR_SHADER
- vertexColor = ac.rgb;
-# else
- vertexColor = hair_get_customdata_vec4(ac).rgb;
-# endif
-#endif
+ objectId = uint(object_id);
-#ifdef NORMAL_VIEWPORT_PASS_ENABLED
-# ifndef HAIR_SHADER
- normal_viewport = normal_object_to_view(nor);
- normal_viewport = normalize(normal_viewport);
-# else
- normal_viewport = normal_world_to_view(nor);
-# endif
-#endif
+ if (materialData.a == -1.0) {
+ /* For matcaps, save front facing in alpha channel. */
+ materialData.a = float(gl_FrontFacing);
+ }
-#ifdef OBJECT_ID_PASS_ENABLED
- PASS_RESOURCE_ID
-#endif
+ // materialData.rgb *= workbench_image_color(uv_interp);
+}
-#ifdef USE_WORLD_CLIP_PLANES
- world_clip_planes_calc_clip_distance(world_pos);
#endif
-}