Using "round" when modifying font.vp

Hello!

Based on some advice given in another thread ( Low resolution pixel art game ), I modified my font.vp file to ensure my fonts were sitting at integer pixels.

My code is as follows, and works fine on my system (Win 7):

uniform mediump mat4 view_proj;

varying mediump vec2 var_texcoord0;
varying lowp vec4 var_face_color;
varying lowp vec4 var_outline_color;

// positions are in world space
attribute mediump vec4 position;
attribute mediump vec2 texcoord0;
attribute lowp vec4 face_color;
attribute lowp vec4 outline_color;
attribute lowp vec4 shadow_color;

void main()
{
    var_texcoord0 = texcoord0;
    var_face_color = face_color;
    var_outline_color = outline_color;
    
    // https://forum.defold.com/t/low-resolution-pixel-art-game/1434/10
    position.x = round(position.x);
    position.y = round(position.y);
    position.z = round(position.z);
    
    gl_Position = view_proj * vec4(position.x, position.y, position.z, 1.0);
}

My project partner is running Mac OS Yosemite, and gets the following error message when building:

WARNING:GRAPHICS: ERROR: 0:21: Invalid call of undeclared identifier 'round’
ERROR: 0:22: Invalid call of undeclared identifier 'round’
ERROR: 0:23: Invalid call of undeclared identifier ‘round’

This prevents the rest of the game from running.

The rounding does make my fonts look better, however I am at a loss as to how to fix this issue since I’m not even really sure what language font.vp is - it’s certainly not Lua! Any help? Thank you very much in advance! :blush:

1 Like

Can you try if floor(...) works? In that case you can use floor(x + 0.5) instead of round(x) in the meantime.

EDIT
By the way, shaders in Defold are written in GLSL (OpenGL Shading Language) which is a C-like language. You can start here if you want to learn more about using shaders in Defold; https://www.defold.com/manuals/shader/

4 Likes