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

paint_wire_vert.glsl « shaders « modes « draw « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b415be7841ce70027f8326d8b22037a09078fc54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

uniform mat4 ModelViewProjectionMatrix;
uniform mat4 ModelMatrix;

in vec3 pos;
in vec4 nor; /* flag stored in w */

flat out vec4 finalColor;

void main()
{
#ifdef USE_SELECT
	bool is_select = (nor.w > 0.0);
	bool is_hidden = (nor.w < 0.0);
#else
	bool is_select = false;
	bool is_hidden = false;
#endif
	gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
	/* Add offset in Z to avoid zfighting and render selected wires on top. */
	/* TODO scale this bias using znear and zfar range. */
	gl_Position.z -= (is_select ? 2e-4 : 1e-4);

	if (is_hidden) {
		gl_Position = vec4(-2.0, -2.0, -2.0, 1.0);
	}

#ifdef VERTEX_MODE
	vec4 colSel = colorEdgeSelect;
	colSel.rgb = clamp(colSel.rgb - 0.2, 0.0, 1.0);
#else
	const vec4 colSel = vec4(1.0, 1.0, 1.0, 1.0);
#endif

#ifdef USE_SELECT
	finalColor = (is_select) ? colSel : colorWire;
#else
#  ifdef VERTEX_MODE
	finalColor = colorWire;
#  else
	/* Weight paint needs a light color to contrasts with dark weights. */
	finalColor.xyz =  vec3(0.8, 0.8, 0.8);
#  endif
#endif

	finalColor.a = nor.w;

#ifdef USE_WORLD_CLIP_PLANES
       world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
#endif
}