Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tier2: Is there a way to pass a OpenGl "mat4" to a shader uniform?

Author
Message
Sandwich
6
Years of Service
User Offline
Joined: 23rd Sep 2017
Location:
Posted: 31st Mar 2018 13:27
Hi and a happy easter-weekend to all

I was wondering if there is no way to set a mat4 as shader uniform...
At first I assumed I could achieve this by handling the mat4 as an array[4][4] and pass the values with "SetShaderConstantArrayByName(...)".

In this case I get an error message that a mat4 can't be handled as an array...

So at the current state, I need to do the transform from array[4][4] to mat4 inside the vertex-shader, what is very unsatisfying:



Thanks again and a nice long weekend!
Preben
AGK Studio Developer
19
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 6th Apr 2018 22:25 Edited at: 6th Apr 2018 22:34
Yes we got what we got, but perhaps this will help



Each myUniform is a vec4 so no need for the looping.

Edit: Tier1
SetShaderConstantArrayByName(myshader,"myUniform",0,x1,y1,z1,w1)
SetShaderConstantArrayByName(myshader,"myUniform",1,x2,y2,z2,w2)
SetShaderConstantArrayByName(myshader,"myUniform",2,x3,y3,z3,w3)
SetShaderConstantArrayByName(myshader,"myUniform",3,x4,y4,z4,w4)
Subscribe and checkout great AppGameKit video's here: Videos click here
Latest GameGuru Loader news: News click here
Get GameGuru Loader PBR version here: Steam click here
best regards Preben Eriksen,
Golelorn
7
Years of Service
User Offline
Joined: 20th Nov 2016
Location:
Posted: 7th Apr 2018 01:55 Edited at: 7th Apr 2018 01:55
FYI,

You can not reference an array with a variable in GLES. It has to be an integer, as in Preben's example.
Sandwich
6
Years of Service
User Offline
Joined: 23rd Sep 2017
Location:
Posted: 10th Apr 2018 08:57
Thank you both!

@Golelorn: You're right. I didn't recognize because currently I'm testing on Desktop and there it is possible. I just read that it isn't for pure GLES-Devices.
@Preben: This is the (more) platform independent way, thanks.

Login to post a reply

Server time is: 2024-04-19 17:05:37
Your offset time is: 2024-04-19 17:05:37