Dynamic Geometry

Creators: Alexander Bruce
Engine: Unreal Tournament 2004
Modification: UT2K4 Level Component

Last Update: 17th June 2007
Current Status: Working. Mostly hardcoded.
Further Development: Including further configurability to remove hardcoded components.
Download: Not yet available

Description: Reconstructing the world you play in...

Demonstration / Purpose Translating the Snake Metaphor Background Information Recursive Interaction Compound Recursion Dynamic Fading Textures Further Development

Page 6 - Implementation - Fading tiles


This problem was a real nuisance to work with. I'd wanted it since the start, but couldn't work out how I was going to do it dynamically. It would have been possible by flipping textures around to get tiles fading in one way or another, but this solution wasn't dynamic. If I had tiles at one point fading over one second, but later wanted them to fade over only half a second, I'd need another texture for that as well. This wasn't very useful considering I was constantly changing the rate with some of the weapons I was making in Hazard.

For the majority of the development to this point, tiles that actually moved were useful and looked nice when dealing with floors and walls. Unfortunately, the same could not be said when working with multi-layered tile structures, such as a solid volume. If you were in the middle of a cube where you were completely surrounded by tiles, it didn't make sense for the tiles to actually move anywhere, as they were completely surrounded by other tiles. In addition, you'd constantly be getting crushed by your surroundings. Hence, making them fade became a necessity at this point.

Good Moving Tiles

Moving tiles is good for walls

Bad Moving Tiles

Moving tiles is bad for solid objects



As I eventually discovered, Unreal already has a ColorModifier class that we could use for our alpha effects, as demonstrated in Laurent Delayen's FX_LinkTurretShield. This was a nice starting point, and got me into dynamically creating textures to handle these kinds of effects. I followed what was done in that work, and sure enough I had some tiles that faded. Unfortunately, they weren't exactly graceful about it.

Having played around with textures a fair bit when dealing with Particle Characters and Recursive Space, I went with the idea that at some point everything was code anyway, so I should be able to code my own textures at the beginning of the game, in the same way as I set up neighbours at the start. I first tried creating a Shader within the Unreal Editor, and then within UnrealScript dynamically allocating an Alpha channel for that Shader. This didn't work, because all tiles had the same instance of the Shader, so fading one tile would fade all of them. I therefore had to also dynamically allocate the Shader as well, using the texture that was already applied to the tile as the diffuse.

This was getting there, though it still wasn't the perfect fading effect I wanted, so I took it even further and allocated a FinalBlend as well. With textures set up this way, I then had control over several variables at run time as well, such as TwoSided (on the shader) and ZTest / ZWrite (on the FinalBlend). I've now got tiles that fade rather nicely, and it all replicates properly as well. Rendering hundreds of tiles to the screen at once has suffered some lag now because of the way the textures are set up, but given that massive levels won't work in multiplayer anyway, this doesn't matter for the time being. I'm still working on it though.

Mid-way through fading

Mid-way through fading

Near the end of the fade

Near the end of the fade



For those that were interested in seeing how this code for this fade effect is set up, it can be viewed when a version is made available to download.

Back Home Next