OpCustomShader

Summary of the code written in the fragment shader inside the operator custom shader in our patch of the day

#ifdef GL_ES
precision highp float;
#endif

IN vec2 texCoord;

// Incoming texture: we tried video and webcam
uniform sampler2D uTexture0;

// Incoming number values
uniform float uTime;
uniform float uNoseX;
uniform float uNoseY;


{{MODULES_HEAD}}

void main()
{
  
   // 1. We read the incoming texture as a vector 4
   vec4 color = texture2D(uTexture0, texCoord); // [ r, g, b, a] 
   
   
   // 2. We use the coordinates given from the operator to place the particles 
   // in the world space
   vec4 positions = vec4(
       (texCoord.x + uNoseX)*20.-10.,           
       (texCoord.y +uNoseY)*20.-10.,          
       color.r*2.,               
       1.);
  
   
   //3. We write 2 textures
   outColor0 = positions; // Has information of the position of the particles
   outColor1= color;      // Will colorize the particles
   
   outColor2 = vec4(0.);
   outColor3 = vec4(0.);
}

Last updated