You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After using square-sized sprites and everything worked great, the moment I have tried a rectangular sprite with the size of 20x200, I have realized that it forces the output to 20x20, it only considers the width of the sprite and forces the height to be the same as the width
precision mediump float;
uniform sampler2D u_texture0;
uniform sampler2D u_texture1;
uniform sampler2D u_texture2;
uniform sampler2D u_texture3;
varying vec2 v_texCoord;
varying vec4 v_textureWeights;
void main() {
vec4 color;
if (v_textureWeights.x > 0.0)
color = texture2D(u_texture0, v_texCoord);
else if (v_textureWeights.y > 0.0)
color = texture2D(u_texture1, v_texCoord);
else if (v_textureWeights.z > 0.0)
color = texture2D(u_texture2, v_texCoord);
else // v_textureWeights.w > 0.0
color = texture2D(u_texture3, v_texCoord);
gl_FragColor = color;
}
My GLSL knowledge isn't very strong yet and I'd appreciate any help to make it render with the original width & height.
Right now I see that the Vertex Shader accepts only spriteSize (which is only the width of the sprite) as a parameter when calculating position & sizes.
The text was updated successfully, but these errors were encountered:
After using square-sized sprites and everything worked great, the moment I have tried a rectangular sprite with the size of 20x200, I have realized that it forces the output to 20x20, it only considers the width of the sprite and forces the height to be the same as the width
jsFiddle here
If you will inspect the canvas, you will see that it has the proper sizes: 20x200
I have used your shaders to render:
Vertex Shader:
Fragment Shader:
My GLSL knowledge isn't very strong yet and I'd appreciate any help to make it render with the original width & height.
Right now I see that the Vertex Shader accepts only spriteSize (which is only the width of the sprite) as a parameter when calculating position & sizes.
The text was updated successfully, but these errors were encountered: