;

PDA

Click to See Complete Forum and Search --> : Particles as vector textures?


evolbeagle
04-08-2007, 10:29 AM
Has anybody experimented with using particles to add texture to vector drawings in KM? I was thinking about that as a possble approach and thought I'd ask before trying to reinvent the wheel.

Say, for instance, you had a vector shape that represented a dirt road. It occurred to me that if you could write a script that would scatter a bunch of particles across that shape, you might be able to give it a suitable grainy texture without having to draw a bunch of extra shapes. The particles would be static once created, but would vary somewhat in terms of things like alpha, scale, rotation - the standard stuff. Has anybody already tried anything like this? If so, does it work? I did some searching on this idea but came up basically empty - maybe I'm not using the right search terms.

Anyway, any input would be appreciated.

Thanks,

Matt

blanius
04-08-2007, 11:22 PM
It's an interesting idea. Let us know what you find out.

evolbeagle
04-09-2007, 02:12 AM
Well, I experimented with the idea a bit tonight. You can see one example here (http://www.sketch.mattjordan.com/2007/04/08/koolmoves-particles-as-vector-based-textures/). The linked example uses two vector particles (no bitmaps) and diminishes the _yscale as you go up the rectangle in an attempt to give it a sort of perspective look.

Assuming it's not too CPU-intensive, this general idea seems promising if you could figure out how to clip the resulting texture to an irregular shape.

Matt

w.brants
04-09-2007, 07:26 AM
It's better to create a bitmap object and draw onto that object.
If you duplicate a lot of movieclips cpu load gets high. Drawing onto a bitmap can be done as often as you want since there's not a lot of movieclips that have to be kept in memory.

Here's an examplecreateEmptyMovieClip('src_obj', 0);
src_obj._visible = false;
src_obj.beginFill(0xffff00);
src_obj.lineStyle(5, 0xff00ff);
src_obj.moveTo(20, 20);
src_obj.lineTo(40, 40);
src_obj.lineTo(20, 40);
src_obj.lineTo(20, 20);
dst_obj.endFill();

bmp_fill = new flash.display.BitmapData(200,100,true,0);
onEnterFrame = function(){
for (i=0; i<20; i++){
mat = new flash.geom.Matrix(Math.random(),0,0,Math.random(), Math.random()*200,Math.random()*100);
col = new flash.geom.ColorTransform(1, 1, 1, Math.random(), 0, 0, 0, 0);
bmp_fill.draw(src_obj, mat, col);
}
}
onEnterFrame();

createEmptyMovieClip('dst_obj', 1);
dst_obj.beginBitmapFill(bmp_fill);
dst_obj.lineStyle(1, 0x0000ff);
dst_obj.moveTo(10, 10);
dst_obj.curveTo(140, 0, 190, 10);
dst_obj.curveTo(20, 40, 190, 90);
dst_obj.lineTo(10, 10);
dst_obj.endFill();Make sure to export as flash 8.

evolbeagle
04-09-2007, 08:17 PM
Thanks for the tip! I'll play around with that approach and see what I can do with it.

Matt

Mysteron
04-14-2007, 11:32 AM
Your link states your having problems clipping the texture. I'm assuming your code is in the main frame. Try putting your code in the 1st frame of an MC. Then masking over the top of the MC. You could also try noise or perlin noise, used with alpha or blend modes, for creating textures.

Mysteron
04-14-2007, 02:30 PM
This is about as a simple as I could make it.
Play around with the parameters for endless texture effects.

Mysteron
04-14-2007, 03:35 PM
Same as above, but for random noise.

evolbeagle
04-15-2007, 09:15 AM
Thanks, Mysteron! I'll play around with those and see what I can learn.

Matt

Mysteron
04-20-2007, 02:17 PM
If you think they worthy. I will post them in the exchange, Along with a more artistic example. If your work involves alot of vector shapes it's sometimes worth saving as bitmap, then importing back in.

evolbeagle
04-21-2007, 08:17 PM
If your work involves alot of vector shapes it's sometimes worth saving as bitmap, then importing back in.

True, of course, but then you give up scalability without pixelation. The problem here the the old "can't maximize for all the variables" rub: if you're avoiding the Flash cartoony look (as I'm trying to do), it's difficult to make a flash movie that's great for both the web and dvd output. For now, I'll probably just optimize the movies I'm making for the web and forget about the possibility of putting them on dvd unless and until that becomes a real and viable thing to do. Then I'll solve whatever issues I have in converting at that time.

While I'm on this, though, I did stumble across a cartoon on Cartoon Network that seems to use this noise-based approach for its texturing. The cartoon was called Ben 10 and I thought the approach was only somewhat effective - partly because it was overused in this particular instance.

Matt

Mysteron
04-22-2007, 07:34 PM
If scalability is the issue. You could adapt the perlin_mc's script to work at run time. But it's not a good idea due to CPU overhead. But you may be able to adapt this for your purposes. It uses the start big scale down approach. But doesn't suffer from pixelation and bandwidth problems associated with bitmaps. It's the best I could come up with. I've removed the mask for clartity. Code is in the main frame and the 1st frame of the perlin_mc. The perlin_mc is not visible because its empty(aside script). But you will find it in the top left corner(0,0).