animated texture for models [Q]

Posted By: mireazma

animated texture for models [Q] - 07/03/11 14:23

I need an animated texture for a model. I can't use sprites over the normal texture because I also need bump and parallax so the only way (I can see) is to replace the texture every frame of the game with a whole new texture that represents the subsequent frame of the "animated" texture (I couldn't express myself any better and preserve the clarity :)). And it's more: I must have control over the animation frames (the speed of "playing").
I think the best option is to use ent_setskin I have a doubt: The manual says:
Quote:
Skins can be replaced by calling ptr_remove for removing the skin returned by ent_getskin, and then setting the new skin with ent_setskin.

Is it really necessary? Can't I just call ent_setskin directly?
My guess is the worst that could happen is not freeing the memory containing the old useless texture. But since I intend to reuse that texture (the "animation" is a loop) I don't want to flush it anyway. But I don't want any internal unknown bugs by not removing the old texture first.
Plus I want to set the skin every single frame and that would cost me fps's cause ent_setskin is rated fast but ptr_remove is medium.
Otherwise, is there a better way for creating an "animated" texture for a model?
Posted By: MrGuest

Re: animated texture for models [Q] - 07/04/11 00:22

what kind of animation are you using. possibly use a shader to display the portion of the bmap for each stage of the animation?
Posted By: mireazma

Re: animated texture for models [Q] - 07/04/11 08:41

That would be very convenient. Wouldn't have to deal with ent_setskin or anything. I know shaders could be made to achieve all kinds of things visually, but to be honest, I haven't thought of such a shader.
The animation is this:

I have a tank and I need the tracks -- both wheels and linked tracks themselves -- to animate as the tank moves. Let's say I'd offset the UV to scroll the linked tracks but what about the wheels? they need to rotate and the bigger picture is I'd use the shader in other projects, as well.
Here is the track model:

Btw this is the default 3DSG parallax effect which is faulty, as you can see, but that's a different story...
The linked track (the part that goes on the ground) will have stripes not the way the track goes but across, to suggest the links but the diffuse texture is not ready yet.

+'s and -'s:

- The trick is I want to use bump and parallax as well. How does this get along with the method? Would it work? And would it require that the normal/height mapping textures be of the same format?
+ The texture size is small so the frames would fit into a 512 x 512 or maybe even 256 x 256 texture.
- only a few polys of the model need animated texture so there'd have to be both "dead" and "animated" parts into the same texture (not necessarily a minus but makes the shader more complicated)

I'm far from making my first shader (to say the least). Do you know of one that does what you said?
Posted By: Superku

Re: animated texture for models [Q] - 07/04/11 12:50

The parallax shader is not faulty, you are using it wrong. Why do you even try to make a tank with a shader and ~20 polygons? My advice: Scrap your idea and start all over again.
You can, f.i., take a quad (2 triangles) (for each wheel) and assign a wheel texture with alpha channel. Now you can animate the wheels easily by rotating them. The tracks should be a separate entity (to keep it simple) where you can now easily shift the U/V parameter.
Posted By: mireazma

Re: animated texture for models [Q] - 07/04/11 13:52

Thanks, Superku. I'm not only open to, but I always appreciate new ideas.
But you see, it's hard to follow your sig in my case wink.
I'm making a RTS game and I took into account about all the "terms" that would make the balance between visual richness and video load. I assumed like 500 objects simultaneously rendered, out of which 250 are tanks (a tank would be made out of ~5). This would be a peak, but encountered often. So I need to reduce the polys accordingly and still get the 3D feeling for the tracks (not to mention the animation...). I can't afford more objects in a tank.
And about the faulty use of the shader -- although I'm so tempted to do it, I'm not that rude to ask you for help once again. You already helped me once with an external topic laugh But believe me, I'm disappointed about the parallax.
Posted By: painkiller

Re: animated texture for models [Q] - 07/04/11 14:04

I already told you that parallax is only for plane surfaces, like floors or simple boxes, the same for occlusion shader.
Posted By: mireazma

Re: animated texture for models [Q] - 07/04/11 14:51

Painkiller, I replied in that specific topic
Posted By: bart_the_13th

Re: animated texture for models [Q] - 07/10/11 01:32

Use LOD
When you want to see 500 tanks on screen, that means the camera is very far away from the scene so the tank can be shown with less detail, I guess no one will notice that their wheel and tracks is moving or not. Except the 500 models occupy the same spot since you forgot to add collision grin
Then when the camera come closer, use the tank with more details, maybe using Superku's method, but instead of separating the wheel from the tank(and having them as different entities) you can stick them in the model and rotate them by animating it directly, you can control the rotation by using ent_animate.

[EDIT]
usng ent_setskin affect all entities sharing the same model, that mean you can't have one model animated while the others not
© 2024 lite-C Forums