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:
Jakob Hellermann 2022-03-20 21:32:38 +00:00
parent af24576b96
commit 3e631e6234

View file

@ -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,