I'm taking in the offsets and advance floats that are usually numbers like 48.0 , 52.1 etc
I think i may need to modify to work with "clip space" which seems to be -1.0 to 1.0 (not sure how though)
If you're wondering what it's for im attempting to implement signed distance field fonts. I actually managed to get it working with multiple overlays, one per each character but im trying to do it with a single one now. The repeat rendering sort of works in that it will draw each character in a string, however they all end up in single spot.
The uniforms bottomleftx and bottomlefty are finding where in the texture a character is before it's rendered(this works) though some characters end up being skewed
as the overlay dimensions don't match the character.
@Override
public boolean repeatRendering() {
renderingIndex++;
if(renderingIndex < charactersList.length && renderingIndex > 0)
{
advances = advances + charactersList[renderingIndex].advanceX;
Overlayshader_.setUniform("a_colour",new SimpleVector(1,(renderingIndex*0.1f),0));
Overlayshader_.setUniform("bottomLeftx",charactersList[renderingIndex].bottomLeftx);
Overlayshader_.setUniform("bottomLefty", charactersList[renderingIndex].bottomLefty);
Overlayshader_.setUniform("width",charactersList[renderingIndex].width);
Overlayshader_.setUniform("height",charactersList[renderingIndex].height);
Overlayshader_.setUniform("offestx",renderingIndex);
Overlayshader_.setUniform("offesty",0);
return true;
}
setUpOverlayStart();
renderingIndex=0;
advances=0;
return false;
}
This is an example show three different strings i've added, the bottom one demonstrates a single character string a skewed zero.
And my vertex shader code
precision highp float;
// VERTEX SHADER
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
uniform float bottomLeftx;
uniform float bottomLefty;
uniform float width;
uniform float height;
uniform vec3 a_colour;
uniform float offsetx;
uniform float offsety;
attribute vec2 texture0;
attribute vec4 position;
varying vec4 v_color;
varying vec2 v_texCoord;
void main()
{
v_color = vec4(a_colour.x,a_colour.y,a_colour.z,1.0);
v_texCoord.x = bottomLeftx + (texture0.x/width);
v_texCoord.y = bottomLefty + (texture0.y/height);
vec4 newpos = vec4(offsetx,offsety,0,0);
gl_Position = projectionMatrix*((modelViewMatrix * position) +newpos);
}