-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Fluttere: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requeststeam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team
Description
Description of problem
When using the FragmentShader API today one has to carefully count uniform offsets by hand in order to set uniforms. There should be a way to instead to set uniforms by name to make changing uniforms easier and for easier debugging.
Example
shader
uniform float uScale;
uniform sampler2D uTexture;
uniform vec2 uMagnitude;
uniform vec4 uColor;today
Generate dart code for shaders that has the uniform indices as constants.
shader.setFloat(0, 23); // uScale
shader.setFloat(1, 114); // uMagnitude x
shader.setFloat(2, 83); // uMagnitude y
shader.setFloat(3, color.red / 255 * color.opacity); // uColor r
shader.setFloat(4, color.green / 255 * color.opacity); // uColor g
shader.setFloat(5, color.blue / 255 * color.opacity); // uColor b
shader.setFloat(6, color.opacity); // uColor a
shader.setImageSampler(0, image);proposal
shader.setFloat(SHADER_USCALE, 23);
shader.setFloat(SHADER_UMAGNITUDE_X, 114);
shader.setFloat(SHADER_UMAGNITUDE_Y, 83);
shader.setFloat(SHADER_UCOLOR_RED, color.red / 255 * color.opacity);
shader.setFloat(SHADER_UCOLOR_GREEN, color.green / 255 * color.opacity);
shader.setFloat(SHADER_UCOLOR_BLUE, color.blue / 255 * color.opacity);
shader.setFloat(SHADER_UCOLOR_ALPHA, color.opacity);
shader.setImageSampler(SHADER_UTEXTURE, image);Alternatives considered
runtime access
shader.setFloat('uScale', 23);
shader.setFloat('uMagnitude', 114, 0);
shader.setFloat('uMagnitude', 83, 1);Having compile time checks for the validity of uniform names is a better user experience and better performance.
ksokolovskyi
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Fluttere: impellerImpeller rendering backend issues and features requestsImpeller rendering backend issues and features requeststeam-engineOwned by Engine teamOwned by Engine teamtriaged-engineTriaged by Engine teamTriaged by Engine team