Implement Source engine VMT shader types #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Currently all BSP surfaces use a single shader (base texture × lightmap). Source engine VMT files specify different shader types that control how surfaces are rendered. We should parse the shader type from VMT files and create appropriate materials.
Shader types to implement
LightmappedGeneric (most BSP surfaces)
$translucent,$alphatest,$alphatestreference,$detail,$detailscale,$bumpmap,$envmap,$selfillumUnlitGeneric (overlays, decals, signs)
$translucent,$alphatest,$additiveWorldVertexTransition (terrain blending)
$basetexture,$basetexture2, blended per-vertexVertexLitGeneric (props/models — lower priority)
Current state
$basetexture(seeclient/src/bsp/vmt.js)client/src/bsp/material.jshas the custom ShaderMaterial — this would become a factory that creates the right material based on VMT shader typeNotes
Related: #11 (material overrides/entity colors). VMT shaders define material behavior, while #11 covers entity-level overrides like
rendercolor/renderamt. Both affect final material appearance but at different levels — #8 is the base material, #11 is per-entity runtime overrides.Progress update — shader type implementation
Most VMT shader types are now handled in the material system. Current status:
Implemented and working
Bug fixes applied
pow(1-NdotV,5) * (1-fresnelReflection) + fresnelReflectionStill needed
$envmap "env_cubemap"which needs BSP-baked cubemaps, not just the skybox fallbackUpdate — envmap and cubemap work complete
Per-surface env_cubemap selection (#21) is now fully implemented:
$basealphaenvmapmaskpolarity fixed (inverted to match Source:1.0 - alpha)ENV_MAP_SCALEapplied with gamma-aware linearize→scale→encodeRemaining for this issue
Note: the shader now operates in a full linear color pipeline (
36368a2, #44). All texture inputs are linearized, lighting math is done in linear space, and there's a single gamma encode at output. Any new shader features added here should work in linear space — no per-path gamma conversions needed.Progress update — bump mapping (
$bumpmap) is now implemented for LightmappedGeneric BSP surfaces as ofa27c9ef:Also in the same batch:
$coloris now applied as a gamma-space lightmap multiplier (matching Source'sg_TintValuesAndLightmapScale), and$selfillumtinthandling matches Source'sg_SelfIllumTint * albedopattern.Remaining from this issue's checklist:
$detail(partially done — blend modes implemented,$detailtintnot yet),$envmapimprovements are ongoing (#45 just fixed).