Maybe for @cuinjune ...?
As part of my continuing quest to figure out how to work with pixel data in Ofelia, I was looking into shaders this weekend. (I don't understand why this has to be a quest, but... there we are.)
I've tried multiple permutations cobbled together from various examples, but I can't successfully get the texture coordinates into the shader.
I'm perplexed. I tried copying a simple texture example from https://riptutorial.com/opengl/example/32426/using-textures-in-glsl-shaders:
in vec2 texCoordOut;
out vec4 color;
uniform sampler2D image;
void main()
{
color = texture(image, texCoordOut);
}
But this crashes Ofelia upon shader:load(...)
. (Don't even have to beginShader()
-- just dies on init.)
OK, so then I copied a fragment shader out of Ofelia's own examples:
uniform sampler2DRect tex0;
varying vec2 texCoordVarying;
void main()
{
gl_FragColor = texture2DRect(tex0, texCoordVarying);
}
... and... "ofShader: ofShader: program reports: error: fragment shader input `texCoordVarying' has no matching output in the previous stage."
Or
uniform sampler2DRect tex0;
// varying vec2 texCoordVarying;
in vec2 coord;
void main()
{
gl_FragColor = texture2DRect(tex0, coord);
}
No crash, but "error: 'in' qualifier in declaration of 'coord' only valid for function parameters in GLSL 1.10"
Sooooooo... sorry for being an idiot about this. I need pixel manipulations for a course. AFAICS shaders should be able to do this, and based on online reading, it doesn't make sense to me that it's this blastedly difficult.
hjh