Any idea on how to change texture wrapping mode inside ofShader? I am struggling to find any info online… I have had a look at a bunch of different threads on the forum but nothing has worked so far. I have read that the wrapping mode has to be set outside of the actual glsl files, but that’s all I’ve been able to find out.
(ive tried, to no avail:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); )
any suggestions appreciated!
I might be wrong about this but I believe if you are using shaders you have to do the math for these things yourself.
Assuming st is your texture coordinate in the frag shader and tex_w is your texture width ( either in pixels for
ofEnableArbTex() or 0-1 if
ofDisableArbTex() ) then:
GL_REPEAT would be:
st.x = mod(st.x, tex_w);
st.y = mod(st.y, tex_h);
Clamp to Edge would be:
st.x = clamp(st.x, 0, tex_w);
st.y = clamp(st.y, 0, tex_h);
Hi Theo, thanks so much for your reply - that worked beautifully. Gotta love GLSL!
I think you need to set it on the texture you are processing in the shader with
setTextureWrap() - ofTexture | openFrameworks
if you are using a subclass off
ofBaseHasTexture (ofFbo, ofImage) there is a
.getTexture() that exposes this.