Flashing Disco Floor

TehStoneMan

L1: Registered
Jun 15, 2012
46
5
Hello. Can somebody help me with this?

I am trying to crate a set of tiles (each tile is a prop_dynamic with a custom model) that change colour randomly at a set interval, say once every 2 seconds.

I would like to have it like an animated texture where each frame is selected at random instead of in sequence (if possible), with each tile colour independent from each other.
 

Seba

DR. BIG FUCKER, PHD
aa
Jun 9, 2009
2,364
2,728
This could probably be pulled off with texture proxies like UniformNoise and AnimatedTexture, TextureTransform, or TextureScroll. I'll give this a shot tomorrow maybe, it sounds interesting.
 

henke37

aa
Sep 23, 2011
2,075
515
If nothing else, you can let I/O do the changing and build fancy patterns.
 

henke37

aa
Sep 23, 2011
2,075
515
Or just use different skins and let I/O do the animations.
 

Seba

DR. BIG FUCKER, PHD
aa
Jun 9, 2009
2,364
2,728
Oh right, I was supposed to do this. Whoops.

Doing this with entities would also work, but considering the number of tiles you'd be working with that'd probably be more trouble than it'd be worth. Although I suppose you could make a few sets of tiles that would switch together, that'd save some work.
 

henke37

aa
Sep 23, 2011
2,075
515
I could throw together a simple pattern editor in Flash that exports an instance for you to include if you want me to. I/O is really easy to generate.

EDIT: I was bored so I wrote it up. Got bored just before the exporter. Give me a shout if you want me to finish it up.
 
Last edited:

TehStoneMan

L1: Registered
Jun 15, 2012
46
5
What I am hoping to do, is have one skin as the flashing pattern, one skin as blue, and one skin as red.

With this, I also would like to be able to use trigger delays to change the skin in a pattern.

If there is a way to start an animated texture on a random frame, I guess one possible solution could be to just use a "pseudo random" animation sequence.

Is this even possible?
 
Last edited:

TehStoneMan

L1: Registered
Jun 15, 2012
46
5
After a bit of thought, I have a basic concept on how it could be done using an animated sequence:

Code:
UnlitGeneric
{
	$model	1
	$basetexture models/props_disco/dance_floor_tile

	$offset 0

	Proxies
	{
		// Set the initial frame of this tile
		EntityRandom
		{
			scale 5
			resultVar $offset
		}
		
		// Get the integer of offset
		
		// Get timer value
		
		// Add offset to timer
		
		// Calculate frame number from timer + offset

		// Update current frame
		Equals
		{
            srcVar1 $offset
            resultVar $frame
		}
	}
}

This example assumes a five frame animation, but the final version would be much longer. I doubt anybody would be studying the pattern long enough to notice that it's not truly "random". :)

Any suggestions to fill in the missing code?
 

henke37

aa
Sep 23, 2011
2,075
515
Bah, I/O is better for randomization.
 

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,669
I/O isn't as easily scalable, though, and for any significantly sized floor you would end up with a crapton of stuff. I also don't know if one can really say that the logic_case RNG is any better than the material proxy RNG. They may even be the same thing.

Have you tried UniformNoise? My first guess is you could point that straight into $frame and be done with it. I'm not sure how fast it would change, though.
 

TehStoneMan

L1: Registered
Jun 15, 2012
46
5
UniformNoise was one of the first things I tried, but it proved difficult to control the rate of change and have the tiles different colours.
 

henke37

aa
Sep 23, 2011
2,075
515
I/O scales marvelously if you use a program to generate it for you. There is literally no limit to how much I/O you can stuff in a single logic_relay, as long as you don't poke at it using hammer.
 

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,775
7,669
It's not about putting a lot of IO in one place. For a randomized floor you would end up needing increasing amounts of entities linked together as the number of tiles increases, unless you are going to limit yourself to 16 predefined patterns that are randomly selected using a logic_case. If you can put the randomization code in the material, then it doesn't matter how many tiles you have, there will be zero alteration or complexity increase.


I haven't messed with proxies in a long time and don't remember how they all work, I might have to poke around myself to look for an answer.