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
7be6912b
Commit
7be6912b
authored
Jun 02, 2010
by
Sebastian Eichelbaum
Browse files
[CHANGE] - improved phong lighting in isosurface raytracer
parent
13800a44
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
12 deletions
+31
-12
src/modules/isosurfaceRaytracer/shaders/IsosurfaceRaytracer.fs
...odules/isosurfaceRaytracer/shaders/IsosurfaceRaytracer.fs
+30
-11
src/modules/isosurfaceRaytracer/shaders/IsosurfaceRaytracer.vs
...odules/isosurfaceRaytracer/shaders/IsosurfaceRaytracer.vs
+1
-1
No files found.
src/modules/isosurfaceRaytracer/shaders/IsosurfaceRaytracer.fs
View file @
7be6912b
...
...
@@ -158,7 +158,7 @@ void main()
#
endif
#
ifdef
PHONG
// find a proper normal for a headlight
float
s
=
0
.
0
05
;
float
s
=
0
.
0
1
;
float
valueXP
=
texture3D
(
tex0
,
curPoint
+
vec3
(
s
,
0
.
0
,
0
.
0
)
).
r
;
float
valueXM
=
texture3D
(
tex0
,
curPoint
-
vec3
(
s
,
0
.
0
,
0
.
0
)
).
r
;
float
valueYP
=
texture3D
(
tex0
,
curPoint
+
vec3
(
0
.
0
,
s
,
0
.
0
)
).
r
;
...
...
@@ -166,18 +166,11 @@ void main()
float
valueZP
=
texture3D
(
tex0
,
curPoint
+
vec3
(
0
.
0
,
0
.
0
,
s
)
).
r
;
float
valueZM
=
texture3D
(
tex0
,
curPoint
-
vec3
(
0
.
0
,
0
.
0
,
s
)
).
r
;
vec3
dir
=
vec3
(
0
.
0
);//
v_ray
;
dir
+=
vec3
(
valueXP
,
0
.
0
,
0
.
0
);
dir
-=
vec3
(
valueXM
,
0
.
0
,
0
.
0
);
dir
+=
vec3
(
0
.
0
,
valueYP
,
0
.
0
);
dir
-=
vec3
(
0
.
0
,
valueYM
,
0
.
0
);
dir
+=
vec3
(
0
.
0
,
0
.
0
,
valueZP
);
dir
-=
vec3
(
0
.
0
,
0
.
0
,
valueZP
);
vec3
dir
=
vec3
(
valueXP
-
valueXM
,
valueYP
-
valueYM
,
valueZP
-
valueZM
)
;//
v_ray
;
// Phong:
float
light
=
blinnPhongIlluminationIntensity
(
0
.
3
,
// material ambient
1
.
0
,
// material diffuse
0
.
1
,
// material ambient
0
.
75
,
// material diffuse
1
.
3
,
// material specular
10
.
0
,
// shinines
1
.
0
,
// light diffuse
...
...
@@ -190,6 +183,32 @@ void main()
color
=
light
*
gl_Color
;
#
endif
#
ifdef
PHONGWITHDEPTH
float
d
=
1
.
0
-
curPointProjected
.
z
;
// find a proper normal for a headlight
float
s
=
0
.
01
;
float
valueXP
=
texture3D
(
tex0
,
curPoint
+
vec3
(
s
,
0
.
0
,
0
.
0
)
).
r
;
float
valueXM
=
texture3D
(
tex0
,
curPoint
-
vec3
(
s
,
0
.
0
,
0
.
0
)
).
r
;
float
valueYP
=
texture3D
(
tex0
,
curPoint
+
vec3
(
0
.
0
,
s
,
0
.
0
)
).
r
;
float
valueYM
=
texture3D
(
tex0
,
curPoint
-
vec3
(
0
.
0
,
s
,
0
.
0
)
).
r
;
float
valueZP
=
texture3D
(
tex0
,
curPoint
+
vec3
(
0
.
0
,
0
.
0
,
s
)
).
r
;
float
valueZM
=
texture3D
(
tex0
,
curPoint
-
vec3
(
0
.
0
,
0
.
0
,
s
)
).
r
;
vec3
dir
=
vec3
(
valueXP
-
valueXM
,
valueYP
-
valueYM
,
valueZP
-
valueZM
)
;//
v_ray
;
// Phong:
float
light
=
blinnPhongIlluminationIntensity
(
0
.
1
,
// material ambient
d
*
d
,
// material diffuse
1
.
3
,
// material specular
10
.
0
,
// shinines
1
.
0
,
// light diffuse
0
.
3
,
// light ambient
normalize
(
-
dir
),
// normal
normalize
(
v_ray
),
// view direction
normalize
(
v_lightSource
)
// light source position
);
color
=
light
*
gl_Color
;
#
endif
color
.
a
=
u_alpha
;
...
...
src/modules/isosurfaceRaytracer/shaders/IsosurfaceRaytracer.vs
View file @
7be6912b
...
...
@@ -71,7 +71,7 @@ void main()
// also get the coordinates of the light
vec4
lpos
=
gl_LightSource
[
0
].
position
;
//
lpos = vec4( 0.0, 0.0, 1000.0, 1.0 );
lpos
=
vec4
(
0
.
0
,
0
.
0
,
1000
.
0
,
1
.
0
);
v_lightSource
=
worldToLocal
(
lpos
).
xyz
;
// Simply project the vertex
...
...
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