Original Post
I'm working on a per-pixel lighting system that can add and remove lights in real time. However I have 2 problems with arrays in HLSL at the moment. Problem 1: Despite having found a few websites that say otherwise, I can't seem to use a variable to define the size of an array. This is what I'm trying to do: uniform extern int gNumLights; uniform extern float4 gAmbientLight[gNumLights]; //etc etc for all the light properties When I try to run it I get an error saying: array dimensions must be literal scalar expressions. If I hard set it to a value like 3 it runs fine. So is it possible for me to use another variable to define the size of global arrays and if so, how? Problem 2: I'm passing the data for the light property arrays above from my C++ code as std::vectors which I assumed would work as essentially they are just fancy arrays. Although it compiles and runs fine, it doesn't seem to make the pixel shader actually do its job. Is there anything special I need to do to make this vector to array setup work? I've done some tests and it all points to the arrays being the problem, at this point I'm trying to determine if it's this conversion that is causing the problem. Thanks.