D3D11: variable number of lights in HLSL
问题 I'm working on a game engine in C++ and Direct3D11 and I want now to add a variable number lights to the scene. Up to date, I managed to add and render simple lights of a count that was already known and coded in the shader programs. In shader.fx: static const int LightsCount= 4; struct NF3D_LIGHT { // Members... }; cbuffer Light : register(b5) { NF3D_LIGHT light[LightsCount]; }; ... // And the pixel shader function: float4 PS(PS_INPUT input) : SV_Target { for(int i = 0; i < LightsCount; i++)