[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
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

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

Post by Sasha264 »

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: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: How to send matrix parameter to a shader?

Post by zorg »

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
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: How to send matrix parameter to a shader?

Post by Sasha264 »

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

Who is online

Users browsing this forum: Google [Bot] and 121 guests