Add a custom uniform

Folks,

I’d like to add a custom uniform to my custom shader (call it radius, type float), with a slider for adjusting the value (much like the LUT slider). As well – in fact, the primary reason – is that I need to be able to adjust this as a parameter through the websdk as I do with “lutAmount”.

Is this possible? I’m perfectly content hacking text/json files to make it happen, if needed!

thanks!
–randy

1 Like

Yes. You would need to select your Fragment shader and edit it in an external tool

and add a new uniform like:

uniform vec4 lutAmount;

You can use this uniform as a parameter to the mix function

vec4 outputColor = mix(inputColor, anotherColor, lutAmount.x);

To display it as a slider select your shader file (parent of Fragment and Vertex) and select Edit
Screenshot 2023-05-12 at 20.11.22

In the shader builder you should be able to find your new uniform, select the slider from the dropdown and set min and max values

If you have issues you can send us the project with your custom shader and we can see how we can help

2 Likes

@jelena
Is it possible design custom ui for the app to control specific stuff in the effect
For example a slider as user can adjust the LUT intensity
Picker options to enable/disable specific objects in the scene
To make the experience more interactive

Thank you! I got this working finally with the right magic of using a vec4 (not a float) and restarting the Studio. Not sure why it didn’t work the first time I tried it that way.

1 Like

@Randy_Chapman I’m glad to hear ther
@Abdelhamid_3wais Yes, but the is a different topic. You can find info on how to hande uniforms form the app here

But you can use info from this thread to find the uniform names

Awesome :blush:
Is that possible with deep ar flutter package for building easier for both ios and android ?!
@jelena

It should be, yes

Future changeParameter(Map<String, dynamic> arguments) {
return _channel.invokeMethod(“changeParameter”, arguments);
}

1 Like