Enable backface culling by default.

Disable only for geom types that need it (planes and triangles).

PiperOrigin-RevId: 914211570
Change-Id: Id95e32924122789111f561d922110128b3f56c77
This commit is contained in:
Haroon Qureshi
2026-05-12 04:40:39 -07:00
committed by Copybara-Service
parent 5339d9154e
commit 3f3ff85a59
20 changed files with 12 additions and 17 deletions
-1
View File
@@ -15,7 +15,6 @@
material {
name : pbr,
shadingModel : lit,
culling: none,
flipUV: false,
parameters : [
{ type : sampler2d, name : BaseColor },
@@ -15,7 +15,6 @@
material {
name : pbr_packed,
shadingModel : lit,
culling: none,
flipUV: false,
parameters : [
{ type : sampler2d, name : BaseColor },
@@ -15,7 +15,6 @@
material {
name : phong_2d,
shadingModel : specularGlossiness,
culling : none,
flipUV : false,
parameters : [
{ type : float4, name : BaseColorFactor },
@@ -15,7 +15,6 @@
material {
name : phong_2d_fade,
shadingModel : specularGlossiness,
culling : none,
flipUV : false,
blending: fade,
parameters : [
@@ -15,7 +15,6 @@
material {
name : phong_2d_reflect,
shadingModel : specularGlossiness,
culling : none,
flipUV : false,
parameters : [
{ type : float4, name : BaseColorFactor },
@@ -15,7 +15,6 @@
material {
name : phong_2d_uv,
shadingModel : specularGlossiness,
culling : none,
flipUV : false,
parameters : [
{ type : float4, name : BaseColorFactor },
@@ -15,7 +15,6 @@
material {
name : phong_2d_uv_fade,
shadingModel : specularGlossiness,
culling : none,
flipUV : false,
blending: fade,
parameters : [
@@ -15,7 +15,6 @@
material {
name : phong_2d_uv_reflect,
shadingModel : specularGlossiness,
culling : none,
flipUV : false,
parameters : [
{ type : float4, name : BaseColorFactor },
@@ -15,7 +15,6 @@
material {
name : phong_color,
shadingModel : specularGlossiness,
culling: none,
parameters : [
{ type : float4, name : BaseColorFactor },
{ type : float, name : SpecularFactor },
@@ -15,7 +15,6 @@
material {
name : phong_color_fade,
shadingModel : specularGlossiness,
culling: none,
blending: fade,
parameters : [
{ type : float4, name : BaseColorFactor },
@@ -15,7 +15,6 @@
material {
name : phong_color_reflect,
shadingModel : specularGlossiness,
culling: none,
parameters : [
{ type : float4, name : BaseColorFactor },
{ type : float, name : SpecularFactor },
@@ -15,7 +15,6 @@
material {
name : phong_cube,
shadingModel : specularGlossiness,
culling : none,
flipUV : false,
parameters : [
{ type : float4, name : BaseColorFactor },
@@ -15,7 +15,6 @@
material {
name : phong_cube_fade,
shadingModel : specularGlossiness,
culling : none,
flipUV : false,
blending: fade,
parameters : [
@@ -15,7 +15,6 @@
material {
name : phong_cube_reflect,
shadingModel : specularGlossiness,
culling : none,
flipUV : false,
parameters : [
{ type : float4, name : BaseColorFactor },
@@ -15,7 +15,6 @@
material {
name : unlit_decor,
shadingModel : unlit,
culling: none,
parameters : [
{ type : float4, name : BaseColorFactor }
]
@@ -16,7 +16,6 @@ material {
name : unlit_depth,
shadingModel : unlit,
blending : opaque,
culling: none,
depthWrite: true
}
@@ -15,7 +15,6 @@
material {
name : unlit_segmentation,
shadingModel : unlit,
culling: none,
parameters : [
{ type : float4, name : SegmentationColor }
]
@@ -77,6 +77,11 @@ void Renderable::SetMesh(const Mesh* mesh, int elem_offset, int elem_count) {
if (mesh == nullptr) {
mju_error("Cannot set mesh to nullptr.");
}
// We use MESH, even though it could be any mesh-like geom type, e.g.
// heightfields, flex, skin, sdf, etc.
geom_type_ = mjGEOM_MESH;
filament::VertexBuffer* vertex_buffer = mesh->GetFilamentVertexBuffer();
if (vertex_buffer == nullptr) {
mju_error("Invalid (null) vertex buffer.");
@@ -234,6 +239,10 @@ void Renderable::AssignMaterial(mjrDrawMode mode,
}
if (material) {
instances_[index] = material->createInstance();
if (geom_type_ == mjGEOM_PLANE || geom_type_ == mjGEOM_TRIANGLE) {
instances_[index]->setCullingMode(
filament::MaterialInstance::CullingMode::NONE);
}
}
}
@@ -407,6 +416,7 @@ ObjectManager::MaterialType Renderable::GetColorMaterialType() const {
void Renderable::SetGeomMesh(mjtGeom type, int nstack, int nslice, int nquad) {
Builtins* builtins = object_mgr_->GetBuiltins(nstack, nslice, nquad);
geom_type_ = type;
switch (type) {
case mjGEOM_PLANE:
@@ -130,6 +130,7 @@ class Renderable : public mjrRenderable {
ObjectManager* object_mgr_;
mjrRenderableParams params_;
filament::MaterialInstance* instances_[mjNUM_DRAW_MODES] = {nullptr};
mjtGeom geom_type_ = mjGEOM_NONE;
mjrMaterial material_;
mjrDrawMode draw_mode_ = mjDRAW_MODE_COLOR;
filament::Scene* assigned_scene_ = nullptr;
@@ -141,6 +141,7 @@ SceneView::SceneView(FilamentContext* ctx, const mjrSceneParams& params)
reflect_view_->setCamera(reflect_camera_);
reflect_view_->setShadowingEnabled(false);
reflect_view_->setPostProcessingEnabled(false);
reflect_view_->setFrontFaceWindingInverted(true);
reflect_view_->setVisibleLayers(0xff, params.reflection_layer_mask);
// Disable post processing for the depth and segmentation views to preserve