SyntaxBomb - Indie Coders
Languages & Coding => BlitzMax / BlitzMax NG => MiniB3D => Topic started by: Flanker on November 02, 2017, 03:07:44
Hello, i'm trying to fill a GLSL float array from blitzmax, I tried SetFloat but I think I'm missing something.
Here is the array in the shader :
uniform float array[10];
And here is what I tried in blitzmax :
For Local i:Int = 0 To 9
SetFloat(shader,"array["+i+"]",value)
Next
Also, as I'm here, is there a way to unlock the vertices/triangles limits of meshes ? OpenB3D seems to have the same limit as Blitz3D, but with shaders it can be useful to have one big mesh (water for example, or a particle system).
Thank you.
Hi,
I can't remember if it's done different in #version 120 but I came up with a solution for arrays which works in #version 110.
First you need to declare a struct in the frag (I made these names up) then use it in the variable type instead of a float:
struct FloatArray {
float Float;
};
#define MAX_LIGHTS 8
..
uniform FloatArray lightradius[MAX_LIGHTS];
Then in Bmx you have to use .Float to set FloatArray's field:
For Local iradius%=0 To TLight.no_lights[0]-1
SetFloat(shader,"lightradius["+iradius+"].Float",0.2)
Next
It's possible to get past the vertex/triangle limit with shaders, it's fairly advanced stuff so I'm not looking in to it now. I think you use vertex buffer objects and DrawArrays because they're non-indexed.
Thank you it's working like that, and also with a vec2 array. I'm translating a Gerstner waves water shader I wrote a while back for Hardwired in HLSL, now the motion works fine, still need to add the effects.
I'll try to find more infos about the vertex/triangle creation in shaders, this could be very useful.