Differential D4694 Diff 14803 source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
| uniform mat4 ModelViewProjectionMatrix; | uniform mat4 ModelViewProjectionMatrix; | ||||
| uniform mat4 ModelMatrix; | uniform mat4 ModelMatrix; | ||||
| uniform mat4 ModelMatrixInverse; | uniform mat4 ModelMatrixInverse; | ||||
| uniform mat4 ProjectionMatrix; | uniform mat4 ProjectionMatrix; | ||||
| uniform mat4 ViewProjectionMatrix; | uniform mat4 ViewProjectionMatrix; | ||||
| uniform mat4 ViewMatrixInverse; | uniform mat4 ViewMatrixInverse; | ||||
| uniform mat3 NormalMatrix; | uniform mat3 NormalMatrix; | ||||
| #ifndef HAIR_SHADER | #ifndef HAIR_SHADER | ||||
| in vec3 pos; | in vec3 pos; | ||||
| in vec3 nor; | in vec3 nor; | ||||
| in vec2 u; /* active texture layer */ | in vec2 u; /* active texture layer */ | ||||
| # ifdef V3D_SHADING_VERTEX_COLOR | |||||
| in vec3 c; /* active color */ | |||||
| # endif | |||||
| # define uv u | # define uv u | ||||
| #else /* HAIR_SHADER */ | #else /* HAIR_SHADER */ | ||||
| # ifdef V3D_SHADING_TEXTURE_COLOR | # ifdef V3D_SHADING_TEXTURE_COLOR | ||||
| uniform samplerBuffer u; /* active texture layer */ | uniform samplerBuffer u; /* active texture layer */ | ||||
| # endif | # endif | ||||
| flat out float hair_rand; | flat out float hair_rand; | ||||
| #endif /* HAIR_SHADER */ | #endif /* HAIR_SHADER */ | ||||
| #ifdef NORMAL_VIEWPORT_PASS_ENABLED | #ifdef NORMAL_VIEWPORT_PASS_ENABLED | ||||
| out vec3 normal_viewport; | out vec3 normal_viewport; | ||||
| #endif | #endif | ||||
| #ifdef V3D_SHADING_TEXTURE_COLOR | #ifdef V3D_SHADING_TEXTURE_COLOR | ||||
| out vec2 uv_interp; | out vec2 uv_interp; | ||||
| #endif | #endif | ||||
| #ifdef V3D_SHADING_VERTEX_COLOR | |||||
| out vec3 vertexColor; | |||||
| #endif | |||||
| /* From http://libnoise.sourceforge.net/noisegen/index.html */ | /* From http://libnoise.sourceforge.net/noisegen/index.html */ | ||||
| float integer_noise(int n) | float integer_noise(int n) | ||||
| { | { | ||||
| n = (n >> 13) ^ n; | n = (n >> 13) ^ n; | ||||
| int nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; | int nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; | ||||
| return (float(nn) / 1073741824.0); | return (float(nn) / 1073741824.0); | ||||
| } | } | ||||
| #ifdef V3D_SHADING_VERTEX_COLOR | |||||
| vec3 srgb_to_linear_attr(vec3 c) | |||||
| { | |||||
| c = max(c, vec3(0.0)); | |||||
| vec3 c1 = c * (1.0 / 12.92); | |||||
| vec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4)); | |||||
| return mix(c1, c2, step(vec3(0.04045), c)); | |||||
| } | |||||
| #endif | |||||
| void main() | void main() | ||||
| { | { | ||||
| #ifdef HAIR_SHADER | #ifdef HAIR_SHADER | ||||
| # ifdef V3D_SHADING_TEXTURE_COLOR | # ifdef V3D_SHADING_TEXTURE_COLOR | ||||
| vec2 uv = hair_get_customdata_vec2(u); | vec2 uv = hair_get_customdata_vec2(u); | ||||
| # endif | # endif | ||||
| float time, thick_time, thickness; | float time, thick_time, thickness; | ||||
| vec3 pos, tan, binor; | vec3 pos, tan, binor; | ||||
| Show All 18 Lines | # endif | ||||
| gl_Position = ViewProjectionMatrix * vec4(pos, 1.0); | gl_Position = ViewProjectionMatrix * vec4(pos, 1.0); | ||||
| #else | #else | ||||
| gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); | gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); | ||||
| #endif | #endif | ||||
| #ifdef V3D_SHADING_TEXTURE_COLOR | #ifdef V3D_SHADING_TEXTURE_COLOR | ||||
| uv_interp = uv; | uv_interp = uv; | ||||
| #endif | #endif | ||||
| #ifdef V3D_SHADING_VERTEX_COLOR | |||||
| # ifndef HAIR_SHADER | |||||
| vertexColor = srgb_to_linear_attr(c); | |||||
| # endif | |||||
| #endif | |||||
| #ifdef NORMAL_VIEWPORT_PASS_ENABLED | #ifdef NORMAL_VIEWPORT_PASS_ENABLED | ||||
| normal_viewport = NormalMatrix * nor; | normal_viewport = NormalMatrix * nor; | ||||
| # ifndef HAIR_SHADER | # ifndef HAIR_SHADER | ||||
| normal_viewport = normalize(normal_viewport); | normal_viewport = normalize(normal_viewport); | ||||
| # endif | # endif | ||||
| #endif | #endif | ||||
| #ifdef USE_WORLD_CLIP_PLANES | #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 | #endif | ||||
| } | } | ||||