I want to be able (in the fragment shader) to add one texture to another. Right now I have projective texturing and you want to expand it.
Here is what I still have: 
Im also draws a viewfrustum along which a blue / gray test image is projected onto a geometry that is in constant rotation.
My vertex shader:
ProjTexCoord = ProjectorMatrix * ModelTransform * raw_pos;
My shader fragment:
vec4 diffuse = texture(texture1, vs_st); vec4 projTexColor = textureProj(texture2, ProjTexCoord); vec4 shaded = diffuse; // max(intensity * diffuse, ambient); -- no shadows for now if (ProjTexCoord[0] > 0.0 || ProjTexCoord[1] > 0.0 || ProjTexCoord[0] < ProjTexCoord[2] || ProjTexCoord[1] < ProjTexCoord[2]){ diffuse = shaded; }else if(dot(n, projector_aim) < 0 ){ diffuse = projTexColor; }else{ diffuse = shaded; }
What I want to achieve:
When, for example, the user presses a button, I want the blue / gray texture to be written on the gray texture on the sphere and rotate with it. Imagine this as an βimageβ or painting on top of a sphere, so that the blue / gray texture rotates around the sphere after pressing a button.
Since the fragment shader works on every pixel, it should be possible to copy pixel pixels from one texture to another, but I donβt know how maybe I would look for the wrong material.
How can I achieve this technically? Which method is the most universal? Suggestions are greatly appreciated, please let me know if more code is required.
source share