1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00
occt/tests/v3d/glsl/tess1
kgv 8e0a2b19ab 0029074: Visualization, TKOpenGl - support Geometry Shader definition
Graphic3d_TypeOfShaderObject enumeration has been extended by Geometry shader object type.
OpenGl_ShaderProgram::Initialize() processes new shader object types when supported by OpenGL version.
Declarations.glsl has been fixed so that occFragColor is defined only for
Fragment Shader object only (by handling new FRAGMENT_SHADER macros).

Improved documentation of Graphic3d_ArrayOfPrimitives class.

vshader Draw Harness command has been extended to support definition
of Shader Object types other than Vertex and Fragment shader.
2017-09-22 11:51:36 +03:00

76 lines
1.9 KiB
Plaintext

puts "========"
puts "0029074: Visualization, TKOpenGl - support of Tessellation Shaders"
puts "========"
pload MODELING VISUALIZATION
set aShaderVert "
out vec4 VertColor;
void main() {
VertColor = occColor;
gl_Position = occVertex;
}"
set aShaderTessCtrl "
layout(vertices = 3) out;
void main() {
if (gl_InvocationID == 0) {
gl_TessLevelInner\[0\] = 7.0;
gl_TessLevelOuter\[0\] = 2.0;
gl_TessLevelOuter\[1\] = 3.0;
gl_TessLevelOuter\[2\] = 7.0;
}
gl_out\[gl_InvocationID\].gl_Position = gl_in\[gl_InvocationID\].gl_Position;
}"
set aShaderTessEval "
layout(triangles, equal_spacing, ccw) in;
void main() {
vec3 aPnt0 = gl_TessCoord.x * gl_in\[0\].gl_Position.xyz;
vec3 aPnt1 = gl_TessCoord.y * gl_in\[1\].gl_Position.xyz;
vec3 aPnt2 = gl_TessCoord.z * gl_in\[2\].gl_Position.xyz;
gl_Position = vec4 (aPnt0 + aPnt1 + aPnt2, 1.0);
}"
set aShaderGeom "
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
void main() {
mat4 aMat = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix;
vec3 aCenter = vec3 (0.0, 0.0, 0.0);
for (int aTriVertIter = 0; aTriVertIter < 3; ++aTriVertIter) {
aCenter += gl_in\[aTriVertIter\].gl_Position.xyz;
}
aCenter /= 3.0;
for (int aTriVertIter = 0; aTriVertIter < 3; ++aTriVertIter) {
vec3 aVec = gl_in\[aTriVertIter\].gl_Position.xyz - aCenter;
vec3 aVertRes = aCenter + normalize (aVec) * length (aVec) * 0.75;
gl_Position = aMat * vec4 (aVertRes, 1.0);
EmitVertex();
}
EndPrimitive();
}"
set aShaderFrag "
void main() {
occFragColor = vec4(1.0, 0.0, 0.0, 1.0);
}"
# draw a box
box b 1 2 3
explode b F
vcaps -core
vclear
vinit View1
vaxo
vdisplay -dispMode 1 -mutable b_1
vfit
vrotate 0.2 0.0 0.0
# take snapshot with built-in shader
vdump $::imagedir/${::casename}_normal.png
vshaderprog b_1 -vert $aShaderVert -tessCtrl $aShaderTessCtrl -tessEval $aShaderTessEval -geom $aShaderGeom -frag $aShaderFrag
vdump $::imagedir/${::casename}_tess.png