That means you can:
- create a
Materialasset from the asset browser - choose whether it is
LitorUnlit - optionally point that material at a custom
Shaderasset - assign a base color
- tune
SpecularandSmoothnessfor the shared lit shader - optionally assign a base texture
- assign that material to built-in 3D renderers from the Inspector
Materials pair with scene ambient light plus DirectionalLight and
PointLight, so projects can move past flat per-component color alone.
What This Guide Covers
The material workflow is strongest for:
CubeRendererSphereRendererCylinderRendererPlaneRendererMeshRendererModelRenderer
Material behavior in this workflow:
- built-in primitive renderers use the material's base color
- the richer shared lit response now covers the built-in primitive renderer set
MeshRenderercan use the material's base color and base textureModelRendereruses the material's base color
Selecting a material asset now also renders a preview sphere in the Inspector
using the same shared Lit / Unlit shader path, so Base Color,
Specular, Smoothness, and textures can be judged without entering play mode.
Creating a Material Asset
- In the Assets panel, create a new
Materialasset. - Give it a name that matches its role, such as
PlayerBall,Pickup, orGround. - Select the material asset to edit it in the Inspector.
The material Inspector exposes:
NameShaderShader AssetBase TextureBase ColorSpecularSmoothness- a live preview sphere
Shader is still the built-in fallback mode.
Shader Asset is the custom programmable path.
Custom shader assets support this Surface3D shape:
Domain = Surface3DSurface Mode = Unlit- GLSL vertex and fragment source files
If the custom shader asset is invalid or unsupported, the material falls back to
its built-in Shader mode instead of breaking rendering outright.
Assigning a Material to a Renderer
- Select a game object with a built-in 3D renderer.
- In the renderer card, find the
Materialfield. - Pick a material asset or drag one onto the field.
That material reference is then serialized with the scene, so it round-trips cleanly through edit, save, and runtime load.
Using A Custom Shader Asset
- Create a
Shaderasset in the Assets panel. - Open the shader asset and assign its
Vertex SourceandFragment Source. - Select a material asset.
- Set
Shader Assetto the shader you just created. - Assign that material to a 3D renderer.
Material preview now validates and compiles the referenced shader asset, so compile problems show up in the Inspector instead of only surfacing later at runtime.
The RollerWorld sample project includes a working example:
Assets/Shaders/PickupBands.shader.jsonAssets/Materials/Pickup.material.json
The pickups in Level1.scene.json and ObstacleCourse.scene.json use that
custom shader-backed material.
PHP Example
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\MeshRenderer;
final class GroundSetup extends Behaviour
{
public function start(): void
{
$renderer = $this->gameObject->getComponent(MeshRenderer::class);
if (!$renderer instanceof MeshRenderer) {
return;
}
$renderer->materialPath = 'Assets/Materials/Ground.material.json';
}
}
The same materialPath pattern works across the built-in 3D renderer surface.
Lit vs Unlit
Lit and Unlit are the standard material modes.
Currently supported:
Unlitis the right choice when you want predictable flat presentationLitworks with scene ambient plusDirectionalLightandPointLight
Lit works with scene ambient plus DirectionalLight and PointLight.
Limits to Keep in Mind
This guide focuses on reusable material assets, shared lighting, and editor preview support.