Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Send a Struct Array to a Shader  (Read 7604 times)

0 Members and 1 Guest are viewing this topic.

MOP

  • Newbie
  • *
  • Posts: 19
  • Expect the progress
    • View Profile
Send a Struct Array to a Shader
« on: October 23, 2017, 12:46:18 pm »
Hi folks,

actually iam faced with a little problem. Iam actually using a pixel shader for diffuse/normal/specular mapping with different lights(point and cone lighting). I wanna reorganize my shader Input to a single Struct.
But iam not to find a function to set a uniform struct directly to a shader.

Iam actually making a snake game, with different "levels"(levels splitted to a texture, a textform tilemap, a eventmap(e.g. for boss "fights")). The Map-Texture included all Tiles, excluded dynamiclly tiles(like bosses, foods, powerups etc.), to reduce Texture handles and resources. Okay thats was a bit OT.

Also i wanna place and remove dynamiclly lights to the maps.
Actually my solution is very creepy :x

I got a struct-like organisation(C):
Code: [Select]
// Game Lichter
sfGlslVec3 *GameLight_Lightpos;
sfGlslVec3 *GameLight_Conepos;
float *GameLight_Coneactive;
float *GameLight_FBMactive;
float *GameLight_Ambientactive;
float *GameLight_Coneangle;
bool *GameLight_type;
size_t light_count;

And when i add or remove lights, i use the mm functions from std, like malloc/realloc etc.
My Shader contains this(did in german language):
Code: [Select]
uniform vec3 Licht_Position[MAX_LIGHTS];
uniform vec3 Kegel_Position[MAX_LIGHTS];
uniform float Licht_Kegel_Aktiv[MAX_LIGHTS];
uniform float FBM_Kegel_Aktiv[MAX_LIGHTS];
uniform float Ambient_Aktiv[MAX_LIGHTS];
uniform float Licht_Kegel_Winkel[MAX_LIGHTS];
uniform int Anzahl_Lichter;

As you see, i setted up the bool-like variables to a float, cause, i dont find a function like:
setBoolUniformArray.

Now i wanna reorganize my Shader Input to a single Structure, also in my C Code.


Is there any possibility with the SFML Framework to do this?

Thanks in advance!

Greetz MOP
My Github Repo:
Snake
Deep Deep Deep in Development

 

anything