Files
Mujoco_WASM/src/experimental/filament/assets/pbr_packed.mat
T
Haroon Qureshi ff7c613c79 Initial implementation of the filament rendering backend for mujoco.
This is intended as a drop-in replacement for mjr_render to enable high
quality, physically-based rendering (PBR) using the filament render engine.

This is a work-in-progress and, as such, some features may be missing. This
is also a code-only drop; build files (including instructions on how to
generate the filament materials) will be provided at a later date.

This library is intended to be run with the experimental studio app.

PiperOrigin-RevId: 817593684
Change-Id: Ib9cd14c1881e4897c1111275bd749aa38ebb5317
2025-10-10 05:01:39 -07:00

52 lines
1.8 KiB
Plaintext

// Copyright 2025 DeepMind Technologies Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
material {
name : pbr_packed,
shadingModel : lit,
culling: none,
flipUV: false,
parameters : [
{ type : sampler2d, name : BaseColor },
{ type : sampler2d, name : Normal },
{ type : sampler2d, name : ORM },
{ type : sampler2d, name : Emissive },
{ type : float4, name : BaseColorFactor },
{ type : float, name : MetallicFactor },
{ type : float, name : RoughnessFactor }
],
requires : [
uv0
]
}
fragment {
void material(inout MaterialInputs material) {
vec2 uv = getUV0();
material.normal = texture(materialParams_Normal, uv).xyz * 2.0 - 1.0;
prepareMaterial(material);
material.baseColor = materialParams.BaseColorFactor;
material.baseColor *= texture(materialParams_BaseColor, uv);
material.ambientOcclusion = texture(materialParams_ORM, uv).r;
material.roughness = materialParams.RoughnessFactor;
material.roughness *= texture(materialParams_ORM, uv).g;
material.metallic = materialParams.MetallicFactor;
material.metallic *= texture(materialParams_ORM, uv).b;
material.emissive = texture(materialParams_Emissive, uv);
material.emissive.a = 1.0 - material.emissive.a;
}
}