mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 15:14:50 +00:00
gltf-loader: disable backface culling if material is double-sided (#4270)
# Objective
The [glTF spec](8e798b02d2/specification/2.0/Specification.adoc (395-double-sided)
) the `doubleSided` has the following to say about the `doubleSided` boolean:
> When this value is false, back-face culling is enabled, i.e., only front-facing triangles are rendered.
> When this value is true, back-face culling is disabled and double sided lighting is enabled. The back-face MUST have its normals reversed before the lighting equation is evaluated.
## Solution
Disable backface culling when `doubleSided: true`.
This commit is contained in:
parent
af24576b96
commit
3e631e6234
1 changed files with 6 additions and 1 deletions
|
@ -18,7 +18,7 @@ use bevy_render::{
|
|||
color::Color,
|
||||
mesh::{Indices, Mesh, VertexAttributeValues},
|
||||
primitives::{Aabb, Frustum},
|
||||
render_resource::{AddressMode, FilterMode, PrimitiveTopology, SamplerDescriptor},
|
||||
render_resource::{AddressMode, Face, FilterMode, PrimitiveTopology, SamplerDescriptor},
|
||||
renderer::RenderDevice,
|
||||
texture::{CompressedImageFormats, Image, ImageType, TextureError},
|
||||
view::VisibleEntities,
|
||||
|
@ -473,6 +473,11 @@ fn load_material(material: &Material, load_context: &mut LoadContext) -> Handle<
|
|||
metallic_roughness_texture,
|
||||
normal_map_texture,
|
||||
double_sided: material.double_sided(),
|
||||
cull_mode: if material.double_sided() {
|
||||
None
|
||||
} else {
|
||||
Some(Face::Back)
|
||||
},
|
||||
occlusion_texture,
|
||||
emissive: Color::rgba(emissive[0], emissive[1], emissive[2], 1.0),
|
||||
emissive_texture,
|
||||
|
|
Loading…
Reference in a new issue