|
Author |
Topic: text as texture... (Read 7835 times) |
|
arielm
|
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
|
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
|
|
|
benelek
|
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
|
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
|
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
|
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
|
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
|
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
|
|
|
benelek
|
Re: text as texture...
« Reply #12 on: Jun 6th, 2003, 10:25am » |
|
getting more and more beautiful all the time.
|
|
|
|
|