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
Hurstel
CGoGN
Commits
b8823876
Commit
b8823876
authored
Feb 17, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flat colorperface modification
parent
8924e290
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
9 deletions
+20
-9
include/Utils/Shaders/shaderFlatColorPerFace.geom
include/Utils/Shaders/shaderFlatColorPerFace.geom
+20
-9
No files found.
include/Utils/Shaders/shaderFlatColorPerFace.geom
View file @
b8823876
...
...
@@ -6,7 +6,7 @@ uniform mat4 ModelViewMatrix;
uniform
vec3
lightPosition
;
uniform
vec4
ambient
;
VARYING_IN
vec3
colorVertex
[
];
VARYING_IN
vec3
colorVertex
[
3
];
// input is triangles -> 3
VARYING_OUT
vec4
ColorFS
;
void
main
(
void
)
...
...
@@ -20,26 +20,37 @@ void main(void)
vec4
newPos
=
ModelViewMatrix
*
vec4
(
center
,
0
.
0
);
vec3
L
=
normalize
(
lightPosition
-
newPos
.
xyz
);
float
lambertTerm
=
dot
(
N
,
L
);
#ifdef AVERGAGE_COLOR
int
i
;
vec3
averageColor
=
vec3
(
0
.,
0
.,
0
.);
for
(
i
=
0
;
i
<
NBVERTS_IN
;
i
++
)
{
for
(
i
=
0
;
i
<
3
;
i
++
)
averageColor
+=
colorVertex
[
i
];
}
averageColor
/=
float
(
NBVERTS_IN
);
averageColor
/=
3
.
0
;
ColorFS
=
ambient
;
if
(
lambertTerm
>
0
.
0
)
ColorFS
+=
vec4
(
averageColor
,
1
.
0
)
*
lambertTerm
;
for
(
i
=
0
;
i
<
NBVERTS_IN
;
i
++
)
for
(
i
=
0
;
i
<
3
;
i
++
)
{
vec4
pos
=
explode
*
POSITION_IN
(
i
)
+
(
1
.
0
-
explode
)
*
vec4
(
center
,
1
.
0
);
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
}
EndPrimitive
();
#else
int
i
;
for
(
i
=
0
;
i
<
3
;
i
++
)
{
vec4
pos
=
explode
*
POSITION_IN
(
i
)
+
(
1
.
0
-
explode
)
*
vec4
(
center
,
1
.
0
);
ColorFS
=
ambient
;
if
(
lambertTerm
>
0
.
0
)
ColorFS
+=
vec4
(
colorVertex
[
i
],
1
.
0
)
*
lambertTerm
;
gl_Position
=
ModelViewProjectionMatrix
*
pos
;
EmitVertex
();
}
EndPrimitive
();
#endif
}
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