Android opengl fragment shader color change question

Asked 2 years ago, Updated 2 years ago, 82 views

        "   precision mediump float;                            \n"
        "   "   void main(){                                        \n"
        "       "       gl_FragColor = vec4(1.0, 1.0, 0, 1.0);          \n"
        "   "   }                                                   \n";

In the current Android studio environment, I approached the fragment shader by putting a color value directly, but is there a way to change the color through an external variable?

android opengl

2022-09-22 19:49

1 Answers

Take Color vec4 out of Uniform and deliver it to the program.

uniform vec4 color;     
void main() {                                  
    gl_FragColor = color;
}         


2022-09-22 19:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.