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/geom1
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

56 lines
1.4 KiB
Plaintext

puts "========"
puts "0029074: Visualization, TKOpenGl - support Geometry Shader definition"
puts "========"
pload MODELING VISUALIZATION
set aShaderVert "
out vec4 VertColor;
void main() {
VertColor = occColor;
gl_Position = occVertex;
}"
# define a Geometry shader drawing shrinked triangles
set aShaderGeom "
layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;
in vec4 VertColor\[3\];
out vec4 Color;
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);
Color = VertColor\[aTriVertIter\] * 2.0;
EmitVertex();
}
EndPrimitive();
}"
set aShaderFrag "
in vec4 Color;
void main() {
occFragColor = Color;
}"
# draw a box
box b 1 2 3
vcaps -core
vclear
vinit View1
vaxo
vdisplay -dispMode 1 -mutable b
vfit
vrotate 0.2 0.0 0.0
vdump $::imagedir/${::casename}_normal.png
vshaderprog b -vert $aShaderVert -geom $aShaderGeom -frag $aShaderFrag
vdump $::imagedir/${::casename}_geom.png