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 / SetShaderConstantByName

Author
Message
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 25th Apr 2023 00:52 Edited at: 25th Apr 2023 00:55
I have no idea how to pass on the texture colors or Hight with SetShaderConstantByName.

I need a demonstration as i am confused. I searched with no help at all and nothing showing how to use the funcion.

// if you want to change the following values when the app is running, change
// them to uniforms, remove the default values, and use SetShaderConstantByName
// after loading the shader

Here is the shader I guess somehow i am supposes to know what a uniform is.

I know what a vector is but have no other shadder experience.

Things I want to influence

mediump vec3 grassColor = vec3(0.89, 1.20, 0.77);
mediump vec3 snowColor = vec3(1.5, 1.5, 1.5);
mediump vec3 rockColor = vec3(0.75, 0.75, 0.75);
mediump float snowHeightStart = 25.0; // height that grass begins to turn to snow
mediump float snowHeightEnd = 35.0; // height that it becomes completely snow
mediump float rockStart = 0.8; // normals with Y greater than this will be 100% grass
mediump float rockEnd = 0.4; // normals with Y less than this will be 100% rock

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 25th Apr 2023 01:37 Edited at: 25th Apr 2023 01:40
Variables need to be vec4 to be able to set them: uniform vec4 MyVariable;

Even if they are just a float, make it vec4 and just set the first value (.x) and make the rest zero. Case is important for the variable name.

in AGK:
SetShaderConstantByName(shader, "segmentCount", 3, 0, 0, 0)

in pixel shader;
uniform vec4 segmentCount;

At least that's my experience. Attached is an example of a pie chart which sets ARRAY variables;

Attachments

Login to view attachments
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 25th Apr 2023 02:04
Ok thanks, ill check it out and see what happens.
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 25th Apr 2023 02:16 Edited at: 25th Apr 2023 02:42
Ok i did this and got a error in my pixel shader.

uniform vec3 grassColor;

Nevermind lol, I was putting it in the vs not the ps lol.

But it still does not work.

Im confused.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 25th Apr 2023 08:23
No not uniform vec3 grassColor;
It should be uniform vec4 grassColor;
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 25th Apr 2023 12:14
still did nothing so i don't know
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 25th Apr 2023 20:46
You don't have to set all uniforms to vec4 you can have vec3,2 and float uniforms and still use SetShaderConstantByName()
But you uploaded a vertex shader but talk about a pixel shader above and do you still have default values like "= vec3(0.89, 1.20, 0.77);" in your shader ?
And what is the error you are getting ?
Game_Code_here
3
Years of Service
User Offline
Joined: 2nd Jun 2020
Location:
Posted: 25th Apr 2023 21:04 Edited at: 25th Apr 2023 21:05
Hay I bought you shader pack and Posted what my error is there. But if i could get your shader pack working this post does not matter.

https://forum.thegamecreators.com/thread/229052

Login to post a reply

Server time is: 2024-04-20 06:54:09
Your offset time is: 2024-04-20 06:54:09