0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / tests / v3d / glsl / tess1
CommitLineData
8e0a2b19 1puts "========"
2puts "0029074: Visualization, TKOpenGl - support of Tessellation Shaders"
3puts "========"
4
5pload MODELING VISUALIZATION
6
7set aShaderVert "
8out vec4 VertColor;
9void main() {
10 VertColor = occColor;
11 gl_Position = occVertex;
12}"
13
14set aShaderTessCtrl "
15layout(vertices = 3) out;
16void main() {
17 if (gl_InvocationID == 0) {
18 gl_TessLevelInner\[0\] = 7.0;
19 gl_TessLevelOuter\[0\] = 2.0;
20 gl_TessLevelOuter\[1\] = 3.0;
21 gl_TessLevelOuter\[2\] = 7.0;
22 }
23 gl_out\[gl_InvocationID\].gl_Position = gl_in\[gl_InvocationID\].gl_Position;
24}"
25
26set aShaderTessEval "
27layout(triangles, equal_spacing, ccw) in;
28void main() {
29 vec3 aPnt0 = gl_TessCoord.x * gl_in\[0\].gl_Position.xyz;
30 vec3 aPnt1 = gl_TessCoord.y * gl_in\[1\].gl_Position.xyz;
31 vec3 aPnt2 = gl_TessCoord.z * gl_in\[2\].gl_Position.xyz;
32 gl_Position = vec4 (aPnt0 + aPnt1 + aPnt2, 1.0);
33}"
34
35set aShaderGeom "
36layout(triangles) in;
37layout(triangle_strip, max_vertices=3) out;
38void main() {
39 mat4 aMat = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix;
40 vec3 aCenter = vec3 (0.0, 0.0, 0.0);
41 for (int aTriVertIter = 0; aTriVertIter < 3; ++aTriVertIter) {
42 aCenter += gl_in\[aTriVertIter\].gl_Position.xyz;
43 }
44 aCenter /= 3.0;
45 for (int aTriVertIter = 0; aTriVertIter < 3; ++aTriVertIter) {
46 vec3 aVec = gl_in\[aTriVertIter\].gl_Position.xyz - aCenter;
47 vec3 aVertRes = aCenter + normalize (aVec) * length (aVec) * 0.75;
48 gl_Position = aMat * vec4 (aVertRes, 1.0);
49 EmitVertex();
50 }
51 EndPrimitive();
52}"
53
54set aShaderFrag "
55void main() {
56 occFragColor = vec4(1.0, 0.0, 0.0, 1.0);
57}"
58
59# draw a box
60box b 1 2 3
61explode b F
62
63vcaps -core
64vclear
65vinit View1
66vaxo
67vdisplay -dispMode 1 -mutable b_1
68vfit
69vrotate 0.2 0.0 0.0
70
71# take snapshot with built-in shader
72vdump $::imagedir/${::casename}_normal.png
73
74vshaderprog b_1 -vert $aShaderVert -tessCtrl $aShaderTessCtrl -tessEval $aShaderTessEval -geom $aShaderGeom -frag $aShaderFrag
75vdump $::imagedir/${::casename}_tess.png