Skip to content

[WIP] Transparency sorting #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ impl Default for Line {
#[derive(Derivative)]
#[derivative(Clone, Debug, PartialEq, Hash, Eq)]
pub struct Pbr {
/// Solid base color applied in the absense of `base_color_map`.
/// Solid base color applied in the absence of `base_color_map`.
///
/// Default: `WHITE`.
pub base_color_factor: Color,

/// Base color alpha factor applied in the absense of `base_color_map`.
/// Base color alpha factor applied in the absence of `base_color_map`.
///
/// Default: `1.0` (opaque).
#[derivative(Hash(hash_with = "util::hash_f32"))]
Expand All @@ -136,20 +136,20 @@ pub struct Pbr {
pub roughness_factor: f32,

/// Scalar multiplier in the range [0.0, 1.0] that controls the amount of
/// occlusion applied in the presense of `occlusion_map`.
/// occlusion applied in the presence of `occlusion_map`.
///
/// Default: `1.0`.
#[derivative(Hash(hash_with = "util::hash_f32"))]
pub occlusion_strength: f32,

/// Solid emissive color applied in the absense of `emissive_map`.
/// Solid emissive color applied in the absence of `emissive_map`.
///
/// Default: `BLACK`.
pub emissive_factor: Color,

/// Scalar multiplier applied to each normal vector of the `normal_map`.
///
/// This value is ignored in the absense of `normal_map`.
/// This value is ignored in the absence of `normal_map`.
///
/// Default: `1.0`.
#[derivative(Hash(hash_with = "util::hash_f32"))]
Expand Down Expand Up @@ -330,3 +330,19 @@ impl From<Wireframe> for Material {
Material::Wireframe(params)
}
}

impl Material {
/// Returns true if the material is fully opaque.
pub fn is_opaque(&self) -> bool {
match *self {
Material::Basic(_) => true,
Material::CustomBasic(_) => true,
Material::Line(_) => true,
Material::Lambert(_) => true,
Material::Phong(_) => true,
Material::Pbr(_) => true,
Material::Sprite(_) => false,
Material::Wireframe(_) => true,
}
}
}
4 changes: 2 additions & 2 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ impl Renderer {
shadow1: &h::ShaderResourceView<back::Resources, f32>,
displacement_contributions: &[DisplacementContribution],
displacements: (h::ShaderResourceView<back::Resources, [f32; 4]>, h::Sampler<back::Resources>),
joint_transform_buffer_view: h::ShaderResourceView<back::Resources, [f32; 4]>,
joint_transforms: h::ShaderResourceView<back::Resources, [f32; 4]>,
displace: bool,
) {
encoder.update_buffer(&inst_buf, instances, 0).unwrap();
Expand Down Expand Up @@ -1205,7 +1205,7 @@ impl Renderer {
depth_target: out_depth,
displacement_contributions: displacement_contributions_buf,
displacements,
joint_transforms: joint_transform_buffer_view,
joint_transforms,
};
encoder.draw(&slice, &pso.pbr, &data);
}
Expand Down