Timing problem with "animated" material

Hi!

I have some issues getting an “animated” material working.

First, a little background on what I am trying to achieve here. As a learning process I am trying to emulate behaviours from an older game engine, more specifically the good old game Heretic (which in turn was built upon the classic Doom engine). What I am trying to do in this case is to replicate an animated floor tile. To quickly summarize:

  • All floor tiles are 64x64.
  • Floor tiles are world aligned.
  • Each frame in the animated tile is stored as a separate texture.
  • Each tic in the doom engine corresponds to 1/35 secs, and each frame of animation for the tile lasts a multiple of Heretic’s tic rate.

I could probably achieve a lot of this by using more “modern” techniques (like FlipBooks). However, in the interest of learning, I’m trying to do as little editing as possible of the source material and more closely emulating the older methods.

I have set up a material (with parameters), and a three material functions in order to take care of the necessary behaviour. The current material is set to play three frames, each playing for 8 “gametics” (that is 1/35 sec multiplied by 8). To do this I have used a MatLayerBlend_TenLayerBlend, with each frame as a separate layer, using the layer mask to show or hide material based on a calculation with a Time node.

Ideally, frame A start playing when time is 0, frame B should start playing when time is approx 0.2286 (1/35 sec * 8) and frame C should start playing at 0.4571 (1/35 sec * 16) and should loop again after time has reached 0.6857 (1/35 sec * 24). However, what happens is that frame A shows briefly, then it skips straight to frame C.

Could anyone point me to what I’ve done wrong with my material? I’m sure it’s just a silly, simple error, but I can not for the life of me track it down.

Pictures of the material and material functions:

  • Main material:

http://i.imgur.com/Div4bvH.png

  • Material function - MF_GameticToTime:

http://i.imgur.com/dvnPSA5.png

  • Material function - MF_FlatBase:

http://i.imgur.com/d0JGkzI.png

  • Material function - MF_FlatAnimatedLogic:

http://i.imgur.com/bSwHF8I.png

Notes

The “Error” in the Material Attributes of MF_FlatBase is because I haven’t assigned a Preview texture to it, but the material function itself works as it should. The error should, as far as I can see, have no actual bearing on the main issue.

For those interested, the comment for the Time node in the main material that is cut off in the image is supposed to read: “Hardcoded time (24 gametics) as you can’t convert period to parameter :(”

Found the answer. *sigh* A simple matter of having stared at the screen for too long.

All I had to do was edit MF_FlatAnimatedLogic:

  • A>=B plugged to 1
  • A==B plugged to 0
  • A < B plugged to 0

I apologize for wasting your time on such a longwinded question for what was basically putting the wrong foot in the wrong shoe. :stuck_out_tongue:

Don´t worry my friend, it´s happen to everybody! =D