-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5aa9f4a
commit 430445a
Showing
7 changed files
with
173 additions
and
3 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
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
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 |
---|---|---|
|
@@ -2,3 +2,4 @@ mod msaa; | |
mod object; | ||
mod shadow; | ||
mod simple; | ||
mod transparency; |
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,50 @@ | ||
use anyhow::Context; | ||
use glam::{Mat4, Quat, Vec3, Vec4}; | ||
use rend3::types::{Camera, Handedness}; | ||
use rend3_test::{no_gpu_return, test_attr, FrameRenderSettings, TestRunner, Threshold}; | ||
|
||
/// Ensure that transparency is ordered correctly | ||
// | ||
// Todo: This test never fails, even if I remove the sort. | ||
#[test_attr] | ||
pub async fn transparency() -> anyhow::Result<()> { | ||
let iad = no_gpu_return!(rend3::create_iad(None, None, None, None).await) | ||
.context("InstanceAdapterDevice creation failed")?; | ||
|
||
let Ok(runner) = TestRunner::builder().iad(iad.clone()).handedness(Handedness::Left).build().await else { | ||
return Ok(()); | ||
}; | ||
|
||
runner.set_camera_data(Camera { | ||
projection: rend3::types::CameraProjection::Raw(Mat4::IDENTITY), | ||
view: Mat4::IDENTITY, | ||
}); | ||
|
||
let material1 = runner.add_transparent_material(Vec4::new(1.0, 0.0, 0.0, 0.5)); | ||
let material2 = runner.add_transparent_material(Vec4::new(0.0, 1.0, 0.0, 0.5)); | ||
let _object_left_1 = runner.plane( | ||
material1.clone(), | ||
Mat4::from_scale_rotation_translation(Vec3::new(-0.25, 0.25, 0.25), Quat::IDENTITY, Vec3::new(-0.5, 0.0, -0.5)), | ||
); | ||
|
||
let _object_left_2 = runner.plane( | ||
material2.clone(), | ||
Mat4::from_scale_rotation_translation(Vec3::new(-0.25, 0.25, 0.25), Quat::IDENTITY, Vec3::new(-0.5, 0.0, 0.5)), | ||
); | ||
|
||
let _object_right_2 = runner.plane( | ||
material2, | ||
Mat4::from_scale_rotation_translation(Vec3::new(-0.25, 0.25, 0.25), Quat::IDENTITY, Vec3::new(0.5, 0.0, 0.5)), | ||
); | ||
|
||
let _object_right_1 = runner.plane( | ||
material1, | ||
Mat4::from_scale_rotation_translation(Vec3::new(-0.25, 0.25, 0.25), Quat::IDENTITY, Vec3::new(0.5, 0.0, -0.5)), | ||
); | ||
|
||
runner | ||
.render_and_compare(FrameRenderSettings::new(), "tests/results/transparency/blending.png", Threshold::Mean(0.0)) | ||
.await?; | ||
|
||
Ok(()) | ||
} |
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