www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: keaukraine on December 02, 2010, 02:03:09 pm

Title: Moving texture
Post by: keaukraine on December 02, 2010, 02:03:09 pm
Hi,

How can I change texture UV coordinates to move it in some loop?
I want to achieve effects like falling rain drops (place some transparent polygons with rain texture and continuously move texture in the bottom direction to achieve desired effect), or grass waving on the wind (move texture in the left/right direction), water running in the river, etc...
Title: Re: Moving texture
Post by: EgonOlsen on December 02, 2010, 02:42:53 pm
You have different options for this:

Title: Re: Moving texture
Post by: keaukraine on December 02, 2010, 03:21:59 pm
OK, so the only way to do it is using PolygonManager.
The next question is: how expensive is calling Object3D.compile(true, false) on each frame redraw? I will need to animate moving textures for objects like water, clouds, etc...
Can I call only touch() as stated here: http://www.jpct.net/forum2/index.php/topic,1689.0.html , or it's no enough to update UVs?
Title: Re: Moving texture
Post by: EgonOlsen on December 02, 2010, 03:59:11 pm
Just update the uv's and call touch(). There's no point in calling compile(...) for each frame. It would be a nop anyway. Regarding performance, rendering static objects is faster than rendering dynamic ones (at least if they actually change...if they don't, it doesn't matter) and changing uv is even more expensive. As long as the objects are pretty simple, it shouldn't matter that much though. Just make sure to reuse TextureInfo-instances instead of creating new ones and call touch() only if something has changed.
As said, if you can move the geometry instead, then do it. Clouds, for example, can easily be animated by rotating a sky dome/box instead of modifying uv coordinates.