animating bumpmaps

Posted By: Josh_Arldt

animating bumpmaps - 06/09/06 21:06

How could I achieve animating normalmap?
I have an animated normalmap sprite file which I want to use as a normalmap.
How can I use this as a normalmap and cycle through the frames?
Posted By: Inestical

Re: animating bumpmaps - 06/09/06 21:49

I'm not even close to know ánything about shaders, but in the effect, just flap through the skin frames?
Posted By: Josh_Arldt

Re: animating bumpmaps - 06/09/06 22:04

hmmm... Your idea gave me an idea...
What if I just keep changing the skin2 of the material every frame?
Posted By: Matt_Aufderheide

Re: animating bumpmaps - 06/09/06 23:30

Yes this would work.. could be done with a bitmap pointer.

Posted By: Josh_Arldt

Re: animating bumpmaps - 06/10/06 00:02

Hmmm a bitmap pointer you say?
What did you have in mind Matt?

bmap* anim_normal = <anim_normal+10.tga>;

Then maybe somewhere...
while(1)
{
anim_normal.frame+=time;
wait(1);
}

???
Posted By: xXxGuitar511

Re: animating bumpmaps - 06/10/06 03:50

Something like that should work. You wouldn't even have to change the shader

Just animate a bmap, and pass it to the shader as a mtl_skin via the skin var...
Posted By: Josh_Arldt

Re: animating bumpmaps - 06/10/06 03:55

Yes, exactly. I haven't tried it yet. I just wanted to get a general idea of what I'm going to do before I get around to it.
Posted By: xXxGuitar511

Re: animating bumpmaps - 06/10/06 05:01

Kool. I can't wait to see if it works out (or not). I'd write some code up for you, but I'm just too damn tired right now. Maybe I'll type somethin up tomorrow mornin'. If you can get the shader, I can try and animate it. lol.

What would be the best way to do this though? You could use the models skins as frames:
Code:

bmap* CMap;

// Animate an Entity by changing the frame parameters.
action AnimateMap
{
my.skill2 = 0.5; // Speed to animate
my.skill3 = 1;
while(1)
{
my.skill1 = cycle(my.skill1 + (my.skill2 * time), 1, ent_skins(my));
my.skill3 = int(my.skill1) + 1;
bmap_for_entity(my, my.skill3);
//
wait(1);
}
}



Then the pointer CMap is set to the skin that needs to be used for the shader mapping. This loop will not include the first skin of the model. This way you can have the models first skin the diffuse map. Then fill the other skins with the normal mapping frames. The above action will cycle through them, and set the predefined bitmap pointer to the entities skin.

The code above is made to work with only one entity though. For multiple entity support, you could simply set up an event for the shader.

Code:

function GetSkin();

material mat_IDK
{
enable_render = on;
event = GetSkin;
effect = "Whatever...";
}

function GetSkin()
{
mtl.skin1 = bmap_for_entity(my, my.skill3);
}

// Animate an Entity by changing the frame parameters.
action AnimateMap
{
my.skill2 = 0.5; // Speed to animate
my.skill3 = 1;
my.material = mat_IDK;
while(1)
{
my.skill1 = cycle(my.skill1 + (my.skill2 * time), 1, ent_skins(my));
my.skill3 = int(my.skill1) + 1;
//
wait(1);
}
}



This code will work with multiple entities, but will also take up more resources.

Say an entity has 6 skins. 1 diffuse texture, and 5 bumpmaps. This code will cycle through skins 2 - 6, and send the current one to the shader each frame. This way you can animate your bumpmaps. It will also work with multiple entities. As many as you want.

* The code above is not tested. Theoretically, it *should* work... If I had a model with animated bumpmaps to test it with, then i would.
Posted By: xXxGuitar511

Re: animating bumpmaps - 06/13/06 02:45

@Josh_Arldt:
Lose interest in the idea?
Posted By: Josh_Arldt

Re: animating bumpmaps - 06/25/06 06:51

Thanks man.
No I haven't lost interest in the idea.
I haven't had much free time lately.
It's of a lower priority on my to-do list.
© 2024 lite-C Forums