Use custom BSP shader materials for entity models #20

Closed
opened 2026-03-18 02:14:51 +00:00 by kit · 0 comments
Owner

Entity models currently use Three.js MeshLambertMaterial, which means they don't benefit from our custom shader pipeline (sun lighting uniforms, envmap reflections, detail textures, $color tinting, $selfillum, etc.). They also don't properly resolve VMT shader properties.

Problem

  • Models use MeshLambertMaterial in client/src/mdl/loader.js — no access to our uber-shader features
  • VMT properties like $envmap, $detail, $selfillum, $phong, $color are ignored on model materials
  • Sun lighting on models relies on Three.js scene lights rather than the shader's useSunLighting path
  • Shadow mapping (future) needs to work consistently across BSP world geometry and entity models, which requires a shared shader pipeline

Requirements

  • Replace MeshLambertMaterial with createBSPMaterial() in the model loader
  • Wire up VMT/VTF resolution for model textures through the same applyVMTProperties path used by BSP faces
  • Set useSunLighting: true for VertexLitGeneric materials on models (they have no lightmap)
  • Ensure model meshes have the vertex attributes the shader expects (uv2, color, normal)
  • Remove the Three.js DirectionalLight/AmbientLight scene lights once all surfaces use the custom shader

Context

  • BSP shader material system: client/src/bsp/material.js
  • Model loader: client/src/mdl/loader.js
  • Sun/ambient parsed from light_environment entity in client/src/bsp/loader.js
  • This is a prerequisite for shadow mapping — shadows need a consistent shader across BSP and entities
Entity models currently use Three.js `MeshLambertMaterial`, which means they don't benefit from our custom shader pipeline (sun lighting uniforms, envmap reflections, detail textures, $color tinting, $selfillum, etc.). They also don't properly resolve VMT shader properties. ## Problem - Models use `MeshLambertMaterial` in `client/src/mdl/loader.js` — no access to our uber-shader features - VMT properties like `$envmap`, `$detail`, `$selfillum`, `$phong`, `$color` are ignored on model materials - Sun lighting on models relies on Three.js scene lights rather than the shader's `useSunLighting` path - Shadow mapping (future) needs to work consistently across BSP world geometry and entity models, which requires a shared shader pipeline ## Requirements - Replace `MeshLambertMaterial` with `createBSPMaterial()` in the model loader - Wire up VMT/VTF resolution for model textures through the same `applyVMTProperties` path used by BSP faces - Set `useSunLighting: true` for VertexLitGeneric materials on models (they have no lightmap) - Ensure model meshes have the vertex attributes the shader expects (`uv2`, `color`, `normal`) - Remove the Three.js `DirectionalLight`/`AmbientLight` scene lights once all surfaces use the custom shader ## Context - BSP shader material system: `client/src/bsp/material.js` - Model loader: `client/src/mdl/loader.js` - Sun/ambient parsed from `light_environment` entity in `client/src/bsp/loader.js` - This is a prerequisite for shadow mapping — shadows need a consistent shader across BSP and entities
kit closed this issue 2026-03-18 08:18:15 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kit/gmod-web-stream#20
No description provided.