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
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
685f3e79
Commit
685f3e79
authored
Jun 26, 2010
by
Mathias Goldau
Browse files
[FIX] Shader work now under Mac OS X too
parent
7d24a4b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
src/graphicsEngine/shaders/lighting.fs
src/graphicsEngine/shaders/lighting.fs
+15
-15
src/modules/triangleMeshRenderer/shaders/triangleMeshRenderer.fs
...ules/triangleMeshRenderer/shaders/triangleMeshRenderer.fs
+1
-1
No files found.
src/graphicsEngine/shaders/lighting.fs
View file @
685f3e79
...
@@ -9,30 +9,30 @@ const vec4 DEFAULT_BLACK = vec4(0.0, 0.0, 0.0, 0.0);
...
@@ -9,30 +9,30 @@ const vec4 DEFAULT_BLACK = vec4(0.0, 0.0, 0.0, 0.0);
void
directionalLight
(
in
int
i
,
in
vec3
normal
,
in
float
shininess
,
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
nDotVP
;
float
nDotHV
;
float
nDotHV
;
float
pf
;
float
pf
;
vec3
L
=
normalize
(
gl_LightSource
[
i
].
position
.
xyz
-
vertex
.
xyz
);
vec3
L
=
normalize
(
gl_LightSource
[
i
].
position
.
xyz
-
vertex
.
xyz
);
vec3
H
=
normalize
(
L
+
halfvec
.
xyz
);
vec3
H
=
normalize
(
L
+
halfvec
.
xyz
);
nDotVP
=
max
(
0
.
0
,
dot
(
normal
,
normalize
((
gl_LightSource
[
i
].
position
.
xyz
))));
nDotVP
=
max
(
0
.
0
,
dot
(
normal
,
normalize
((
gl_LightSource
[
i
].
position
.
xyz
))));
nDotHV
=
max
(
0
.
0
,
dot
(
normal
,
H
));
nDotHV
=
max
(
0
.
0
,
dot
(
normal
,
H
));
if
(
nDotVP
==
0
.
0
)
if
(
nDotVP
==
0
.
0
)
pf
=
0
.
0
;
pf
=
0
.
0
;
else
else
pf
=
pow
(
nDotHV
,
gl_FrontMaterial
.
shininess
);
pf
=
pow
(
nDotHV
,
gl_FrontMaterial
.
shininess
);
ambient
+=
gl_LightSource
[
i
].
ambient
;
ambient
+=
gl_LightSource
[
i
].
ambient
;
diffuse
+=
gl_LightSource
[
i
].
diffuse
*
nDotVP
;
diffuse
+=
gl_LightSource
[
i
].
diffuse
*
nDotVP
;
specular
+=
gl_LightSource
[
i
].
specular
*
pf
;
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/modules/triangleMeshRenderer/shaders/triangleMeshRenderer.fs
View file @
685f3e79
...
@@ -18,7 +18,7 @@ void main()
...
@@ -18,7 +18,7 @@ void main()
col
=
clamp
(
col
,
0
.
0
,
1
.
0
);
col
=
clamp
(
col
,
0
.
0
,
1
.
0
);
col
.
a
=
opacity
*
0
.
01
;
col
.
a
=
float
(
opacity
)
*
0
.
01
;
// MacOS X has old shader spec, no implicit conversion to float takes place
gl_FragColor
=
col
;
gl_FragColor
=
col
;
}
}
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