Jump to content
  • Advertisement

Vincent_M

Member
  • Content Count

    557
  • Joined

  • Last visited

Community Reputation

969 Good

About Vincent_M

  • Rank
    Advanced Member

Personal Information

  • Interests
    Art
    Audio
    Business
    Design
    Production
    Programming
  1. I forgot to post that. I'm doing basic mipmapping. Here's the member definition that creates the OpenGL texture object, and uploads the data to its memory space: uint32_t Font::CreateTexture(size_t width, size_t height, const void* buffer) { uint32_t handle; glGenTextures(1, &handle); glBindTexture(GL_TEXTURE_2D, handle); glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, (GLsizei)width, (GLsizei)height, 0, GL_RED, GL_UNSIGNED_BYTE, buffer); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); return handle; } Here's how I call it: texture_ = CreateTexture(atlasWidth_, atlasHeight_, (void*)((uint8_t*)buffer + offset)); Here's my text shader source as well: static const std::string TextVertSource = "uniform mat4 u_transMat;" "attribute vec2 a_pos;" "attribute vec2 a_coord;" "varying vec2 v_coord;" "void main()" "{" " v_coord = a_coord;" " gl_Position = u_transMat * vec4(a_pos, 0.0, 1.0);" "}" ; static const std::string TextFragSource = "uniform vec4 u_params;" // fillWidth, fillEdge, strokeWidth, strokeEdge "uniform vec4 u_colors[2];" // fillColor, strokeColor "uniform sampler2D u_tex;" "varying vec2 v_coord;" "void main()" "{" " float distance = 1.0 - texture2D(u_tex, v_coord).r;" " float fillAlpha = 1.0 - smoothstep(u_params.x, u_params.x + u_params.y, distance);" " float strokeAlpha = 1.0 - smoothstep(u_params.z, u_params.z + u_params.w, distance);" " float a = fillAlpha + (1.0 - fillAlpha) * strokeAlpha;" " vec4 color = mix(u_colors[1], u_colors[0], fillAlpha / a);" " gl_FragColor = color;" " gl_FragColor.a = a;" "}" ;
  2. My SDF font looks great at large sizes, but not when I draw it at smaller sizes. I have my orthogonal projection matrix setup so that each unit is a 1x1 pixel. The text is rendered from Freetype2 to a texture atlas @ 56px with a spread of 8 pixels (the multiplier is 8x and scaled down). I'm drawing @ 18px in the screenshot attached to this post. The way I calculate the size of the text quads is by dividing the desired size (18px in the screenshot) by the size of the glyphs in the atlas (56px in this case), and scaling the glyph sprite by that factor. So: 18/56 = ~0.32, and I multiply the rect's size vector by that when it comes to vertex placement (this obviously doesn't apply to the vertices' texture coords). Now, I made sure that all metrics stored in my SDF font files are whole numbers (rect position/size, bearing amounts, advance, etc), but when I scale the font, vertex positions are almost always not going to be whole numbers. I increase the "edge" smoothstep shader parameter for smaller text as well, but it doesn't seem to help all that much.
  3. Vincent_M

    Why NASA Switched from Unity to Blend4Web

    True, some WebGL games are simply too ambitious for mobile, but there are some impressive WebGL demos such as this one on my iPhone 6 Plus at an intractable framerate. As far as large amounts of memory consumption: probably a byproduct of much of everything being in JavaScript --even if running as an IL/emscripten approach. WebGL's currently-supported implementation is the JavaScript equivalent to the OpenGL ES 2.0 API in C, which Unity's supported for some time now. They'd mostly have to use some sort of IL approach, such as JS.asm/emscripten to convert the code-base over to something browsers, even Node.js could run. It sounds like their own IL2CPP is their solution to that. If anything, just switch your platform and renderer to OpenGL ES 2.0, and you've got yourself a natively-written app. Now, your only hurdle is Apple's App Store review process. Sure, there are plenty of hurdles that Unity's got to jump, but their publicly-released efforts regarding WebGL look pretty solid so far.
  4. Vincent_M

    One year report (trailer inside).

    WOOOOAH!   This is how I'd describe everything here in one word. I think it's a cool idea, and would like playing that game. From what I've seen in the trailer, I could see an in-game scenario editor could really benefit it.
  5. Vincent_M

    Math for Game Developers: Intro to Vectors

    Awesome tutorial! You draw really straight lines too haha
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!