Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TSBK07 Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simon Jonsson
TSBK07 Project
Commits
b8cccb7b
Commit
b8cccb7b
authored
2 years ago
by
Adam Borgstrand
Browse files
Options
Downloads
Patches
Plain Diff
Fix bump mapping by multiplying normal with TBN
parent
6f842ec0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main
+0
-0
0 additions, 0 deletions
main
main.cpp
+2
-2
2 additions, 2 deletions
main.cpp
shaders/ray.frag
+8
-3
8 additions, 3 deletions
shaders/ray.frag
with
10 additions
and
5 deletions
main
+
0
−
0
View file @
b8cccb7b
No preview for this file type
This diff is collapsed.
Click to expand it.
main.cpp
+
2
−
2
View file @
b8cccb7b
...
...
@@ -182,8 +182,8 @@ void init(void)
//m = LoadModel("groundsphere.obj");
texID1
=
LoadTexture
(
"Substance_Normal92df.jpg"
,
1
);
// Flipped. Klipper?! FIXAD!
//
texID1 = LoadTexture("normal.jpg", 1); // Flipped. Klipper?! FIXAD!
//
texID1 = LoadTexture("Substance_Normal92df.jpg", 1); // Flipped. Klipper?! FIXAD!
texID1
=
LoadTexture
(
"normal.jpg"
,
1
);
// Flipped. Klipper?! FIXAD!
// Defaults to unit 0
glUniform1i
(
glGetUniformLocation
(
program
,
"texUnit"
),
0
);
...
...
This diff is collapsed.
Click to expand it.
shaders/ray.frag
+
8
−
3
View file @
b8cccb7b
...
...
@@ -62,7 +62,7 @@ vec3 CameraRay(float fieldOfViewY, float aspectRatio, vec2 point)
vec2
UV
(
vec3
intersection
,
int
ID
)
{
vec3
d
=
normalize
(
intersection
-
object_descriptor
[
ID
]);
float
U
=
0
.
5
+
atan
(
d
.
x
,
d
.
z
)
/
(
2
.
0
*
3
.
141592
);
float
U
=
0
.
5
+
atan
(
d
.
z
,
d
.
x
)
/
(
2
.
0
*
3
.
141592
);
float
V
=
0
.
5
+
asin
(
d
.
y
)
/
3
.
141592
;
return
vec2
(
U
,
V
);
}
...
...
@@ -76,7 +76,7 @@ float thetaSphere(vec3 intersection, int ID)
vec3
theta_hat
(
float
theta
)
{
vec3
theta_hat
=
vec3
(
-
cos
(
theta
),
-
sin
(
theta
),
0
);
vec3
theta_hat
=
vec3
(
-
cos
(
theta
),
sin
(
theta
),
0
);
return
theta_hat
;
}
...
...
@@ -207,6 +207,11 @@ vec3 CalculateNormal(vec3 intersection_point, int id)
mat3
tbn
=
TBN
(
N
,
B
,
T
);
vec2
uv
=
UV
(
intersection_point
,
id
);
vec3
normal
=
normalize
(
texture
(
texUnit
,
uv
).
rgb
*
2
.
0
-
1
.
0
);
normal
=
tbn
*
normal
;
//if (dot(N, normal) < 0)
//{
// normal = -normal;
//}
return
normal
;
}
...
...
@@ -320,7 +325,7 @@ void main(void)
if
((
closest_id
>=
0
)
&&
(
closest_distance
<
1500
))
{
int
nr_reflections
=
3
;
int
nr_reflections
=
5
;
int
reflections
=
0
;
int
closest_id_temp
=
-
1
;
for
(
int
i
=
0
;
i
<
nr_reflections
;
i
++
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment