Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
VTK
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
1
Merge Requests
1
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Michael Migliore
VTK
Commits
ece2ba8f
Commit
ece2ba8f
authored
Apr 30, 2014
by
Ken Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some more cleanup
parent
3c9a2943
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
28 deletions
+59
-28
Rendering/OpenGL2/Testing/Cxx/TestVBOPLYMapper.cxx
Rendering/OpenGL2/Testing/Cxx/TestVBOPLYMapper.cxx
+7
-2
Rendering/OpenGL2/glsl/vtkglPolyDataVSHeadlight.glsl
Rendering/OpenGL2/glsl/vtkglPolyDataVSHeadlight.glsl
+15
-7
Rendering/OpenGL2/glsl/vtkglPolyDataVSLightKit.glsl
Rendering/OpenGL2/glsl/vtkglPolyDataVSLightKit.glsl
+30
-14
Rendering/OpenGL2/vtkVBOPolyDataMapper.cxx
Rendering/OpenGL2/vtkVBOPolyDataMapper.cxx
+7
-5
No files found.
Rendering/OpenGL2/Testing/Cxx/TestVBOPLYMapper.cxx
View file @
ece2ba8f
...
...
@@ -23,6 +23,7 @@
#include "vtkPLYReader.h"
#include "vtkNew.h"
#include "vtkProperty.h"
#include "vtkLightKit.h"
#include "vtkTimerLog.h"
...
...
@@ -41,6 +42,10 @@ int TestVBOPLYMapper(int argc, char *argv[])
renderWindow
->
AddRenderer
(
renderer
.
Get
());
renderer
->
AddActor
(
actor
.
Get
());
vtkNew
<
vtkLightKit
>
lightKit
;
lightKit
->
AddLightsToRenderer
(
renderer
.
Get
());
const
char
*
fileName
=
vtkTestUtilities
::
ExpandDataFileName
(
argc
,
argv
,
"Data/bunny.ply"
);
...
...
@@ -53,9 +58,9 @@ int TestVBOPLYMapper(int argc, char *argv[])
mapper
->
SetInputConnection
(
computeNormals
->
GetOutputPort
());
actor
->
SetMapper
(
mapper
.
Get
());
actor
->
GetProperty
()
->
SetDiffuseColor
(
1.0
,
1.0
,
0.0
);
actor
->
GetProperty
()
->
SetDiffuseColor
(
1.0
,
0.65
,
0.7
);
actor
->
GetProperty
()
->
SetSpecularColor
(
1.0
,
1.0
,
1.0
);
actor
->
GetProperty
()
->
SetSpecular
(
1.0
);
actor
->
GetProperty
()
->
SetSpecular
(
0.5
);
actor
->
GetProperty
()
->
SetOpacity
(
1.0
);
vtkNew
<
vtkRenderWindowInteractor
>
interactor
;
...
...
Rendering/OpenGL2/glsl/vtkglPolyDataVSHeadlight.glsl
View file @
ece2ba8f
...
...
@@ -15,14 +15,22 @@
// it requires only one white light, positioned at the camera
// Gouraud shading
attribute
vec4
vertex
;
attribute
vec3
normal
;
// all variables that represent positions or directions have a suffix
// indicating the coordinate system they are in. The possible values are
// MC - Model Coordinates
// WC - WC world coordinates
// VC - View Coordinates
// DC - Display Coordinates
attribute
vec4
vertexMC
;
attribute
vec3
normalMC
;
// material property values
uniform
float
opacity
;
uniform
vec3
diffuseColor
;
uniform
vec3
specularColor
;
uniform
vec3
specularPower
;
uniform
float
specularPower
;
// camera and actor matrix values
uniform
mat4
modelView
;
...
...
@@ -33,12 +41,12 @@ varying vec4 fcolor;
void
main
()
{
gl_Position
=
projection
*
modelView
*
vertex
;
vec3
N
=
normalize
(
normalMatrix
*
normal
);
gl_Position
=
projection
*
modelView
*
vertex
MC
;
vec3
normalVC
=
normalize
(
normalMatrix
*
normalMC
);
// diffuse and specular lighting
float
df
=
max
(
0
.
0
,
dot
(
N
,
vec3
(
0
,
0
,
-
1
)));
float
sf
=
pow
(
df
,
20
.
0
);
float
df
=
max
(
0
.
0
,
dot
(
normalVC
,
vec3
(
0
,
0
,
-
1
)));
float
sf
=
pow
(
df
,
specularPower
);
//vec3 ambient = 0.4 * color;
vec3
diffuse
=
df
*
diffuseColor
;
...
...
Rendering/OpenGL2/glsl/vtkglPolyDataVSLightKit.glsl
View file @
ece2ba8f
...
...
@@ -15,43 +15,59 @@
// and supports the VTK light kit, multiple lights
// some off axis from the camera, Gouraud shading
attribute
vec4
vertex
;
attribute
vec3
normal
;
// all variables that represent positions or directions have a suffix
// indicating the coordinate system they are in. The possible values are
// MC - Model Coordinates
// WC - WC world coordinates
// VC - View Coordinates
// DC - Display Coordinates
attribute
vec4
vertexMC
;
attribute
vec3
normalMC
;
// material property values
uniform
float
opacity
;
uniform
vec3
diffuseColor
;
uniform
vec3
specularColor
;
uniform
vec3
specularPower
;
uniform
float
specularPower
;
// camera and actor matrix values
uniform
mat4
modelView
;
uniform
mat4
projection
;
uniform
mat3
normalMatrix
;
uniform
mat4
modelView
;
// combined actor (model) and view matricies
uniform
mat4
projection
;
// the camera's projection matrix
uniform
mat3
normalMatrix
;
// transform model coordinate directions to view coordinates
uniform
int
numberOfLights
;
// only allow for up to 6 active lights
uniform
vec3
lightColor
[
6
];
// intensity weighted
uniform
vec3
lightDirection
[
6
];
// normalized and in camera coords
uniform
vec3
lightColor
[
6
];
// intensity weighted
color
uniform
vec3
lightDirection
VC
[
6
];
// normalized
// the resulting vertex color to be passed down to the fragment shader
varying
vec4
fcolor
;
void
main
()
{
gl_Position
=
projection
*
modelView
*
vertex
;
vec3
N
=
normalize
(
normalMatrix
*
normal
);
vec3
E
=
vec3
(
0
,
0
,
1
);
// eye/view/camera direction
// compute the projected vertex position
vec4
vertexVC
=
modelView
*
vertexMC
;
gl_Position
=
projection
*
vertexVC
;
// now compute the vertex color
vec3
normalVC
=
normalize
(
normalMatrix
*
normalMC
);
vec3
viewDirectionVC
=
normalize
(
vec3
(
0
.
0
,
0
.
0
,
1
.
0
)
-
vertexVC
);
vec3
diffuse
=
vec3
(
0
,
0
,
0
);
vec3
specular
=
vec3
(
0
,
0
,
0
);
for
(
int
lightNum
=
0
;
lightNum
<
numberOfLights
;
lightNum
++
)
{
// diffuse and specular lighting
float
df
=
max
(
0
.
0
,
dot
(
N
,
lightDirection
[
lightNum
]));
float
df
=
max
(
0
.
0
,
dot
(
normalVC
,
lightDirectionVC
[
lightNum
]));
diffuse
+=
(
df
*
lightColor
[
lightNum
]);
float
sf
=
pow
(
max
(
0
.
0
,
dot
(
reflect
(
lightDirection
[
lightNum
],
N
),
E
)),
20
.
0
);
specular
+=
(
sf
*
lightColor
[
lightNum
]);
if
(
dot
(
normalVC
,
lightDirectionVC
[
lightNum
])
>
0
.
0
)
{
float
sf
=
pow
(
max
(
0
.
0
,
dot
(
reflect
(
lightDirectionVC
[
lightNum
],
normalVC
),
viewDirectionVC
)),
specularPower
);
specular
+=
(
sf
*
lightColor
[
lightNum
]);
}
}
diffuse
=
diffuse
*
diffuseColor
;
...
...
Rendering/OpenGL2/vtkVBOPolyDataMapper.cxx
View file @
ece2ba8f
...
...
@@ -217,7 +217,7 @@ void vtkVBOPolyDataMapper::SetLightingShaderParameters(vtkRenderer* ren, vtkActo
}
}
this
->
Internal
->
program
.
setUniformValue
(
"lightColor"
,
numberOfLights
,
lightColor
);
this
->
Internal
->
program
.
setUniformValue
(
"lightDirection"
,
numberOfLights
,
lightDirection
);
this
->
Internal
->
program
.
setUniformValue
(
"lightDirection
VC
"
,
numberOfLights
,
lightDirection
);
this
->
Internal
->
program
.
setUniformValue
(
"numberOfLights"
,
numberOfLights
);
}
...
...
@@ -250,10 +250,12 @@ void vtkVBOPolyDataMapper::SetPropertyShaderParameters(vtkRenderer* ren, vtkActo
vtkgl
::
Vector3ub
specularColor
(
static_cast
<
unsigned
char
>
(
sColor
[
0
]
*
sIntensity
*
255.0
),
static_cast
<
unsigned
char
>
(
sColor
[
1
]
*
sIntensity
*
255.0
),
static_cast
<
unsigned
char
>
(
sColor
[
2
]
*
sIntensity
*
255.0
));
float
specularPower
=
actor
->
GetProperty
()
->
GetSpecularPower
();
this
->
Internal
->
program
.
setUniformValue
(
"opacity"
,
opacity
);
this
->
Internal
->
program
.
setUniformValue
(
"diffuseColor"
,
diffuseColor
);
this
->
Internal
->
program
.
setUniformValue
(
"specularColor"
,
specularColor
);
this
->
Internal
->
program
.
setUniformValue
(
"specularPower"
,
specularPower
);
}
//-----------------------------------------------------------------------------
...
...
@@ -327,13 +329,13 @@ void vtkVBOPolyDataMapper::RenderPiece(vtkRenderer* ren, vtkActor *actor)
this
->
Internal
->
vbo
.
bind
();
this
->
Internal
->
ibo
.
bind
();
this
->
Internal
->
program
.
enableAttributeArray
(
"vertex"
);
this
->
Internal
->
program
.
useAttributeArray
(
"vertex"
,
0
,
this
->
Internal
->
program
.
enableAttributeArray
(
"vertex
MC
"
);
this
->
Internal
->
program
.
useAttributeArray
(
"vertex
MC
"
,
0
,
sizeof
(
float
)
*
6
,
VTK_FLOAT
,
3
,
vtkgl
::
ShaderProgram
::
NoNormalize
);
this
->
Internal
->
program
.
enableAttributeArray
(
"normal"
);
this
->
Internal
->
program
.
useAttributeArray
(
"normal"
,
sizeof
(
float
)
*
3
,
this
->
Internal
->
program
.
enableAttributeArray
(
"normal
MC
"
);
this
->
Internal
->
program
.
useAttributeArray
(
"normal
MC
"
,
sizeof
(
float
)
*
3
,
sizeof
(
float
)
*
6
,
VTK_FLOAT
,
3
,
vtkgl
::
ShaderProgram
::
NoNormalize
);
...
...
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