Sending an array of vec2 to a pixel effect

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Fractal
Prole
Posts: 3
Joined: Wed Aug 29, 2012 6:01 pm

Sending an array of vec2 to a pixel effect

Post by Fractal »

Hello,

First of all, yesterday was the first day I ever touched to shader programming, so perhaps that what I want is not possible.

I would like to send an array of (say) 25 vec2 from Lua to a pixel effect. Looking at the löve API for send, there does not seem to be such a function, but the OpenGL doc on uniform variables says that uniforms can be of any type, and gives examples of arrays of matrices.

So my question is:
Is it possible to send an array of 25 vec2 from Lua to a shader?

Of course I can fake it and send 25 individual variables, but this is not pretty and has probably some performance issues.

Thank you

Fractal
User avatar
dreadkillz
Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

Re: Sending an array of vec2 to a pixel effect

Post by dreadkillz »

There is a topic with many shader examples: viewtopic.php?f=4&t=3733

If you want to send 25 vectors, you can call send 25 times. Extern in this case is an alias for uniform type.

Code: Select all


effect = love.graphics.newPixelEffect([[
extern vec2 vector1
extern vec2 vector2
extern vec2 vector3
...
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords )
{
...
}
]])

effect:send('vector1',num1,num2)
effect:send('vector2',num1,num2)
...
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 51 guests