FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Tools
(Moderator: REAS)
   text as texture...
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: text as texture...  (Read 7835 times)
arielm

WWW
text as texture...
« on: May 30th, 2003, 1:13pm »

i'm checking an alternative direction of handling text within processing, viewable at:
http://www.chronotext.org/bits/027
 
the trick is to use a texture-mapped quad-strip. it's just a beginning, but it seems promising, in term of execution speed and programming flexibility...
 
Code:

// TEXTURE 1
// by arielm - May 30, 2003
// http://www.chronotext.org
 
float fovy, aspect;
float elevation, azimuth, distance;
 
BImage img;
 
void setup()
{
  size(300, 300);
  framerate(20.0);
  background(0);
  //hint(SMOOTH_IMAGES);  // !!! crashes under 0054 !!!
 
  fovy = 60.0;
  aspect = (float) width / (float) height;
 
  distance = 200.0;
  elevation = radians(285.0);
  azimuth = radians(235.0);
 
  img = loadImage("img.gif");
  formatImage(img);
}
 
void formatImage(BImage bi)
{
  bi.format = ALPHA;
  for (int i = 0; i < bi.width * bi.height; i++)
  {
    bi.pixels[i] = bi.pixels[i] & 0xff;
  }
}
 
void loop()
{
  beginCamera();
  perspective(fovy, aspect, 1.0, 1000.0);
  translate(0.0, 0.0, -distance);
  rotateX(-elevation);
  rotateZ(-azimuth);
  endCamera();
 
  noStroke();
 
  fill(224, 224 ,255);
  drawBadShape(img, 0.0, 0.0, -40.0, 90.0, 16.0, radians(12.0));
 
  fill(255);
  drawBadShape(img, 0.0, 0.0, -20.0, 120.0, 16.0, radians(12.0));
 
  azimuth += radians(1.0);
}
 
void drawBadShape(BImage bi, float x, float y, float z, float r, float h, float dd)
{
  boolean b = false;
  float xx, yy, uu;
 
  beginShape(QUAD_STRIP);
  textureImage(bi);
  for (float d = 0.0; d < TWO_PI * 2.0; d += dd)
  {
    b = !b;
    xx = x + cos(d) * r;
    yy = y - sin(d) * r;
    uu = d * r * bi.height / h;
    vertexTexture(uu, b ? (float) bi.height : 0.0); vertex(xx, yy, b ? z : z + h);  
    vertexTexture(uu, b ? 0.0 : (float) bi.height); vertex(xx, yy, b ? z + h : z);  
 
    z += 1.0;
  }
  endShape();
}

 
for now, the text is not dynamic, i'm using an image (6000 x 64):
http://www.chronotext.org/bits/027/img.gif
 
but i'm planning to use a buffer which will use the vlw fonts...
 
i will also try to implement a basic depth effect using transparency (seems technically feasible with "vertex coloring).
 
i still have one technical problem: how can i color each quad within the quad-strip (the goal is to achieve arbitrarly colored text)
 
i've set up a topic related to this issue in the "syntax" board:
http://proce55ing.net/discourse/yabb/board_Syntax_action_displa_y_num_1054204503.html
« Last Edit: Jun 2nd, 2003, 3:27pm by arielm »  

Ariel Malka | www.chronotext.org
arielm

WWW
Re: text as texture...
« Reply #1 on: May 30th, 2003, 3:37pm »

okay, i think the problem of text-coloring is solved:
http://www.chronotext.org/processing/texture_1_rv_1
 
using now 2 images:
http://www.chronotext.org/processing/texture_1_rv_1/mask.gif
 
and
http://www.chronotext.org/processing/texture_1_rv_1/img.gif
 
 
next step: trying to implement depth...
 

Ariel Malka | www.chronotext.org
benelek

35160983516098 WWW Email
Re: text as texture...
« Reply #2 on: Jun 1st, 2003, 1:49pm »

it looked too good to not play with! have a look:
 
http://users.bigpond.net.au/schwartz/texture_text01/applet/
 
and...
 
http://users.bigpond.net.au/schwartz/texture_text02/applet/
 
there seem to be some problems with the text running out of space, and being cut off the shape in the first one. as of yet, i haven't figured out the maths needed to keep the shape the same size as the texture, but here's for playfulness... number 2 runs into all sorts of design possibilities.
 
arielm

WWW
Re: text as texture...
« Reply #3 on: Jun 1st, 2003, 2:55pm »

hey benelek,
 
the pond effect in the 1st applet is suggesting a.. pond effect!
 
for the 2nd applet, i don't know which effect you wanted to achieve but it hurts (like scratching a board with a chalk
 
i think that if you want to keep the proportions of the text, while doing some effects, you should (instead of playing with the uv texture coordinates) work directly on img.pixels[]...
 
added later:
because the text has to work with a mask, it may add a level of complexity (requiring a blend() function at some point)...
 
maybe it would be simplier to start with an opaque image, i.e. no need to use formatImage()...
« Last Edit: Jun 1st, 2003, 3:01pm by arielm »  

Ariel Malka | www.chronotext.org
arielm

WWW
Re: text as texture...
« Reply #4 on: Jun 2nd, 2003, 4:11pm »

i temporarely gave up investigating vertex-coloring on textures (and lights too, eventhough it's really interesting)...
 
anyway, to complete this first round, i upgraded the previous code to this version:
http://www.chronotext.org/bits/028
 
source at:
http://www.chronotext.org/bits/028/texture_1_rv_3.pde
 
instead of using a bitmap for text, the original (vlw) fonts are used...
 
i wanted to see how it looks with hint(SMOOTH_IMAGES) but this bug is not enabling it:
http://proce55ing.net/discourse/yabb/board_Proce55ing_software__bugs_action_display_num_1054456405.html
 
so to recap: it's possible to map (dynamic) text on volumes (like quad-strips), and it seems to run pretty fast...
 
caution: this bit of code is using undocumented features of p5... it works under 0054 but it could just stop working sometimes...
 

Ariel Malka | www.chronotext.org
benelek

35160983516098 WWW Email
Re: text as texture...
« Reply #5 on: Jun 2nd, 2003, 4:36pm »

this latest one seems to have caused IE to freeze, while the applet itself kept running (at strangely varying speeds).
 
however, before i decided to jump to the task manager for help, i noticed that the tripple spiral works interestingly in terms of information display. the inner one displays a word or two, the middle one shows the next few words, and the outer one shows a whole phrase ahead. it's interesting how different speeds/sizes/colours can affect this.
 
arielm

WWW
Re: text as texture...
« Reply #6 on: Jun 2nd, 2003, 4:50pm »

ouch... this one hurts...
 
what is your config: os, ram, java & IE version etc?
 
could you make another try (just after a clean boot) to see if it happens again? 10-x
 
 
yeah, the 3d parallax effect on text is interesting... i think it could be used in a meaningful fashion sometime...
 
(actually, the 3 sentences have the same font sizes, the only params that are changing are the radius and the z-position of the helices)
 

Ariel Malka | www.chronotext.org
benelek

35160983516098 WWW Email
Re: text as texture...
« Reply #7 on: Jun 2nd, 2003, 5:00pm »

os, ram, java & IE version:
Win2k, 256MB RD, JRE 1.4.1_02, IE 6.0
 
for a clean boot, you'll have to wait another day (thanks to win2k's wonderful ability to recover from explorer problems), but I'll try one more time... i'll reply straight afterwards.
 
benelek

35160983516098 WWW Email
Re: text as texture...
« Reply #8 on: Jun 2nd, 2003, 5:05pm »

it worked better this time... though there was still a short period when i thought it had frozen again. after i went to the taskmanager, it worked fine.
 
i'm not sure what part of the applet is doing it, but by now my eyes have gone blurry from the exhaustion. i'll make some attempts to straighten things out tomorow.
 
btw, which os, ram, java & IE versions are you running Arielm?
 
arielm

WWW
Re: text as texture...
« Reply #9 on: Jun 2nd, 2003, 6:33pm »

happy to hear that it's not freezing all the time!
 
i think massive real-time texture mapping is pushing p5 / java to their limit...
 
well, if you ask, i have 3 systems (as a web designer, i need these 3 versions of ie!!!):
- PIII/450MHZ 192M with WIN2K + IE5.5 + JDK 1.4.1_02
- same machine as above with WIN98SE + IE5 + OLD MICROSOFT VM
- Compaq laptop: AMD 900MHZ 256M with XP + IE6 + JDK 1.4.1_02
 
the last applet works relatively smooth on all of these systems (although the framerate seems not to be constant)...
 
thanks for the support!
« Last Edit: Jun 2nd, 2003, 6:35pm by arielm »  

Ariel Malka | www.chronotext.org
arielm

WWW
Re: text as texture...
« Reply #10 on: Jun 3rd, 2003, 12:22am »

second thought on what i suggested a few hours ago:
 
on Jun 1st, 2003, 2:55pm, arielm wrote:
i think that if you want to keep the proportions of the text, while doing some effects, you should (instead of playing with the uv texture coordinates) work directly on img.pixels[]...

well, playing with img.pixels[] is one direction but it should also be possible do something like a pond effect with correct proportions playing both with vertices and textureVertices (i.e: uv coordinates) as benelek started to experiment...
 
definitely (just) a matter of maths...
 

Ariel Malka | www.chronotext.org
arielm

WWW
Re: text as texture...
« Reply #11 on: Jun 5th, 2003, 2:22pm »

another example using the "text as texture" method can be found at:
http://proce55ing.net/discourse/yabb/board_Contribution_Info_ac_tion_display_num_1054759465.html
 
this time i tried to push the limits by using an image of 14091 x 50 pixels:
http://www.chronotext.org/bits/029/genesis%2011,1.gif
 
well, it works... nothing imploded...
 
 
and finally, i found a solution to my vertex coloring issue so i implemented this altenative version:
http://www.chronotext.org/processing/babel_1_rv_1
 
where vertex coloring is used to produce a cheap depth effect (would have been more difficult in term of programming and moree expensive in term of processing power to achieve such an effect with lights)
 

Ariel Malka | www.chronotext.org
benelek

35160983516098 WWW Email
Re: text as texture...
« Reply #12 on: Jun 6th, 2003, 10:25am »

getting more and more beautiful all the time.
 
Pages: 1 

« Previous topic | Next topic »