Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Renderer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Flueren
Renderer
Commits
a3644701
Commit
a3644701
authored
Oct 5, 2022
by
Jonathan Flueren
Browse files
Options
Downloads
Patches
Plain Diff
More tries to fix Metal material
parent
fd9cbea2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.rs
+4
-4
4 additions, 4 deletions
src/main.rs
src/material.rs
+2
-2
2 additions, 2 deletions
src/material.rs
with
6 additions
and
6 deletions
src/main.rs
+
4
−
4
View file @
a3644701
...
...
@@ -39,7 +39,7 @@ fn ray_color(r: &Ray, world: &HittableList, depth: u32) -> Color {
{
return
attenuation
*
ray_color
(
&
scattered
,
world
,
depth
-
1
);
}
return
Color
::
null
();
return
Color
::
new
(
255.0
,
0.0
,
0.0
);
//
Color::null();
}
let
unit_direction
=
r
.direction
();
...
...
@@ -67,7 +67,7 @@ fn main() {
// Image
let
aspect_ratio
=
10.0
/
7.5
;
//16.0 / 9.0;
let
image_width
=
3
00
;
let
image_width
=
12
00
;
let
image_height
=
(
image_width
as
f64
/
aspect_ratio
)
as
u32
;
let
samples_per_pixel
=
1_u32
;
let
max_depth
=
50
;
...
...
@@ -287,10 +287,10 @@ fn from_obj(path: &str) -> HittableList {
// 118.0 / 255.0,
//)));
//let material = Arc::new(Dielectric::new(2.0));
let
material
=
Arc
::
new
(
Metal
::
new
(
&
Color
::
new
(
0.
7
,
0.
6
,
0.
5
),
0.0
));
let
material
=
Arc
::
new
(
Metal
::
new
(
&
Color
::
new
(
0.
5
,
0.
55
,
0.
7
),
0.0
));
//let material = Arc::new(Rainbow::new());
let
rotate_obj
=
0
;
// rotate clockwise, 0: 0, 1: 90, 2: 180, 3: 270
let
rotate_obj
=
1
;
// rotate clockwise, 0: 0, 1: 90, 2: 180, 3: 270
let
cornell_box
=
tobj
::
load_obj
(
path
,
&
tobj
::
OFFLINE_RENDERING_LOAD_OPTIONS
);
let
(
models
,
materials
)
=
cornell_box
.expect
(
"Failed to load OBJ file"
);
...
...
This diff is collapsed.
Click to expand it.
src/material.rs
+
2
−
2
View file @
a3644701
...
...
@@ -77,13 +77,13 @@ impl Material for Metal {
*
scattered
=
Ray
::
new
(
rec
.p
,
reflected
+
self
.fuzz
*
Vec3
::
random_in_unit_sphere
());
*
attenuation
=
self
.albedo
.clone
();
let
reflect
=
Vec3
::
dot
(
scattered
.direction
(),
rec
.normal
);
let
reflect
=
Vec3
::
dot
(
r_in
.direction
(),
rec
.normal
);
//dbg!(reflect);
/*if reflect > 0.0 {
*attenuation = Color::new(100.0, 0.0, 0.0);
}*/
return
reflect
>
0.0
;
return
true
;
//
reflect > 0.0;
}
}
...
...
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