[SOLVED] How to send matrix parameter to a shader?

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
User avatar
Sasha264
Citizen
Posts: 71
Joined: Mon Sep 08, 2014 7:57 am

[SOLVED] How to send matrix parameter to a shader?

Post by Sasha264 » Sat Jun 20, 2020 10:51 am

Hello! :emo:
Did not found this in docs...

Code: Select all

local pixelcode = [[
	extern mat2 myMatrix;
	vec4 effect(vec4 color, Image texture, vec2 tc, vec2 sc)
	{
		// some use of the myMatrix here
		return Texel(texture, tc) * color;
	}
]]
local shader = love.graphics.newShader(pixelcode)

shader:send("myMatrix", ?)
Last edited by Sasha264 on Sat Jun 20, 2020 12:15 pm, edited 1 time in total.

User avatar
zorg
Party member
Posts: 2942
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to send matrix parameter to a shader?

Post by zorg » Sat Jun 20, 2020 11:52 am

Docs page: Shader:send
Quote:
Synopsis
Shader:send( name, matrix, ... )
Arguments
string name
Name of the matrix to send to the shader.
table matrix
2x2, 3x3, or 4x4 matrix to send to the uniform variable. Using table form: {{a,b,c,d}, {e,f,g,h}, ... } or (since version 0.10.2) {a,b,c,d, e,f,g,h, ...}. The order in 0.10.2 is column-major; starting in 11.0 it's row-major instead.
table ...
Additional matrices of the same type as matrix to store in a uniform array.
Returns
Nothing.
It's there. (There's also a second version where you can define the matrix layout as well, below the one i quoted)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

User avatar
Sasha264
Citizen
Posts: 71
Joined: Mon Sep 08, 2014 7:57 am

Re: How to send matrix parameter to a shader?

Post by Sasha264 » Sat Jun 20, 2020 12:14 pm

Wow! Somehow I missed that :huh:
Thank you! =)

Post Reply

Who is online

Users browsing this forum: Nikki and 12 guests