Author Topic: 3D Text in OpenGL  (Read 7111 times)

0 Members and 1 Guest are viewing this topic.

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
3D Text in OpenGL
« on: June 24, 2011 »
I'm looking into a nice way to handle text in an an OpenGL intro/demo. I was wondering how the 3D text in something like the video below is done. Do you think this is a bitmap font that is converted into 3D objects or just some fancy 'render to texture' effect to make it look 3D?:

[youtube]http://www.youtube.com/watch?v=0bZbQH_1sj8[/youtube]

I'm referring mainly to the sine wave text that appears that looks something like a flag effect.

My plan for handling text is just to have a standard bitmap font (like the old Amiga ones) and a lookup list with the character sizes and positions. Is this still a sensible way to do things in this day and age? :)

Thanks for looking,

Raizor
raizor

Challenge Trophies Won:

Offline Hotshot

  • DBF Aficionado
  • ******
  • Posts: 2114
  • Karma: 91
    • View Profile
Re: 3D Text in OpenGL
« Reply #1 on: June 24, 2011 »
I did love to help but I don't know much about Open Gl :(

Quote
sine wave text that appears that looks something like a flag effect.

Yes, it is Flag Effect  :)

That 3D Text(that spin round in 3D) is somethings I would like to do in BlitzMax of Open Gl but it isnt easy to do.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2751
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: 3D Text in OpenGL
« Reply #2 on: June 25, 2011 »
Each letter is made using a textured quad, to see it, run the intro and press F3 and it will switch to debug mode.

« Last Edit: June 25, 2011 by rbz »
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: 3D Text in OpenGL
« Reply #3 on: June 25, 2011 »
Each letter is made using a textured quad, to see it, run the intro and press F3 and it will switch to debug mode.

Perfect rbz, thanks :)
raizor

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: 3D Text in OpenGL
« Reply #4 on: September 22, 2011 »
I've been looking at this some more and trying to figure out how the blending for the char depth is done. Each textured quad is rendered seversl times behind the main quad to give the char depth. What I can't figure out is how the layed rear quads are drawn.

I've been playing around myself trying to mimic the effect but can't get the layered quads not to over saturate. It looks to me like it's using additive blending, but when I try this (using various GL_ONE blending modes) the layers get brighter and brighter as they're overlayed. I've also tried using depth test and sorting but still can't get my head around how it's done. How is the colour intesity limited?

If anyone can shed any light on this, I'd be most grateful.
raizor

Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: 3D Text in OpenGL
« Reply #5 on: September 22, 2011 »
Meaby try "screen" blending if it's available?
It gives a similarish effect to additive blending but less pronounced, not sure what it does exactly...
Using transparancy and/or darker colors can help to prevent additive blending becomming to bright to quickly as well.

I think you can get a long way using only transparancy though, it looks like only the front/top slice is drawn at full opacity.

I hope this makes sense for OpenGl as I'm not familair with it.  :-\
« Last Edit: September 22, 2011 by Kirl »
www.kirl.nl
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: 3D Text in OpenGL
« Reply #6 on: September 22, 2011 »
Thanks Kirl.

I think the solution is something specifc to OpenGL, some kind of setting or mode that I'm not aware of or maybe some technique I haven't thought of.
raizor

Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1292
  • Karma: 466
    • View Profile
    • my stuff
Re: 3D Text in OpenGL
« Reply #7 on: September 22, 2011 »
The font is most probably a 1bit bitmap stored in a rgba texture, so all pixels are either (FF,FF,FF,FF) or (0,0,0,0).
This way you can control the color and the level of opacity separately (eg using glColor4f).
The blend mode is set to (GL_ONE, GL_ONE_MINUS_SRC_ALPHA).
The front layer seems to be drawn with almost full opacity (alpha=1) and the rear ones with lower alpha (0.5 or less) and darker color.
This way you're always attenuating the background and the colors never saturate.
If you set alpha to 0 you're back at additive blending (used to make the characters flash).
Keep in mind that you'll have to draw the layers back to front to make the blending work.

Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: 3D Text in OpenGL
« Reply #8 on: September 22, 2011 »
Hellfire, you're a star! Thank you :)

I already have my blend function set to GL_ONE / GL_ONE_MINUS_SRC_ALPHA but was specifying RGB values in the glColor4f call that were too high. If I take them down to around 0.05f, it works great. 

K++
raizor

Challenge Trophies Won: