Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
KennethVanhoey
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