I've spent a few hours hammering through the UDK material docs now, and I'm still no closer to an actual solution to this. What I want, is a translucent material which renders everything behind it blurred (as if you had put a blur filter on it in photoshop, for example).
Basically, I want to make this:
And I cannot work out for the life of me how to even begin to go about achieving the blur on the viewed-through-glass objects. If anybody has any tips or pointers about where to start I'd really appreciate it!
Replies
some combination of the above realtime blur material, a scene capture actor and some noise plugged into the distortion of a slightly transparent material might do it.
would be bloody expensive though. i presume you're planning on having something affect the material in realtime so you can't just use a texture? like a person walking past the window etc?
it may be possible to use a very low res scene capture since you're going to blur it anyway which would save memory but not instructions. is this for a portfolio piece or for an actual game? apart from that i think you'd have to get into writing custom nodes.
hope that helps
http://forums.epicgames.com/showthread.php?t=789955
Also thanks to pondering this I finally found a decent way to blur a cube map. Thanks.
The blur quality could be increased by changing how the blocks are interpolated, at the expense of more operations. Current shader is 120 instructions, so not terrible, and not super light either.
edit: one more.. just added in a control for how much of the normal map gets taken into account
What I did was to use the SceneTex as texture lookup with Virtuosics example, but I couldn't get it to map to screenspace due to my usual very limited math muscles (do fill me in!), which seems to me should do the trick on flat-window surfaces atleast. No normals though, just blur:
To do this you can just use a screenpos node as UV's
I have an example of that in this shader: (top right of image)
http://www.flickr.com/photos/sprunghunt/5177430382/
Rasmus: Thanks man! you totally inspired me to make another approach at this. My earlier example is using a realtime cubemap, again, explaining later tonight.
Here's the new version and its shader network. Can definitely use refinement, but I'm outa time right now.
I also refined the refracting glass a bit, as I had made an error in one part. Not serious, but it makes a difference.
here's a new screenshot
I'll give a short detail of how this is done now: and get the shader network labeled and captured for upload a little later.
When Marks posted the goal look of the material, I noticed that the nature of the effect was very close to the transmitted contents being mosaiced at different block sizes, along with some smoothing. Realworld wise this is small scale changes in refraction due to surface faceting.
I thought of how cubemaps work by projecting a vector from the center of a cube to its faces, and returning the color of a texel hit by that ray. Normally you reflect into them, but if you just pass the camera vector you get what amounts to transmission. Simple refraction can be achieved by altering the camera vector before it is used in the cube map.
So to facet or mosaic something I figured you just need to pass the same vector for multiple samples. With infinite vectors to choose from this could be hard, but since we're dealing with the space of a cubemap, only unit vectors are valid, which makes life much easier. Numerically, you can get discrete steps from a continuum by multiplying by the number of steps you want, then rounding down the product to the nearest integer. To get it back to the same start and end points you divide the product by the number of steps you originally multiplied by.
This works for 2d and for 3d. 2d you can do it with texcoords, 3d you do it with spacial vectors.
I added a step to attempt some smoothing, by linearly interpolating between different scales of steps, so you get sub-blocks per full block. And now I remember I was going to do that differently at first, but my first attempt was flawed because I did it wrong. I have an idea that I might be able to smooth out the blocks.. if it works I'll post it here too.
In my first post the real magic happened when I tossed in a normal map to perturb the surface normal. Combining a semi-random surface normal with the texture chunking gave a nice blurry glass look.
The other glass type effects, like color, varying opacity, external reflection, etc, all added to the look, and took more time than just setting up the mosaic blur.
Will edit in the morning with the video and probably some shader refinements.
[ame]http://www.youtube.com/watch?v=mYgh3VKF-7U&hd=1[/ame]
and the shader network.
click for full size
I do find, however, that adding in a distortion like normal map to the overall chain with the mosaic effect really gets some nice effects. I altered the screenbuffer version to include a scaleable normal map to use both in its chunking effects and in the sort of front frosting effect. The normal map does a lot of the work, but the pixelation helps break up the background into large bits of color for the normal map to distort.
I played around a bit on the VCTF map included since the foliage demo map is too hardcore for my current hardware.
Here's a few shots. From and angle and up close. EDIT: Oh, btw the big black uglyness in the upclose shot is thanks to some odd post process thing happening in the editor. There are some edges of the screen that have this subtle black fade on them, and when they hit the screenbuffer chunking effect they get chunked too.
Showing different transmission attribute settings. (kinda cool lookin)
One very noticeable artifact on these is the block size is in screenspace, so the chunking gets visibly larger as you get further from the object. Could modulate the block size with scene depth perhaps to get a more consistent look no matter how far away you are from the glass surface.
Anyway, Marks, or anyone else, if you want the node structures for this or anything else I can make up a udk package and post it to dropbox for easy reference
So I remembered how I thought of doing the block blending the first time and fixed up the framebuffer shader to be less pixelated. Turns out I've been re-inventing my way toward the ever so standard bilinear filtering algorithm... One the one hand, its nice to know that I CAN re-invent wheels.. on the other its a bit of a "duh" moment that I wasn't able to make the abstract jump to known algorithms from where I was at.
Also there is a video to show it in motion:
[ame]http://www.youtube.com/watch?v=yqFU5I9QR68[/ame]
and the package of materials, including a few I've made up before, but aren't relevant to this thread can be found here (13mb rar archive)
I haven't updated the package, but the unreal object text can be downloaded here.
Edit: Upper bit has block size 128, lower has 64
Just import it into udk and it will create the material for you, though you'll need to re-link the normal map in the shader.