// BVLE Voxels - Toping Pixel Shader (Phase 4.2) // Simplified version of voxelPS: triplanar texture sampling + basic lighting. // No height-based blending (topings are small decorative meshes). #include "voxelCommon.hlsli" Texture2DArray materialTextures : register(t1); SamplerState texSampler : register(s0); struct PSInput { float4 position : SV_POSITION; float3 worldPos : WORLDPOS; float3 normal : NORMAL; nointerpolation uint materialID : MATERIALID; }; [RootSignature(VOXEL_ROOTSIG)] float4 main(PSInput input) : SV_TARGET0 { float3 N = normalize(input.normal); float tiling = textureTiling; // Material texture index (materialID 1-5 → array layer 0-4) uint texIdx = clamp(input.materialID - 1u, 0u, 4u); // Triplanar sampling (same as voxel PS) float3 blend = abs(N); blend = blend / (blend.x + blend.y + blend.z + 0.001); float4 xSample = materialTextures.Sample(texSampler, float3(input.worldPos.yz * tiling, (float)texIdx)); float4 ySample = materialTextures.Sample(texSampler, float3(input.worldPos.xz * tiling, (float)texIdx)); float4 zSample = materialTextures.Sample(texSampler, float3(input.worldPos.xy * tiling, (float)texIdx)); float3 texColor = (xSample.rgb * blend.x + ySample.rgb * blend.y + zSample.rgb * blend.z); // Basic directional lighting + ambient float3 L = normalize(-sunDirection.xyz); float NdotL = max(dot(N, L), 0.0); float3 ambient = float3(0.15, 0.18, 0.25); float3 lit = texColor * (sunColor.rgb * NdotL + ambient); return float4(lit, 1.0); }