glsl - OpenGL Shaders - Structuring blocks of data of similar types -
i'm having bit of structural problem shader of mine. want able handle multiple lights of potentionally different types, i'm unsure best way of implementing be. far i've been using uniform blocks:
layout (std140) uniform lightsourceblock { int type; vec3 position; vec4 color; // spotlights / point lights float dist; // spotlights vec3 direction; float cutoffouter; float cutoffinner; float attenuation; } lightsources[12];
it works, there several problems this:
a light can 1 of 3 types (spotlight, point light, directional light), require different attributes (which aren't neccessarily required types)
every light needs sampler2dshadow (samplercubeshadow point lights), can't used in uniform blocks.
the way i'm doing works, surely there must better way of handling this? how done?
Comments
Post a Comment