Physically-based punctual lighting system (point + spot lights)#81
Draft
Physically-based punctual lighting system (point + spot lights)#81
Conversation
Add multi-light support with physically-based distance attenuation (UE4/Frostbite inverse-square + range windowing) and spot light angular falloff for point and spot lights. Shader changes: - Add PointLightData/SpotLightData structs in default_pass.hlslh - Add light counts to global cbuffer - New punctual_light.hlslh with EvaluatePointLight/EvaluateSpotLight - Integrate punctual light loop in standard_pbr.hlsl (ENABLE_PUNCTUAL_LIGHTS) C++ changes: - Add ShaderPointLightData/ShaderSpotLightData/ShaderLightInfo to RenderBuiltinLayout.h - Enhance PointLight/SpotLight with physical params (range, inner/outer cone) - LightFeatureProcessor gathers punctual light data for GPU upload - Pipeline binds light UBOs at slots 12-13 - New PointLightComponent/SpotLightComponent ECS components Agent-Logs-Url: https://github.com/bluesky013/SkyEngine/sessions/443e8444-26ec-4c5b-b076-7543a63da3aa Co-authored-by: bluesky013 <35895395+bluesky013@users.noreply.github.com>
…dant copies Agent-Logs-Url: https://github.com/bluesky013/SkyEngine/sessions/443e8444-26ec-4c5b-b076-7543a63da3aa Co-authored-by: bluesky013 <35895395+bluesky013@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Design a physical lighting scheme
Physically-based punctual lighting system (point + spot lights)
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The engine only supported a single main directional light. This adds a complete multi-light pipeline for point and spot lights with physically-based attenuation.
Shader
lighting/punctual_light.hlslh(new) — Inverse-square distance attenuation with smooth range windowing (saturate(1-(d/r)⁴)² / max(d²,ε)), spot angular falloff, Cook-Torrance BRDF evaluation per punctual lightlayout/default_pass.hlslh—PointLightData/SpotLightDatastructs + cbuffer bindings at slots 12–13 (MAX_POINT_LIGHTS=8, MAX_SPOT_LIGHTS=4)layout/default_global_view.hlslh—PointLightCount/SpotLightCountadded to global cbufferstandard_pbr.hlsl—ENABLE_PUNCTUAL_LIGHTSpass option; light accumulation loop in FSMainC++ core
RenderBuiltinLayout.h— GPU-matching structs (ShaderPointLightData,ShaderSpotLightData, buffer wrappers);ShaderPassInfoextended with light countsLightBase.h/cpp—PointLightgets position/range;SpotLightgets position/direction/range/inner+outer cone anglesLightFeatureProcessor—GatherPunctualLightData()collects lights into GPU-ready buffers eachTick()DefaultForwardPipeline— UBO init + per-frame upload for light buffers at descriptor slots 12–13ECS integration
PointLightComponent/SpotLightComponent—ComponentAdaptor+ITransformEventpattern, serialization, registered inRenderModuleUsage
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.