SiebenCorgie / ori-engine

A small engine written in rust + vulkan.
Other
7 stars 1 forks source link

Dynamic light loop in PBR Shader #22

Closed SiebenCorgie closed 7 years ago

SiebenCorgie commented 7 years ago

Its better to have a somewhat dynamic light loop in the shader like this:

 for (uint i = 0U; i < min(MAX_LIGHTS, u_NumLights); ++i) {
}

(taken from here: https://github.com/three-rs/three/blob/master/data/shaders/pbr_ps.glsl )

SiebenCorgie commented 7 years ago

Has also been fixed, the shader gets a new struct:

layout(set = 3, binding = 3) uniform LightCount{
  uint points;
  uint directionals;
  uint spots;
}u_light_count;

which holds the number of lights, the loops then decide which is smaller, the max count or the light count per type.