"Replace Color" action for Sprite object

New releases and general discussions.

Post » Sat Jan 09, 2010 12:56 am

My game project is really pushing the limits of people on the screen - there's gonna be at least 400 pedestrians in a layout at once. So too little visual difference makes it hard to make a good feeling of a city.

I made a small system called "P.R.E" to randomize headwear for each civilian and that made it a little more bearable to watch crowds of people. I toyed with color filters but didn't achieve anything but red lava people.

Then I realized what Construct really would need: color replacing!

You can already crop out colors in corners of a sprite, why not replace one color with another?

I could put specific colored areas to my little townsmen and then randomize the color on their chest to create different colored shirts and pants for every single citizen in my game!

So please, to make my game wonderfully crowded I need a Replace Color action to the Sprite object.

P.S, here's how the citizens are doing now: naked, without clothes and only headwear on :(

B
4
S
2
G
6
Posts: 50
Reputation: 1,690

Post » Sat Jan 09, 2010 1:18 am

Isn't there a shader that does that?

You really should use a shader, otherwise you'd be using extra VRAM for every texture with different colours.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sat Jan 09, 2010 1:45 am

This has been requested a lot in the past, and I believe the consensus was that it'd be really complicated, and slow rendering down a lot because of something something VRAM something, I don't know.

[quote:3prsuodl]I toyed with color filters but didn't achieve anything but red lava people.[/quote:3prsuodl]

If all you are getting is shades of red then your expression might be wrong. To get a full gamut of red, green, and blue you need to use the rgb(r, g, b) expression in the color filter box. Just typing in something like "200, 150, 150" or "random(255), random(255), random(255)" won't work, it will only recognize the first value and apply it to the red channel only.

Also, if you make your people have pure white skin with shades of gray and black outlines, then you can set up a skintone generator kind of like so:

http://dl.dropbox.com/u/529356/skintones.cap

Of course, the numbers could be tweaked and you could make people more saturated and orangey looking like in your screenshot. Or you could always make a set of twelve or so preset filters and randomly assign them to your sprites.

Or, of course, track down that color changing shader like Ash said. It only changes one color per shader, I believe, but since you seem to have only one skin color in your sprites that shouldn't be a problem.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Jan 09, 2010 8:10 am

If I use this shader to achieve, say, different colored shirts and pants, can each of them be randomized independently?

So each and every pedestrian would have a differently colored shirt, pants and a varied skin color. That combined to the headwear will make everyone look different.

And Deadeye, I know about the color filter thing - the thing is, should I make a white shirt sprite separate from the citizen, then attach it to the citizen and THEN randomize its color.
B
4
S
2
G
6
Posts: 50
Reputation: 1,690

Post » Sat Jan 09, 2010 9:54 am

[quote="Namelezz":6gkoco08]And Deadeye, I know about the color filter thing - the thing is, should I make a white shirt sprite separate from the citizen, then attach it to the citizen and THEN randomize its color.[/quote:6gkoco08]

Sure, if you want to take the time to set it up:

http://dl.dropbox.com/u/529356/scarypeople.cap

There's an awful lot of women with bald heads or comb-overs in that example, though :P. And people with green hair. Anyway, animation would be a bit trickier to do. Not hard, really, just time consuming.

Those totally random colored clothes are kind of odd looking too, as you can see. Like I said you may just want a set of a dozen or so colors to pick from.

As far as that shader goes, yeah if you have one color for skin, one color for shirt, and one color for pants, then you would have to use three shaders. Each could be randomized.

The benefits to using filters are you won't get slowdown like you would with a shader. The drawback is of course the time it takes to set up.

The benefit to the shader is it's a lot easier to use, and you don't have to split up your objects into different parts. But rendering time might become an issue.

I can't for the life of me find that shader now though... I know it's here somewhere on the board. I can't even remember who made it. It's not linkman's hue shader, because that changes all the colors at once, not just one of them. Argh, I really wish people would put their finished plugins into the Completed Addons section :?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Jan 09, 2010 4:35 pm

Does the shader take into account semi transparencies, or offer a color range?
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Tue Jan 26, 2010 10:04 am

[quote="deadeye":1km4wi8l]I can't for the life of me find that shader now though... I know it's here somewhere on the board. I can't even remember who made it. It's not linkman's hue shader, because that changes all the colors at once, not just one of them. Argh, I really wish people would put their finished plugins into the Completed Addons section :?[/quote:1km4wi8l]
It is called (tadaa) "Color Replace", created by lucid, and can be found in this thread:
[url:1km4wi8l]http://www.scirra.com/forum/viewtopic.php?f=17&t=4234&hilit=color+replace&start=10[/url:1km4wi8l]

[quote="newt":1km4wi8l]Does the shader take into account semi transparencies, or offer a color range?[/quote:1km4wi8l]
No, and no.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue Jan 26, 2010 12:31 pm

[quote="tulamide":399w7dqd]
It is called (tadaa) "Color Replace", created by lucid, and can be found in this thread:
[url:399w7dqd]http://www.scirra.com/forum/viewtopic.php?f=17&t=4234&hilit=color+replace&start=10[/url:399w7dqd]

[quote="newt":399w7dqd]Does the shader take into account semi transparencies, or offer a color range?[/quote:399w7dqd]
No, and no.[/quote:399w7dqd]
I couldn't make it do the transparencies I believe cuz it had premultiplied alphas or something. Someone who knew more about shaders explained why it didn't work to me

also, there is another one on that same page for color ranges
scroll down the page a little bit
there is one called range tinter
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Sat Feb 13, 2010 11:13 pm

Just do the same thing you did with the hats, but with the people's skin color.
B
7
S
2
G
3
Posts: 139
Reputation: 2,331

Post » Tue Feb 16, 2010 8:40 pm

does Range Tinter work with alpha?


Just in case it doesn't, or if you want to retrofit Color Replace with alpha support

Premultiplied alpha means color rgb(0.8,0.8,0.8) with an opacity of 50% gets stored as rgba(0.4, 0.4, 0.4, 0.5).

To get the original color, just divide by the stored alpha!

color = rgb(0.4, 0.4, 0.4) / 0.5 = rgb(0.8,0.8,0.8)

then do your color replacing magickqs and then re-multiply by alpha.

*All vector notation here is faux and does not work at all like that in shader code.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 5 guests