-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add image texture to Lambertian material
- Loading branch information
1 parent
79fc2ce
commit 9aa2f62
Showing
12 changed files
with
99 additions
and
29 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
camera.pos = {0.0, 0.0, 6.0} | ||
camera.center = {0.0, 0.0, 0.0} | ||
camera.fov = math.rad(20.0) | ||
|
||
scene:set_env(Color3.new{1.0, 1.0, 1.0}) | ||
|
||
material_ball = Lambertian.new(Image.new("assets/earthmap.jpg")) | ||
scene:add(Sphere.new({0.0, 0.0, 0.0}, 1.0, material_ball)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
mod color; | ||
mod image; | ||
mod image_hdr; | ||
mod panorama; | ||
|
||
pub use color::Color; | ||
pub use image::Image; | ||
pub use image_hdr::ImageHdr; | ||
pub use panorama::Panorama; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crate::core::{Texture2, Texture3}; | ||
use nalgebra::{Vector2, Vector3}; | ||
use palette::LinSrgb; | ||
|
||
pub struct Color { | ||
color: LinSrgb<f64>, | ||
} | ||
|
||
impl Color { | ||
pub fn new(color: LinSrgb<f64>) -> Self { | ||
Self { color } | ||
} | ||
} | ||
|
||
impl Texture2 for Color { | ||
fn sample(&self, _uv: Vector2<f64>) -> LinSrgb<f64> { | ||
self.color | ||
} | ||
} | ||
|
||
impl Texture3 for Color { | ||
fn sample(&self, _uvw: Vector3<f64>) -> LinSrgb<f64> { | ||
self.color | ||
} | ||
} |