Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
3aa922c4
Commit
3aa922c4
authored
Sep 28, 2010
by
Alexander Wiebel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD
#390
] Style checking for glsl shaders
[STYLE
#390
] adapted all shaders to style
parent
599948cd
Changes
35
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
1128 additions
and
492 deletions
+1128
-492
src/CMakeLists.txt
src/CMakeLists.txt
+2
-1
src/graphicsEngine/shaders/WGEColorMaps.glsl
src/graphicsEngine/shaders/WGEColorMaps.glsl
+109
-87
src/graphicsEngine/shaders/WGELighting-fragment.glsl
src/graphicsEngine/shaders/WGELighting-fragment.glsl
+35
-11
src/graphicsEngine/shaders/WGELighting-vertex.glsl
src/graphicsEngine/shaders/WGELighting-vertex.glsl
+30
-6
src/graphicsEngine/shaders/WGEShadingTools.glsl
src/graphicsEngine/shaders/WGEShadingTools.glsl
+44
-19
src/graphicsEngine/shaders/WGETensorTools.glsl
src/graphicsEngine/shaders/WGETensorTools.glsl
+134
-107
src/graphicsEngine/shaders/WGETransformationTools.glsl
src/graphicsEngine/shaders/WGETransformationTools.glsl
+26
-26
src/graphicsEngine/shaders/WGEUtils.glsl
src/graphicsEngine/shaders/WGEUtils.glsl
+25
-1
src/kernel/modules/fiberDisplay/shaders/WMFiberDisplay-FakeTubes-fragment.glsl
...berDisplay/shaders/WMFiberDisplay-FakeTubes-fragment.glsl
+45
-18
src/kernel/modules/fiberDisplay/shaders/WMFiberDisplay-FakeTubes-vertex.glsl
...fiberDisplay/shaders/WMFiberDisplay-FakeTubes-vertex.glsl
+40
-16
src/kernel/modules/fiberDisplay/shaders/WMFiberDisplay-Textured-fragment.glsl
...iberDisplay/shaders/WMFiberDisplay-Textured-fragment.glsl
+33
-7
src/kernel/modules/fiberDisplay/shaders/WMFiberDisplay-Textured-vertex.glsl
.../fiberDisplay/shaders/WMFiberDisplay-Textured-vertex.glsl
+24
-0
src/kernel/modules/navSlices/shaders/WMNavSlices-fragment.glsl
...ernel/modules/navSlices/shaders/WMNavSlices-fragment.glsl
+42
-18
src/kernel/modules/navSlices/shaders/WMNavSlices-vertex.glsl
src/kernel/modules/navSlices/shaders/WMNavSlices-vertex.glsl
+24
-0
src/modules/arbitraryPlane/shaders/WMArbitraryPlane-fragment.glsl
...les/arbitraryPlane/shaders/WMArbitraryPlane-fragment.glsl
+43
-19
src/modules/arbitraryPlane/shaders/WMArbitraryPlane-vertex.glsl
...dules/arbitraryPlane/shaders/WMArbitraryPlane-vertex.glsl
+24
-0
src/modules/coordinateHUD/shaders/WMCoordinateHUD-vertex.glsl
...modules/coordinateHUD/shaders/WMCoordinateHUD-vertex.glsl
+5
-5
src/modules/isosurfaceRaytracer/shaders/WMIsosurfaceRaytracer-fragment.glsl
...faceRaytracer/shaders/WMIsosurfaceRaytracer-fragment.glsl
+11
-11
src/modules/lic/shaders/WMLIC-fragment.glsl
src/modules/lic/shaders/WMLIC-fragment.glsl
+54
-30
src/modules/lic/shaders/WMLIC-vertex.glsl
src/modules/lic/shaders/WMLIC-vertex.glsl
+24
-0
src/modules/lineGuidedSlice/shaders/WMLineGuidedSlice-fragment.glsl
...s/lineGuidedSlice/shaders/WMLineGuidedSlice-fragment.glsl
+29
-5
src/modules/lineGuidedSlice/shaders/WMLineGuidedSlice-vertex.glsl
...les/lineGuidedSlice/shaders/WMLineGuidedSlice-vertex.glsl
+24
-0
src/modules/marchingCubes/shaders/WMMarchingCubes-fragment.glsl
...dules/marchingCubes/shaders/WMMarchingCubes-fragment.glsl
+45
-21
src/modules/marchingCubes/shaders/WMMarchingCubes-vertex.glsl
...modules/marchingCubes/shaders/WMMarchingCubes-vertex.glsl
+24
-0
src/modules/superquadricGlyphs/shaders/WMSuperquadricGlyphs-fragment.glsl
...rquadricGlyphs/shaders/WMSuperquadricGlyphs-fragment.glsl
+5
-5
src/modules/superquadricGlyphs/shaders/WMSuperquadricGlyphs-varyings.glsl
...rquadricGlyphs/shaders/WMSuperquadricGlyphs-varyings.glsl
+3
-3
src/modules/superquadricGlyphs/shaders/WMSuperquadricGlyphs-vertex.glsl
...perquadricGlyphs/shaders/WMSuperquadricGlyphs-vertex.glsl
+6
-6
src/modules/surfaceParameterAnimator/shaders/WMSurfaceParameterAnimator-Beams-fragment.glsl
...or/shaders/WMSurfaceParameterAnimator-Beams-fragment.glsl
+43
-41
src/modules/teemGlyphs/shaders/WMTeemGlyphs-fragment.glsl
src/modules/teemGlyphs/shaders/WMTeemGlyphs-fragment.glsl
+24
-0
src/modules/teemGlyphs/shaders/WMTeemGlyphs-vertex.glsl
src/modules/teemGlyphs/shaders/WMTeemGlyphs-vertex.glsl
+24
-0
src/modules/triangleMeshRenderer/shaders/WMTriangleMeshRenderer-fragment.glsl
...MeshRenderer/shaders/WMTriangleMeshRenderer-fragment.glsl
+30
-6
src/modules/triangleMeshRenderer/shaders/WMTriangleMeshRenderer-vertex.glsl
...leMeshRenderer/shaders/WMTriangleMeshRenderer-vertex.glsl
+24
-0
src/modules/vectorPlot/shaders/WMVectorPlot-fragment.glsl
src/modules/vectorPlot/shaders/WMVectorPlot-fragment.glsl
+24
-0
src/modules/vectorPlot/shaders/WMVectorPlot-vertex.glsl
src/modules/vectorPlot/shaders/WMVectorPlot-vertex.glsl
+24
-0
tools/brainlint.py
tools/brainlint.py
+25
-23
No files found.
src/CMakeLists.txt
View file @
3aa922c4
...
...
@@ -285,6 +285,7 @@ ENDIF()
# noncolored if it is set to OFF
FILE
(
GLOB_RECURSE STYLE_CPP
${
PROJECT_SOURCE_DIR
}
/*.cpp
)
FILE
(
GLOB_RECURSE STYLE_H
${
PROJECT_SOURCE_DIR
}
/*.h
)
FILE
(
GLOB_RECURSE STYLE_GLSL
${
PROJECT_SOURCE_DIR
}
/*.glsl
)
# Set dirs to exclude from stylecheck
SET
(
EXCLUDE_DIRS
"/ext/nifti/;/dataHandler/io/biosig/;/dataHandler/io/biosigWin/;/dataHandler/io/biosig/XMLParser/;/dataHandler/io/biosigWin/XMLParser/;/ext/libeep/avr/;/ext/libeep/cnt/;/ext/libeep/eep/;/common/platformDependent/visualStudio/;/modules/lic/fibernavigator/;/modules/lic/fantom/"
)
FOREACH
(
dirname
${
EXCLUDE_DIRS
}
)
...
...
@@ -316,7 +317,7 @@ ELSE()
ENDIF
()
FILE
(
WRITE
${
PROJECT_BINARY_DIR
}
/brainlintlist
""
)
FOREACH
(
fname
${
STYLE_CPP
}
${
STYLE_H
}
)
FOREACH
(
fname
${
STYLE_CPP
}
${
STYLE_H
}
${
STYLE_GLSL
}
)
FILE
(
APPEND
${
PROJECT_BINARY_DIR
}
/brainlintlist
"
${
fname
}
\n
"
)
ENDFOREACH
()
...
...
src/graphicsEngine/shaders/WGEColorMaps.glsl
View file @
3aa922c4
This diff is collapsed.
Click to expand it.
src/graphicsEngine/shaders/WGELighting-fragment.glsl
View file @
3aa922c4
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut 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 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
varying
vec3
normal
;
varying
vec4
vertex
;
varying
vec3
halfvec
;
const
vec4
AMBIENT_BLACK
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
1
.
0
);
const
vec4
DEFAULT_BLACK
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
0
.
0
);
const
vec4
AMBIENT_BLACK
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
1
.
0
);
const
vec4
DEFAULT_BLACK
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
0
.
0
);
void
directionalLight
(
in
int
i
,
in
vec3
normal
,
in
float
shininess
,
inout
vec4
ambient
,
inout
vec4
diffuse
,
inout
vec4
specular
)
inout
vec4
ambient
,
inout
vec4
diffuse
,
inout
vec4
specular
)
{
float
nDotVP
;
float
nDotHV
;
float
pf
;
vec3
L
=
normalize
(
gl_LightSource
[
i
].
position
.
xyz
-
vertex
.
xyz
);
vec3
H
=
normalize
(
L
+
halfvec
.
xyz
);
vec3
L
=
normalize
(
gl_LightSource
[
i
].
position
.
xyz
-
vertex
.
xyz
);
vec3
H
=
normalize
(
L
+
halfvec
.
xyz
);
nDotVP
=
max
(
0
.
0
,
dot
(
normal
,
normalize
((
gl_LightSource
[
i
].
position
.
xyz
)))
);
nDotHV
=
max
(
0
.
0
,
dot
(
normal
,
H
)
);
nDotVP
=
max
(
0
.
0
,
dot
(
normal
,
normalize
(
(
gl_LightSource
[
i
].
position
.
xyz
)
)
)
);
nDotHV
=
max
(
0
.
0
,
dot
(
normal
,
H
)
);
if
(
nDotVP
==
0
.
0
)
if
(
nDotVP
==
0
.
0
)
pf
=
0
.
0
;
else
pf
=
pow
(
nDotHV
,
gl_FrontMaterial
.
shininess
);
pf
=
pow
(
nDotHV
,
gl_FrontMaterial
.
shininess
);
ambient
+=
gl_LightSource
[
i
].
ambient
;
diffuse
+=
gl_LightSource
[
i
].
diffuse
*
nDotVP
;
specular
+=
gl_LightSource
[
i
].
specular
*
pf
;
}
void
calculateLighting
(
in
vec3
N
,
in
float
shininess
,
inout
vec4
ambient
,
inout
vec4
diffuse
,
inout
vec4
specular
)
void
calculateLighting
(
in
vec3
N
,
in
float
shininess
,
inout
vec4
ambient
,
inout
vec4
diffuse
,
inout
vec4
specular
)
{
directionalLight
(
0
,
N
,
shininess
,
ambient
,
diffuse
,
specular
);
directionalLight
(
0
,
N
,
shininess
,
ambient
,
diffuse
,
specular
);
}
src/graphicsEngine/shaders/WGELighting-vertex.glsl
View file @
3aa922c4
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut 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 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
varying
vec3
normal
;
varying
vec4
vertex
;
varying
vec3
halfvec
;
const
vec4
AMBIENT_BLACK
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
1
.
0
);
const
vec4
DEFAULT_BLACK
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
0
.
0
);
const
vec4
AMBIENT_BLACK
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
1
.
0
);
const
vec4
DEFAULT_BLACK
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
0
.
0
);
/**
* Computes normal and makes transformation to eye space.
...
...
@@ -11,12 +35,12 @@ const vec4 DEFAULT_BLACK = vec4(0.0, 0.0, 0.0, 0.0);
void
prepareLight
()
{
// Calculate the normal
normal
=
normalize
(
gl_NormalMatrix
*
gl_Normal
).
xyz
;
normal
=
normalize
(
gl_NormalMatrix
*
gl_Normal
).
xyz
;
// Transform the vertex position to eye space
vertex
=
vec4
(
gl_ModelViewMatrix
*
gl_Vertex
);
vertex
=
vec4
(
gl_ModelViewMatrix
*
gl_Vertex
);
vec3
L
=
normalize
(
gl_LightSource
[
0
].
position
.
xyz
-
vertex
.
xyz
);
vec3
L
=
normalize
(
gl_LightSource
[
0
].
position
.
xyz
-
vertex
.
xyz
);
halfvec
=
vec3
(
L
+
vec3
(
0
.
0
,
0
.
0
,
1
.
0
)
);
halfvec
=
vec3
(
L
+
vec3
(
0
.
0
,
0
.
0
,
1
.
0
)
);
}
src/graphicsEngine/shaders/WGEShadingTools.glsl
View file @
3aa922c4
/**
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut 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 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
/**
* Function to calculate lighting based on "Real-Time Volume Graphics, p 119, chapter 5.4, Listing 5.1".
*
* @param ambient materials ambient color
...
...
@@ -10,33 +34,33 @@
* @param normalDir the normal
* @param viewDir viewing direction
* @param lightDir light direction
*
*
* @return the color.
*/
vec4
blinnPhongIllumination
(
vec3
ambient
,
vec3
diffuse
,
vec3
specular
,
float
shininess
,
vec3
lightColor
,
vec3
ambientLight
,
vec3
normalDir
,
vec3
viewDir
,
vec3
lightDir
)
vec4
blinnPhongIllumination
(
vec3
ambient
,
vec3
diffuse
,
vec3
specular
,
float
shininess
,
vec3
lightColor
,
vec3
ambientLight
,
vec3
normalDir
,
vec3
viewDir
,
vec3
lightDir
)
{
vec3
H
=
normalize
(
lightDir
+
viewDir
);
// compute ambient term
vec3
ambientV
=
ambient
*
ambientLight
;
// compute diffuse term
float
diffuseLight
=
max
(
dot
(
lightDir
,
normalDir
),
0
.
);
float
diffuseLight
=
max
(
dot
(
lightDir
,
normalDir
),
0
.
);
vec3
diffuseV
=
diffuse
*
diffuseLight
;
// compute specular term
float
specularLight
=
pow
(
max
(
dot
(
H
,
normalDir
),
0
.),
shininess
);
float
specularLight
=
pow
(
max
(
dot
(
H
,
normalDir
),
0
.
),
shininess
);
if
(
diffuseLight
<=
0
.)
specularLight
=
0
.;
vec3
specularV
=
specular
*
specularLight
;
return
vec4
(
ambientV
+
(
diffuseV
+
specularV
)
*
lightColor
,
1
.
);
return
vec4
(
ambientV
+
(
diffuseV
+
specularV
)
*
lightColor
,
1
.
);
}
/**
/**
* @brief Function to calculate lighting intensitybased on "Real-Time Volume Graphics, p 119, chapter 5.4, Listing 5.1".
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* It is basically the same as blinnPhongIllumination function above. But it is faster if you just need
* the intensity.
*
* @param ambient materials ambient intensity
...
...
@@ -48,27 +72,28 @@ vec4 blinnPhongIllumination( vec3 ambient, vec3 diffuse, vec3 specular, float sh
* @param normalDir the normal
* @param viewDir viewing direction
* @param lightDir light direction
*
*
* @return the light intensity.
*/
float
blinnPhongIlluminationIntensity
(
float
ambient
,
float
diffuse
,
float
specular
,
float
shininess
,
float
lightIntensity
,
float
ambientIntensity
,
vec3
normalDir
,
vec3
viewDir
,
vec3
lightDir
)
float
blinnPhongIlluminationIntensity
(
float
ambient
,
float
diffuse
,
float
specular
,
float
shininess
,
float
lightIntensity
,
float
ambientIntensity
,
vec3
normalDir
,
vec3
viewDir
,
vec3
lightDir
)
{
vec3
H
=
normalize
(
lightDir
+
viewDir
);
// compute ambient term
float
ambientV
=
ambient
*
ambientIntensity
;
// compute diffuse term
float
diffuseLight
=
max
(
dot
(
lightDir
,
normalDir
),
0
.
);
float
diffuseLight
=
max
(
dot
(
lightDir
,
normalDir
),
0
.
);
float
diffuseV
=
diffuse
*
diffuseLight
;
// compute specular term
float
specularLight
=
pow
(
max
(
dot
(
H
,
normalDir
),
0
.),
shininess
);
float
specularLight
=
pow
(
max
(
dot
(
H
,
normalDir
),
0
.
),
shininess
);
if
(
diffuseLight
<=
0
.)
specularLight
=
0
.;
float
specularV
=
specular
*
specularLight
;
return
ambientV
+
(
diffuseV
+
specularV
)
*
lightIntensity
;
return
ambientV
+
(
diffuseV
+
specularV
)
*
lightIntensity
;
}
src/graphicsEngine/shaders/WGETensorTools.glsl
View file @
3aa922c4
This diff is collapsed.
Click to expand it.
src/graphicsEngine/shaders/WGETransformationTools.glsl
View file @
3aa922c4
...
...
@@ -25,9 +25,9 @@
/**
* Projects a given point to screen-space, where (0,0) is the lower left corner and (1,1) the upper right. The Depth
* is stored in the returned vector's Z value.
*
*
* \param point the point to project
*
*
* \return the projected point, the Z value is the depth
*/
vec3
project
(
vec4
point
)
...
...
@@ -37,29 +37,29 @@ vec3 project( vec4 point )
// 2: scale to screen space and [0,1]
pointProjected
.
x
/=
pointProjected
.
w
;
pointProjected
.
x
=
pointProjected
.
x
*
0
.
5
+
0
.
5
;
pointProjected
.
x
=
pointProjected
.
x
*
0
.
5
+
0
.
5
;
pointProjected
.
y
/=
pointProjected
.
w
;
pointProjected
.
y
=
pointProjected
.
y
*
0
.
5
+
0
.
5
;
pointProjected
.
y
=
pointProjected
.
y
*
0
.
5
+
0
.
5
;
pointProjected
.
z
/=
pointProjected
.
w
;
pointProjected
.
z
=
pointProjected
.
z
*
0
.
5
+
0
.
5
;
pointProjected
.
z
=
pointProjected
.
z
*
0
.
5
+
0
.
5
;
return
pointProjected
.
xyz
;
}
/**
* Projects a given vector to screen-space. It does not scale the final vector to [0,1] as project() would have done.
*
*
* \param vector the vector to project
*
*
* \return the projected vector in unscaled screen-space ( [-1,1] per component )
*/
vec3
projectVector
(
vec4
vector
)
{
vec4
base
=
vec4
(
0
.
0
,
0
.
0
,
0
.
0
,
1
.
0
);
vec4
diff
=
vector
;
vec4
diffP
=
gl_ModelViewProjectionMatrix
*
diff
;
vec4
baseP
=
gl_ModelViewProjectionMatrix
*
base
;
vec4
diffP
=
gl_ModelViewProjectionMatrix
*
diff
;
vec4
baseP
=
gl_ModelViewProjectionMatrix
*
base
;
// scale by w
diffP
.
x
/=
diffP
.
w
;
...
...
@@ -75,9 +75,9 @@ vec3 projectVector( vec4 vector )
/**
* Projects a given vector to screen-space. It does not scale the final vector to [0,1] as project() would have done.
*
*
* \param vector the vector to project
*
*
* \return the projected vector in unscaled screen-space ( [-1,1] per component )
*
* \note This assumes the homogeneous coordinate to be 1.
...
...
@@ -90,9 +90,9 @@ vec3 projectVector( vec3 vector )
/**
* Projects a given point to screen-space, where (0,0) is the lower left corner and (1,1) the upper right. The Depth
* is stored in the returned vector's Z value.
*
*
* \param point the point to project
*
*
* \return the projected point, the Z value is the depth
*
* \note This projects a vec3 by applying 1.0 to the homogeneous coordinate
...
...
@@ -103,11 +103,11 @@ vec3 project( vec3 point )
}
/**
* This function transforms a point which is in world space, to a point in the local coordinate system of the object
* This function transforms a point which is in world space, to a point in the local coordinate system of the object
* currently getting rendered.
*
*
* \param point the point in world coordinates
*
*
* \return the point in local coordinates
*/
vec4
worldToLocal
(
vec4
point
)
...
...
@@ -116,11 +116,11 @@ vec4 worldToLocal( vec4 point )
}
/**
* This function transforms a point which is in world space, to a point in the local coordinate system of the object
* This function transforms a point which is in world space, to a point in the local coordinate system of the object
* currently getting rendered.
*
*
* \param point the point in world coordinates
*
*
* \return the point in local coordinates
*
* \note This assumes the homogeneous part to be 1.0
...
...
@@ -131,12 +131,12 @@ vec4 worldToLocal( vec3 point )
}
/**
* This function transforms a vector which is in world space, to a point in the local coordinate system of the object
* This function transforms a vector which is in world space, to a point in the local coordinate system of the object
* currently getting rendered.
*
*
* \param point1 the vector point in world coordinates
* \param point2 the vector direction point in world coordinates
*
*
* \return the vector in local coordinates
*/
vec4
worldToLocal
(
vec4
point1
,
vec4
point2
)
...
...
@@ -145,12 +145,12 @@ vec4 worldToLocal( vec4 point1, vec4 point2 )
}
/**
* This function transforms a vector which is in world space, to a point in the local coordinate system of the object
* This function transforms a vector which is in world space, to a point in the local coordinate system of the object
* currently getting rendered.
*
*
* \param point1 the vector point in world coordinates
* \param point2 the vector direction point in world coordinates
*
*
* \return the vector in local coordinates
*
* \note This assumes the homogeneous part to be 1.0
...
...
src/graphicsEngine/shaders/WGEUtils.glsl
View file @
3aa922c4
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut 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 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
//
// This makes threshold lying between min and max to lie between 0 and 1
// where 0 correspond to min and 1 to max
// where 0 correspond
s
to min and 1 to max
//
float
scaleZeroOne
(
in
float
threshold
,
in
float
min
,
in
float
max
)
{
...
...
src/kernel/modules/fiberDisplay/shaders/WMFiberDisplay-FakeTubes-fragment.glsl
View file @
3aa922c4
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut 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 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
varying
vec3
tangentR3
;
// Tangent vector in world space
varying
float
s_param
;
// s parameter of texture [-1..1]
varying
float
tangent_dot_view
;
...
...
@@ -28,37 +52,40 @@ float lookupTex()
if
(
col1
.
r
<
threshold
)
{
discard
;
discard
;
}
else
{
return
col1
.
r
;
}
}
/*
/**
* simple fragment shader that does rendering of tubes with diffuse illumination
*/
void
main
()
{
vec3
color
;
vec3
color
;
if
(
useTexture
)
{
float
value
=
lookupTex
();
colorMap
(
color
.
rgb
,
value
,
cMap
);
}
else
{
color
=
abs
(
normalize
(
myColor
.
rgb
));
}
if
(
useTexture
)
{
float
value
=
lookupTex
();
colorMap
(
color
.
rgb
,
value
,
cMap
);
}
else
{
color
=
abs
(
normalize
(
myColor
.
rgb
)
);
}
vec3
view
=
vec3
(
0
.,
0
.,
-
1
.
);
float
view_dot_normal
=
sqrt
(
1
.
-
s_param
*
s_param
)
+
.
1
;
vec3
view
=
vec3
(
0
.,
0
.,
-
1
.
);
float
view_dot_normal
=
sqrt
(
1
.
-
s_param
*
s_param
)
+
.
1
;
gl_FragColor
.
rgb
=
clamp
(
view_dot_normal
*
(
color
+
0
.
15
*
pow
(
view_dot_normal
,
10
.)
*
pow
(
tangent_dot_view
,
10
.)
*
vec3
(
1
.,
1
.,
1
.)),
0
.,
1
.);
//< set the color of this fragment (i.e. pixel)
// set the color of this fragment (i.e. pixel)
gl_FragColor
.
rgb
=
clamp
(
view_dot_normal
*
(
color
+
0
.
15
*
pow
(
view_dot_normal
,
10
.
)
*
pow
(
tangent_dot_view
,
10
.
)
*
vec3
(
1
.,
1
.,
1
.
)
),
0
.,
1
.
);
gl_FragColor
.
a
=
myColor
.
a
;
gl_FragColor
.
a
=
myColor
.
a
;
}
src/kernel/modules/fiberDisplay/shaders/WMFiberDisplay-FakeTubes-vertex.glsl
View file @
3aa922c4
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut 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 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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 OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
varying
float
tangent_dot_view
;
varying
vec3
tangentR3
;
varying
float
s_param
;
...
...
@@ -8,29 +32,29 @@ varying vec4 VaryingTexCoord0;
void
main
()
{
VaryingTexCoord0
=
gl_Vertex
;
gl_ClipVertex
=
gl_ModelViewMatrix
*
gl_Vertex
;
//< make clipping planes work
vec3
tangent
;
gl_ClipVertex
=
gl_ModelViewMatrix
*
gl_Vertex
;
//< make clipping planes work
vec3
tangent
;
float
thickness
=
0
.
01
*
u_thickness
/
100
.;
float
thickness
=
0
.
01
*
u_thickness
/
100
.;
tangentR3
=
gl_Normal
;
tangent
=
(
gl_ModelViewProjectionMatrix
*
vec4
(
gl_Normal
,
0
.)
).
xyz
;
//< transform our tangent vector
s_param
=
gl_MultiTexCoord0
.
x
;
//< store texture coordinate for shader
tangentR3
=
gl_Normal
;
tangent
=
(
gl_ModelViewProjectionMatrix
*
vec4
(
gl_Normal
,
0
.
)
).
xyz
;
//< transform our tangent vector
s_param
=
gl_MultiTexCoord0
.
x
;
//< store texture coordinate for shader
vec3
offsetNN
=
cross
(
normalize
(
tangent
.
xyz
),
vec3
(
0
.,
0
.,
-
1
.)
);
vec3
offset
=
normalize
(
offsetNN
);
tangent_dot_view
=
length
(
offsetNN
);
vec3
offsetNN
=
cross
(
normalize
(
tangent
.
xyz
),
vec3
(
0
.,
0
.,
-
1
.
)
);
vec3
offset
=
normalize
(
offsetNN
);
tangent_dot_view
=
length
(
offsetNN
);
vec4
pos
=
ftransform
();
//< transform position to eye space
vec4
pos
=
ftransform
();
//< transform position to eye space
offset
.
x
*=
thickness
;
offset
.
y
*=
thickness
;
offset
.
x
*=
thickness
;
offset
.
y
*=
thickness
;
pos
.
xyz
+=
offset
*
(
s_param
);
//< add offset in y-direction (eye-space)
pos
.
xyz
+=
offset
*
(
s_param
);
//< add offset in y-direction (eye-space)
myColor
=
gl_Color
;
myColor
=
gl_Color
;
gl_Position
=
pos
;
//< store final position
gl_Position
=
pos
;
//< store final position
}
src/kernel/modules/fiberDisplay/shaders/WMFiberDisplay-Textured-fragment.glsl
View file @
3aa922c4
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut 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 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut 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.