blitz-foundation / monkey2

zlib License
3 stars 0 forks source link

Any way to set GLSL uniform arrays? #128

Open Pharmhaus-2 opened 5 years ago

Pharmhaus-2 commented 5 years ago

Original Author: DruggedBunny

Hi Mark,

I'm attempting to shove a bunch of palette values from Monkey2 side into a uniform array, but as far as I can tell, that's not currently possible as we don't have the relevant SetXXXArray option. (Did consider abusing SetMat4fArray, but... )

Naive attempt with floats! Would be looking to fill in vec3s or maybe just floats (hsl hue values) in my case...

    ' OK, this wasn't gonna happen!

    TargetImage.Material.SetFloat   ("m_Test[0]", 0.0)
    TargetImage.Material.SetFloat   ("m_Test[1]", 1.0)

    ' GLSL side:

    uniform float m_Test [2];

    if (m_Test[1] > 0.0)

    ' Nope!

I'm avoiding sending the palette texture as I would need to do up to 8, 16... maybe even 256 texture lookups per-pixel for closest-colour selection, depending on fake retro-palette, and one thing I've learned is that this is slow, whereas a quick iteration through float or vec3 arrays ought to be fine.

Pharmhaus-2 commented 5 years ago

See https://github.com/blitz-research/monkey2/issues/468