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.glsl58
1 files changed, 31 insertions, 27 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 66372f82b89..dd737063f61 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
@@ -10,7 +10,7 @@ uniform mat3 NormalMatrix;
in vec3 pos;
in vec3 nor;
in vec2 u; /* active texture layer */
-#define uv u
+# define uv u
#else /* HAIR_SHADER */
# ifdef V3D_SHADING_TEXTURE_COLOR
uniform samplerBuffer u; /* active texture layer */
@@ -29,49 +29,53 @@ out vec2 uv_interp;
/* 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);
+ n = (n >> 13) ^ n;
+ int nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
+ return (float(nn) / 1073741824.0);
}
void main()
{
#ifdef HAIR_SHADER
# ifdef V3D_SHADING_TEXTURE_COLOR
- vec2 uv = hair_get_customdata_vec2(u);
+ vec2 uv = hair_get_customdata_vec2(u);
# endif
- float time, thick_time, thickness;
- vec3 pos, tan, binor;
- hair_get_pos_tan_binor_time(
- (ProjectionMatrix[3][3] == 0.0),
- ModelMatrixInverse,
- ViewMatrixInverse[3].xyz, ViewMatrixInverse[2].xyz,
- pos, tan, binor, time, thickness, thick_time);
- /* To "simulate" anisotropic shading, randomize hair normal per strand. */
- hair_rand = integer_noise(hair_get_strand_id());
- tan = normalize(tan);
- vec3 nor = normalize(cross(binor, tan));
- nor = normalize(mix(nor, -tan, hair_rand * 0.10));
- float cos_theta = (hair_rand*2.0 - 1.0) * 0.20;
- float sin_theta = sqrt(max(0.0, 1.0f - cos_theta*cos_theta));
- nor = nor * sin_theta + binor * cos_theta;
- gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
+ float time, thick_time, thickness;
+ vec3 pos, tan, binor;
+ hair_get_pos_tan_binor_time((ProjectionMatrix[3][3] == 0.0),
+ ModelMatrixInverse,
+ ViewMatrixInverse[3].xyz,
+ ViewMatrixInverse[2].xyz,
+ pos,
+ tan,
+ binor,
+ time,
+ thickness,
+ thick_time);
+ /* To "simulate" anisotropic shading, randomize hair normal per strand. */
+ hair_rand = integer_noise(hair_get_strand_id());
+ tan = normalize(tan);
+ vec3 nor = normalize(cross(binor, tan));
+ nor = normalize(mix(nor, -tan, hair_rand * 0.10));
+ float cos_theta = (hair_rand * 2.0 - 1.0) * 0.20;
+ float sin_theta = sqrt(max(0.0, 1.0f - cos_theta * cos_theta));
+ nor = nor * sin_theta + binor * cos_theta;
+ gl_Position = ViewProjectionMatrix * vec4(pos, 1.0);
#else
- gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
#endif
#ifdef V3D_SHADING_TEXTURE_COLOR
- uv_interp = uv;
+ uv_interp = uv;
#endif
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
- normal_viewport = NormalMatrix * nor;
+ normal_viewport = NormalMatrix * nor;
# ifndef HAIR_SHADER
- normal_viewport = normalize(normal_viewport);
+ normal_viewport = normalize(normal_viewport);
# endif
#endif
#ifdef USE_WORLD_CLIP_PLANES
- world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
-
}