How do the pixel shaders work?

New releases and general discussions.

Post » Fri May 08, 2009 2:44 pm

Tom, if you've got a couple of film grain textures I could have a shot at making a film grain effect. I'm useless with art though. I guess you'd need a bunch of black-and-white textures that have just the film grain pattern on them, then I could use that with an effect to process the background, and switch randomly between the textures to give the effect of frames going by.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Fri May 08, 2009 3:18 pm

Ooh this is starting to be interesting!
And to be honest FX code looks so simple that I could try to learn it a bit to make few FXs ^^ Maybe some day...
B
11
S
3
G
4
Posts: 622
Reputation: 3,186

Post » Fri May 08, 2009 3:43 pm

[quote="Ashley":255fq99z]Tom, if you've got a couple of film grain textures I could have a shot at making a film grain effect. I'm useless with art though. I guess you'd need a bunch of black-and-white textures that have just the film grain pattern on them, then I could use that with an effect to process the background, and switch randomly between the textures to give the effect of frames going by.[/quote:255fq99z]

Funny thing is I completed 'Ico' a couple of days ago and figured out today that once you play through it, you get a couple of post processing effects to play around with.

I think the old film / grain effect works through a couple of layers. You have the grain itself, which just animates randomly (David had something like this set through a simple event in an older cap). Then, you have a couple of burns and stuff - means: black blotches and burnmarks that you barely notice, cause the film runs at 24fps. You do see them, but they're quickly gone again. And then you also see a few light stripes 'walking' from left to right sometimes. I have no idea how they're generated, but my wild guess is that that's just light shining through the roll of film. And then the film also sometimes loses its sharpness - I guess that's because the filmroll is probably moving around slightly while being played - but that's a wild guess again.

Also, there's vignetting, which means that the sides of the screen gradually become darker and darker.

Valve has put up a bit of info on what they did for Left 4 Dead on their blog:

http://www.l4d.com/blog/post.php?id=1962

Interesting stuff.

I'll try to come up with a Photoshop composition that has those layers in one simple .psd, so you could play around with it. Another thing that'd certainly help to get this old'ish look would be if we could affect the opacity of a sprite through the sine behavior - So we could let things flicker and fade in / out, etc. randomly.

Also, have you looked at the fx file they provided on that site? Maybe that effects looks cool enough already?
B
6
S
2
G
3
Posts: 520
Reputation: 2,690

Post » Fri May 08, 2009 4:37 pm

I don't have Photoshop, by the way :?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Fri May 08, 2009 5:09 pm

Film grain should be relatively easy. Using a prerendered texture like this:
Or even better would be rgb noise generation like what the image manipulator can do, except with an alpha channel.

Now for the vignette, thats a bit harder as its based on screen size.
Here is an overlay for a top layer(based on 640x480 screen): [url:3evmxjux]http://dl.getdropbox.com/u/666516/vig.png[/url:3evmxjux]
Example in gimp:[url:3evmxjux]http://dl.getdropbox.com/u/666516/vig.xcf[/url:3evmxjux]
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri May 08, 2009 10:38 pm

I did part of the effect for Rocket Days, just cause I thought it would be easy (and it was).
It's lacking blotches, hairs and scratches (the bright lines that walk are scratches in the film made by projection equipment!) but only because they require more time creating the images for them.

[url:k4ls7b1g]http://www.udec.cl/~jfuente_alba/film.cap[/url:k4ls7b1g]

Nice link on L4D tech. We'll need adjustable smart-sharpening to do that one, and adjustable kernel-size blurring (samples can be fixed, kernel size just has to be adjustable).

Also, grayscale plus breaks alpha? Try adding it to the layer in that .cap and see what happens.
We need a way to apply effects to the whole screen. 3D games use a big quad that samples a buffer where everything's been stored so far. Layers cannot sample other layers in Construct. Would using Canvas work?
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Sat May 09, 2009 7:48 am

[quote="Madster":hefresfd]We need a way to apply effects to the whole screen. 3D games use a big quad that samples a buffer where everything's been stored so far. Layers cannot sample other layers in Construct. Would using Canvas work?[/quote:hefresfd]

That's exactly what I do. Create a canvas object and put it into the topmost layer. Then apply the effect to the canvas object. So you really only ever have to set the effect once.

@devs: It'd be cool if we could copy / paste a whole layer with its settings from one layout to another.

If you want the effect on other layouts as well, you just create a layer on top of everything and set it to be an inheritance layer that references the canvas layer from the other layout.

The interesting part is that we can even use this stuff for gameplay effects. Like, you can even flip the screen (including inverted controls), invert everything, use warp effects and stuff like that.

Also, because the post processing then happens on an object and isn't just something that's being done internally, you can use it in events, which is pretty awesome. Imagine your character is drunk or drugged and to heighten the difficulty, you could start warping the screen, etc.
B
6
S
2
G
3
Posts: 520
Reputation: 2,690

Post » Sat May 09, 2009 8:10 am

[quote="thomasmahler":1rro8eeg]That's exactly what I do. Create a canvas object and put it into the topmost layer. Then apply the effect to the canvas object. So you really only ever have to set the effect once.[/quote:1rro8eeg]

You paste every object on the canvas? or is there a way to paste a whole layer?
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Sat May 09, 2009 11:19 am

No, that's what the canvas object does. I only assign it to the topmost layer so it affects every layer underneath it.

A canvas object is an object like the sprite object - just create it, you'll see what it'll do. You only need 1 canvas object and assign the effect you want to it - that's all there is to it. That way, you can even emulate adjustment layers or quickly change the mood of layouts and stuff, it's a pretty great way of working. So you could have 2 different mood sets that are only based on effects and they'd still only count as one in terms of vram.
B
6
S
2
G
3
Posts: 520
Reputation: 2,690

Post » Sun May 10, 2009 2:39 am

I'm trying but it behaves just like a sprite with the difference that I have an action to paste stuff on it.

Could you make an example of how to affect layers below?
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

PreviousNext

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 3 guests