hi, ive created quite a few library functions for creating linked lists with models loaded by assimp and i understand the basic lighting models. i want to, for convenience, be able to create one shader for each light and pass all the models through these seperate shaders. it would make my life alot easier, i believe. if their is a way to do this, or if their is a better way to acheive the same result please let me know. thanks
Basically you want to reuse shader code. Make 1-2-n shaders for diff lights and then use them in other model shaders ? If yes , then just create simple “include” directive algorithm when loading the shader, for example how i do it.
string LoadShaderSource(filename)
string shadersource;
OpenFile(filename)
while(getline(file,line)
{
if(line.startswith(#include)
extract filename from the line
LoadShaderSource(filename)
else
shadersource.append(line)
}
return shadersource;
then in the shader you can use something like
#version 330 core
#include “Light.vsh”
// The rest of the shader
// That will be doing the model stuff
… use Light functions here …
k, im having a little trouble understanding what you are saying, but i believe im looking for a more dynamic solution. i would like to be able to add a lightsource at any time and also delete one at anytime. id like to create a file that gives the intenstiy, falloff, etc. and then a type of light. i would then run a copy of the necessary light type (which would be a shader program), with the proper variables once for every seperate light in the scene. thanks