Using shaders to compute lighting?

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.
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

Re: Using shaders to compute lighting?

Post by Whatthefuck » Mon Jun 23, 2014 3:51 pm

Ranguna259 wrote:I dont' think that GLSL accepts tables that have more than 4 indexes (vec4)
I see, thank you.
Well, regardless, the lighting compute is fast as it is, so this shouldn't be a problem anyway.

Thanks for the answers, everyone.

User avatar
Ref
Party member
Posts: 690
Joined: Wed May 02, 2012 11:05 pm

Re: Using shaders to compute lighting?

Post by Ref » Mon Jun 23, 2014 4:15 pm

Probably way off base but is this anywhere close to what you want?
Attachments
lighting_test.love
Simple lighting shader
(48.39 KiB) Downloaded 77 times

User avatar
slime
Solid Snayke
Posts: 2904
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Using shaders to compute lighting?

Post by slime » Mon Jun 23, 2014 6:12 pm

Ranguna259 wrote:I dont' think that GLSL accepts tables that have more than 4 indexes (vec4)
You can have arrays (even arrays of vec4's) via shader:send("arrayname", element1, element2, ...) where element1 can be a table if it's a vector in GLSL, or a number if it's just a float in GLSL.

There is a driver/GPU-specific limit to the number of extern/uniform values per shader though.

Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

Re: Using shaders to compute lighting?

Post by Whatthefuck » Tue Jun 24, 2014 7:04 am

Ref wrote:Probably way off base but is this anywhere close to what you want?
No, what I want to do is compute static world lighting, but since it isn't exactly possible because I'd have to send a table containing 256 indexes, I'll just stick to what I have coded so far. :)

The shader you showed could be useful for torches and other dynamic light sources though.

Post Reply

Who is online

Users browsing this forum: No registered users and 29 guests