Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference in handling textures in glslCanvas and glslViewer #61

Open
edap opened this issue Dec 4, 2019 · 3 comments
Open

Difference in handling textures in glslCanvas and glslViewer #61

edap opened this issue Dec 4, 2019 · 3 comments

Comments

@edap
Copy link

edap commented Dec 4, 2019

I have the same exact code that gives me two different results on glslCanvas and glslViewer.

vec2 origSt = (2.0 * gl_FragCoord.xy - u_resolution.xy)/ u_resolution.y;
vec4 texZoom = vec4(texture2D(u_tex0, origSt + vec2(0.5)));
gl_FragColor = texZoom;

This is the result using glslViewer:
Screen Shot 2019-12-04 at 15 03 51

And this is the result on glslCanvas:
Screen Shot 2019-12-04 at 15 05 18

Can it be that gl.REPEAT is different between the two?

@edap
Copy link
Author

edap commented Dec 4, 2019

So, basically glslViewer is loading the texture using GL_REPEAT, see https://github.com/patriciogonzalezvivo/glslViewer/blob/16b17f524680f0f50702fc9bb1e61a981386cbbf/src/gl/texture.cpp#L37

While in glslCanvas gl.REPEAT is set just if it is passes through options.

gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, options.TEXTURE_WRAP_S || options.repeat && gl.REPEAT || gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, options.TEXTURE_WRAP_T || options.repeat && gl.REPEAT || gl.CLAMP_TO_EDGE);

via https://rawgit.com/patriciogonzalezvivo/glslCanvas/master/dist/GlslCanvas.js

Is there some documentation about how to pass that option? I am hardcoding it at the moment and it works.

@patriciogonzalezvivo
Copy link
Owner

Hi! so a quick hack for this is to force the repeat using fract()
So could look like this:

vec4 texZoom = vec4(texture2D(u_tex0, fract(origSt + vec2(0.5))));

@edap
Copy link
Author

edap commented Dec 4, 2019

I have simply hardcoded:
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
As this is the behaviour in glslViewer.

I wanted to port a sketch done in glslViewer on glslCanvas.Last time that I did it it went smoothly, this time I have some issues, but I am figuring them out.
Many thanks for your tools ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants