Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
CGoGN
Commits
7de7491c
Commit
7de7491c
authored
Nov 09, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update ShaderIsoLines
parent
6fa0fae0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
23 deletions
+76
-23
include/Utils/GLSLShader.h
include/Utils/GLSLShader.h
+6
-1
include/Utils/Shaders/shaderIsoLines.geom
include/Utils/Shaders/shaderIsoLines.geom
+5
-12
include/Utils/Shaders/shaderIsoLines.h
include/Utils/Shaders/shaderIsoLines.h
+38
-8
src/Utils/GLSLShader.cpp
src/Utils/GLSLShader.cpp
+27
-2
No files found.
include/Utils/GLSLShader.h
View file @
7de7491c
...
...
@@ -79,6 +79,9 @@ protected:
static
std
::
string
defines_Geom
(
const
std
::
string
&
primitivesIn
,
const
std
::
string
&
primitivesOut
,
int
maxVert
);
int
m_nbMaxVertices
;
/**
* handle of vertex shader
*/
...
...
@@ -167,7 +170,7 @@ protected:
/**
* create the shader (attach and link shaders into program)
*/
bool
create
(
GLint
inputGeometryPrimitive
=
GL_TRIANGLES
,
GLint
outputGeometryPrimitive
=
GL_TRIANGLES
,
int
nb_max_vertices
=
16
);
bool
create
(
GLint
inputGeometryPrimitive
=
GL_TRIANGLES
,
GLint
outputGeometryPrimitive
=
GL_TRIANGLES
,
int
nb_max_vertices
=
-
1
);
/**
* get log after compiling
...
...
@@ -270,6 +273,8 @@ public:
bool
recompile
();
bool
changeNbMaxVertices
(
int
nb_max_vertices
);
/**
* Link the shader do it just after binding the attributes
*/
...
...
include/Utils/Shaders/shaderIsoLines.geom
View file @
7de7491c
...
...
@@ -35,13 +35,13 @@ void isoLine(float x)
if
(
in01
)
{
vec4
pos01
=
ModelViewProjectionMatrix
*
mix
(
POSITION_IN
(
0
),
POSITION_IN
(
1
),
b01
);
if
(
in02
)
{
// line 01 - 02
vec4
pos
=
mix
(
POSITION_IN
(
0
),
POSITION_IN
(
1
),
b01
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
gl_Position
=
pos01
;
EmitVertex
();
pos
=
mix
(
POSITION_IN
(
0
),
POSITION_IN
(
2
),
b02
);
vec4
pos
=
mix
(
POSITION_IN
(
0
),
POSITION_IN
(
2
),
b02
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
EndPrimitive
();
...
...
@@ -49,10 +49,9 @@ void isoLine(float x)
if
(
in12
)
{
// line 01 - 12
vec4
pos
=
mix
(
POSITION_IN
(
0
),
POSITION_IN
(
1
),
b01
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
gl_Position
=
pos01
;
EmitVertex
();
pos
=
mix
(
POSITION_IN
(
1
),
POSITION_IN
(
2
),
b12
);
vec4
pos
=
mix
(
POSITION_IN
(
1
),
POSITION_IN
(
2
),
b12
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
EndPrimitive
();
...
...
@@ -74,16 +73,10 @@ void isoLine(float x)
void
main
(
void
)
{
float
inc
=
(
vmax
-
vmin
)
/
float
(
vnb
);
for
(
int
i
=
0
;
i
<
vnb
;
++
i
)
{
float
v
=
vmin
+
float
(
i
)
*
inc
;
isoLine
(
v
);
}
// isoLine(0.5);
// isoLine(0.5);
// isoLine(0.75);
}
include/Utils/Shaders/shaderIsoLines.h
View file @
7de7491c
...
...
@@ -33,27 +33,34 @@ namespace CGoGN
namespace
Utils
{
/**
* Shader to draw iso-lines on a triangles mesh.
* Iso-line are computed on a data vertex attribute (float)
*/
class
ShaderIsoLines
:
public
GLSLShader
{
protected:
// shader sources
//
/
shader sources
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
geometryShaderText
;
// uniform locations
//
/
uniform locations
CGoGNGLuint
m_unif_colorMin
;
CGoGNGLuint
m_unif_colorMax
;
CGoGNGLuint
m_unif_vmin
;
CGoGNGLuint
m_unif_vmax
;
CGoGNGLuint
m_unif_vnb
;
// colors of iso-lines
Geom
::
Vec4f
m_colorMin
;
Geom
::
Vec4f
m_colorMax
;
/// min/max of data attribute
float
m_vmin
;
float
m_vmax
;
/// number of iso-line to draw
int
m_vnb
;
VBO
*
m_vboPos
;
...
...
@@ -61,24 +68,47 @@ protected:
void
getLocations
();
// void restoreUniformsAttribs();
public:
/**
* constructor
* @param max number of isolines drawable per triangle (as low as possible for performance)
*/
ShaderIsoLines
(
int
maxNbIsoPerTriangle
=
6
);
/**
* set colors for min and max isoLine, interpolated between
// * @param colorMin color for minimum iso-line value
* @param colorMax color for maximum iso-line value
*/
void
setColors
(
const
Geom
::
Vec4f
&
colorMin
,
const
Geom
::
Vec4f
&
colorMax
);
/**
* Set min and max value of used atribute
* @param attMin minimun of attribute
* @param attMax maximun of attribute
*/
void
setDataBound
(
float
attMin
,
float
attMax
);
/**
* set the number of iso-lines (default is 32)
*/
void
setNbIso
(
int
nb
);
/**
*
* set max number of isolines per triangle
* If to small risk of missing lines
* if to big performance problem
*/
void
setNbMaxIsoLinePerTriangle
(
int
nb
)
{
changeNbMaxVertices
(
2
*
nb
);
}
/**
* Position attribute
*/
void
setAttributePosition
(
VBO
*
vbo
);
/**
* Data
attribute must b
e float
* Data
attribute for iso-lines must be of typ
e float
*/
void
setAttributeData
(
VBO
*
vbo
);
};
...
...
src/Utils/GLSLShader.cpp
View file @
7de7491c
...
...
@@ -86,6 +86,8 @@ GLSLShader::GLSLShader() :
if
(
DEFINES_GL
==
NULL
)
DEFINES_GL
=
&
DEFINES_GL2
;
m_nbMaxVertices
=
16
;
}
void
GLSLShader
::
registerShader
(
void
*
ptr
,
GLSLShader
*
shader
)
...
...
@@ -451,6 +453,9 @@ bool GLSLShader::create(GLint inputGeometryPrimitive,GLint outputGeometryPrimiti
int
status
;
char
*
info_log
;
if
(
nb_max_vertices
!=-
1
)
m_nbMaxVertices
=
nb_max_vertices
;
m_geom_inputPrimitives
=
inputGeometryPrimitive
;
m_geom_outputPrimitives
=
outputGeometryPrimitive
;
...
...
@@ -479,7 +484,7 @@ bool GLSLShader::create(GLint inputGeometryPrimitive,GLint outputGeometryPrimiti
glProgramParameteriEXT
(
*
m_program_object
,
GL_GEOMETRY_INPUT_TYPE_EXT
,
inputGeometryPrimitive
);
glProgramParameteriEXT
(
*
m_program_object
,
GL_GEOMETRY_OUTPUT_TYPE_EXT
,
outputGeometryPrimitive
);
glProgramParameteriEXT
(
*
m_program_object
,
GL_GEOMETRY_VERTICES_OUT_EXT
,
nb_max_v
ertices
);
glProgramParameteriEXT
(
*
m_program_object
,
GL_GEOMETRY_VERTICES_OUT_EXT
,
m_nbMaxV
ertices
);
}
/*** link program object ***/
...
...
@@ -511,6 +516,26 @@ bool GLSLShader::create(GLint inputGeometryPrimitive,GLint outputGeometryPrimiti
return
true
;
}
bool
GLSLShader
::
changeNbMaxVertices
(
int
nb_max_vertices
)
{
m_nbMaxVertices
=
nb_max_vertices
;
if
(
*
m_geom_shader_object
)
{
glProgramParameteriEXT
(
*
m_program_object
,
GL_GEOMETRY_VERTICES_OUT_EXT
,
m_nbMaxVertices
);
// need to relink
return
true
;
}
return
false
;
}
bool
GLSLShader
::
link
()
{
int
status
;
...
...
@@ -839,7 +864,7 @@ bool GLSLShader::recompile()
*
m_uniMat_Proj
=
glGetUniformLocation
(
*
m_program_object
,
"ProjectionMatrix"
);
*
m_uniMat_Model
=
glGetUniformLocation
(
*
m_program_object
,
"ModelViewMatrix"
);
*
m_uniMat_ModelProj
=
glGetUniformLocation
(
*
m_program_object
,
"ModelViewProjectionMatrix"
);
*
m_uniMat_Normal
=
glGetUniformLocation
(
*
m_program_object
,
"NormalMatrix"
);
*
m_uniMat_Normal
=
glGetUniformLocation
(
*
m_program_object
,
"NormalMatrix"
);
restoreUniformsAttribs
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment