diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-03-29 13:40:26 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-04-01 20:27:13 +0400 |
commit | 3ed49a810d469174d2c0233dcb03d249adc60056 (patch) | |
tree | 6e80355cf213b928c9d292ebf894095aad687d8e /source/blender/gpu/shaders | |
parent | ad7980a51a7e1c2492691e403ffdf84a29081c35 (diff) |
Make matcaps suck less
This commit does various changes for matcaps:
One is taking advantage of drawing with pbvh (which would only happen
with dyntopo previously) and drawing with partial redraw during
sculpting.
The second one is support for masks. To make this work in the special
case of multires, which uses flat shading, I use the only available flat
shaded builtins in OpenGL 2.0 which are color and secondary color.
Abusing colors in that way is also essential for flat shading to work if
we are to use pbvh draw in multires, since it is the color that is being
interpolated flatly, not the normal (which can only interpolated
smoothly). The pbvh drawing code for multires used last triangle
element's normal to compute the shading which would only produce smooth
results. This could change if we did the shading in the vertex shader
for flat shaded primitives, but this is more complex and makes it harder
to have one shader to rule the mole.
Also increased the brightness of the default diffuse color for
sculpting. This should be useful since artists like to tweak the
lighting settings and it will give them the full dynamic range of the
lights, but also it helps with correct brightness of sculpted matcaps.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D435
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 19ef6d01cfd..cfe99625db3 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2409,16 +2409,20 @@ void node_output_material(vec4 surface, vec4 volume, float displacement, out vec /* ********************** matcap style render ******************** */ -void material_preview_matcap(vec4 color, sampler2D ima, vec3 N, out vec4 result) +void material_preview_matcap(vec4 color, sampler2D ima, vec4 N, vec4 mask, out vec4 result) { + vec3 normal; vec2 tex; - - if (N.z < 0.0) { - N.z = 0.0; - N = normalize(N); + + /* remap to 0.0 - 1.0 range. This is done because OpenGL 2.0 clamps colors + * between shader stages and we want the full range of the normal */ + normal = vec3(2.0, 2.0, 2.0) * vec3(N.x, N.y, N.z) - vec3(1.0, 1.0, 1.0); + if (normal.z < 0.0) { + normal.z = 0.0; } + normal = normalize(normal); - tex.x = 0.5 + 0.49 * N.x; - tex.y = 0.5 + 0.49 * N.y; - result = texture2D(ima, tex); + tex.x = 0.5 + 0.49 * normal.x; + tex.y = 0.5 + 0.49 * normal.y; + result = texture2D(ima, tex) * mask; } |