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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KennethVanhoey
CGoGN
Commits
6fa0fae0
Commit
6fa0fae0
authored
Nov 08, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add iso lines shader
parent
f08ed21b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
326 additions
and
0 deletions
+326
-0
include/Utils/Shaders/shaderIsoLines.frag
include/Utils/Shaders/shaderIsoLines.frag
+6
-0
include/Utils/Shaders/shaderIsoLines.geom
include/Utils/Shaders/shaderIsoLines.geom
+89
-0
include/Utils/Shaders/shaderIsoLines.h
include/Utils/Shaders/shaderIsoLines.h
+90
-0
include/Utils/Shaders/shaderIsoLines.vert
include/Utils/Shaders/shaderIsoLines.vert
+9
-0
src/Utils/Shaders/shaderIsoLines.cpp
src/Utils/Shaders/shaderIsoLines.cpp
+132
-0
No files found.
include/Utils/Shaders/shaderIsoLines.frag
0 → 100644
View file @
6fa0fae0
// ShaderIsoLines::fragmentShaderText
VARYING_FRAG
vec4
ColorFS
;
void
main
()
{
gl_FragColor
=
ColorFS
;
}
include/Utils/Shaders/shaderIsoLines.geom
0 → 100644
View file @
6fa0fae0
// ShaderIsoLines::geometryShaderText
uniform
mat4
NormalMatrix
;
uniform
mat4
ModelViewMatrix
;
uniform
mat4
ModelViewProjectionMatrix
;
uniform
vec4
colorMin
;
uniform
vec4
colorMax
;
uniform
float
vmin
;
uniform
float
vmax
;
uniform
int
vnb
;
VARYING_IN
float
attribData
[
3
];
VARYING_OUT
vec4
ColorFS
;
float
bary
(
float
x
,
float
xmin
,
float
xmax
)
{
return
(
x
-
xmin
)
/
(
xmax
-
xmin
);
}
/*
* warning works only with triangles
*/
void
isoLine
(
float
x
)
{
ColorFS
=
mix
(
colorMin
,
colorMax
,(
x
-
vmin
)
/
(
vmax
-
vmin
));
float
b01
=
bary
(
x
,
attribData
[
0
],
attribData
[
1
]);
float
b02
=
bary
(
x
,
attribData
[
0
],
attribData
[
2
]);
float
b12
=
bary
(
x
,
attribData
[
1
],
attribData
[
2
]);
bool
in01
=
(
b01
>=
0
.
0
)
&&
(
b01
<=
1
.
0
);
bool
in02
=
(
b02
>=
0
.
0
)
&&
(
b02
<=
1
.
0
);
bool
in12
=
(
b12
>=
0
.
0
)
&&
(
b12
<=
1
.
0
);
if
(
in01
)
{
if
(
in02
)
{
// line 01 - 02
vec4
pos
=
mix
(
POSITION_IN
(
0
),
POSITION_IN
(
1
),
b01
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
pos
=
mix
(
POSITION_IN
(
0
),
POSITION_IN
(
2
),
b02
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
EndPrimitive
();
}
if
(
in12
)
{
// line 01 - 12
vec4
pos
=
mix
(
POSITION_IN
(
0
),
POSITION_IN
(
1
),
b01
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
pos
=
mix
(
POSITION_IN
(
1
),
POSITION_IN
(
2
),
b12
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
EndPrimitive
();
}
}
if
(
in02
&&
in12
)
{
// line 12 - 02
vec4
pos
=
mix
(
POSITION_IN
(
0
),
POSITION_IN
(
2
),
b02
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
pos
=
mix
(
POSITION_IN
(
1
),
POSITION_IN
(
2
),
b12
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
EndPrimitive
();
}
}
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
0 → 100644
View file @
6fa0fae0
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __CGOGN_SHADER_ISO_LINES__
#define __CGOGN_SHADER_ISO_LINES__
#include "Utils/GLSLShader.h"
#include "Geometry/vector_gen.h"
namespace
CGoGN
{
namespace
Utils
{
class
ShaderIsoLines
:
public
GLSLShader
{
protected:
// shader sources
static
std
::
string
vertexShaderText
;
static
std
::
string
fragmentShaderText
;
static
std
::
string
geometryShaderText
;
// uniform locations
CGoGNGLuint
m_unif_colorMin
;
CGoGNGLuint
m_unif_colorMax
;
CGoGNGLuint
m_unif_vmin
;
CGoGNGLuint
m_unif_vmax
;
CGoGNGLuint
m_unif_vnb
;
Geom
::
Vec4f
m_colorMin
;
Geom
::
Vec4f
m_colorMax
;
float
m_vmin
;
float
m_vmax
;
int
m_vnb
;
VBO
*
m_vboPos
;
VBO
*
m_vboData
;
void
getLocations
();
// void restoreUniformsAttribs();
public:
ShaderIsoLines
(
int
maxNbIsoPerTriangle
=
6
);
void
setColors
(
const
Geom
::
Vec4f
&
colorMin
,
const
Geom
::
Vec4f
&
colorMax
);
void
setDataBound
(
float
attMin
,
float
attMax
);
void
setNbIso
(
int
nb
);
/**
*
*/
void
setAttributePosition
(
VBO
*
vbo
);
/**
* Data attribute must be float
*/
void
setAttributeData
(
VBO
*
vbo
);
};
}
// namespace Utils
}
// namespace CGoGN
#endif
include/Utils/Shaders/shaderIsoLines.vert
0 → 100644
View file @
6fa0fae0
// ShaderIsoLines::vertexShaderText
ATTRIBUTE
vec3
VertexPosition
;
ATTRIBUTE
float
VertexData
;
VARYING_VERT
float
attribData
;
void
main
()
{
gl_Position
=
vec4
(
VertexPosition
,
1
.
0
);
attribData
=
VertexData
;
}
src/Utils/Shaders/shaderIsoLines.cpp
0 → 100644
View file @
6fa0fae0
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <string>
#include <GL/glew.h>
#include "Utils/Shaders/shaderIsoLines.h"
namespace
CGoGN
{
namespace
Utils
{
#include "shaderIsoLines.vert"
#include "shaderIsoLines.frag"
#include "shaderIsoLines.geom"
ShaderIsoLines
::
ShaderIsoLines
(
int
maxNbIsoPerTriangle
)
{
m_nameVS
=
"shaderIsoLines_vs"
;
m_nameFS
=
"shaderIsoLines_fs"
;
m_nameGS
=
"shaderIsoLines_gs"
;
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
=
GLSLShader
::
defines_Geom
(
"triangles"
,
"line_strip"
,
2
*
maxNbIsoPerTriangle
);
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_TRIANGLES
,
GL_LINE_STRIP
,
2
*
maxNbIsoPerTriangle
);
getLocations
();
//Default values
setColors
(
Geom
::
Vec4f
(
1.0
f
,
0.0
f
,
0.0
f
,
1.0
f
),
Geom
::
Vec4f
(
0.0
f
,
1.0
f
,
0.0
f
,
1.0
f
));
setDataBound
(
0.0
f
,
1.0
f
);
setNbIso
(
32
);
}
void
ShaderIsoLines
::
getLocations
()
{
*
m_unif_colorMin
=
glGetUniformLocation
(
program_handler
(),
"colorMin"
);
*
m_unif_colorMax
=
glGetUniformLocation
(
program_handler
(),
"colorMax"
);
*
m_unif_vmin
=
glGetUniformLocation
(
program_handler
(),
"vmin"
);
*
m_unif_vmax
=
glGetUniformLocation
(
program_handler
(),
"vmax"
);
*
m_unif_vnb
=
glGetUniformLocation
(
program_handler
(),
"vnb"
);
}
void
ShaderIsoLines
::
setAttributePosition
(
VBO
*
vbo
)
{
m_vboPos
=
vbo
;
bindVA_VBO
(
"VertexPosition"
,
vbo
);
}
void
ShaderIsoLines
::
setAttributeData
(
VBO
*
vbo
)
{
m_vboData
=
vbo
;
bindVA_VBO
(
"VertexData"
,
vbo
);
}
void
ShaderIsoLines
::
setColors
(
const
Geom
::
Vec4f
&
colorMin
,
const
Geom
::
Vec4f
&
colorMax
)
{
m_colorMin
=
colorMin
;
m_colorMax
=
colorMax
;
bind
();
glUniform4fv
(
*
m_unif_colorMin
,
1
,
colorMin
.
data
());
glUniform4fv
(
*
m_unif_colorMax
,
1
,
colorMax
.
data
());
}
void
ShaderIsoLines
::
setDataBound
(
float
attMin
,
float
attMax
)
{
m_vmin
=
attMin
;
m_vmax
=
attMax
;
bind
();
glUniform1f
(
*
m_unif_vmin
,
attMin
);
glUniform1f
(
*
m_unif_vmax
,
attMax
);
}
void
ShaderIsoLines
::
setNbIso
(
int
nb
)
{
m_vnb
=
nb
;
bind
();
glUniform1i
(
*
m_unif_vnb
,
nb
);
}
/*
void ShaderIsoLines::restoreUniformsAttribs()
{
*m_unif_explode = glGetUniformLocation(program_handler(),"explode");
*m_unif_ambiant = glGetUniformLocation(program_handler(),"ambient");
*m_unif_lightPos = glGetUniformLocation(program_handler(),"lightPosition");
bind();
glUniform1f (*m_unif_explode, m_explode);
glUniform4fv(*m_unif_ambiant, 1, m_ambiant.data());
glUniform3fv(*m_unif_lightPos, 1, m_light_pos.data());
bindVA_VBO("VertexPosition", m_vboPos);
bindVA_VBO("VertexColor", m_vboPos);
unbind();
}
*/
}
// namespace Utils
}
// namespace CGoGN
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