Hey guys,
I've been working on making some cool materials lately, and TheKeg showed me Dice's document on how they do their Sub Surface Scattering inside of Frostbite 2. The technology behind it isn't anything out of the ordinary, so naturally, I decided to try and bring it into UDK.
Here are the Results:
[ame="
http://www.youtube.com/watch?v=HSjU2oUl5_0"]Sub Surface Scattering - UDK - YouTube[/ame]
I used the code that Dice showed in
this document to create a custom shader inside of UDK. It actually wasn't too hard to do.
The most interesting part for me was playing around wit hrendering out decent "Volume" maps. All you have to do is invert the normals of your highpoly mesh, and then render out an ambient occlusion map. Inverse the colors of that ambient occlusion map and you have yourself a Volume map.
After playing in Photoshop, this is the result that i got.
Notice the lighter areas of the Unwrap are the tips of the crystals, and are lighter in color to allow more light to pass through. The bottom areas are darker in color, and let less light pass through. The lighter edges were added based on the normal map for a more stylized look.
You could get the same result in realtime by using a map like this in the "Transmission Mask" material slot, but when it bakes it doesn't look as convincing, and honestly what comes stocked with UDK is meant for things like skin, cloth, and membrane like materials.
The downsides of using this shader are threefold: It can't be baked, it can't cast shadows without ruining the effect, and it's for dynamic lights only. However, that usually goes unnoticed as long as the effect looks great. If you wanted to use this in actual production, you'd have to do some pretty crafty placement and composition to hide this among assets that use baked lighting.
Thanks for reading/watching, and thanks DICE for making this information public... it certainly is a cool little shader.
Questions or Comments, don't hesitate.
Replies
I'm hoping that I don't ask for too much here, but could you upload this scene? I'd love to play around with that effect for a bit and I'm not sure if I could get it to work by myself, since I don't have any experience with coding shaders in UDK or anything else.
Great looking results in your test, man!
did you have to play with the ray angle or distance much, or the bias?
Brilliant work!
Some of you asked about tweaking and stuff like that. I definitely had to tweak the shit out of it to get it to look alright. for instance, there's an instruction in the shader that "distorts" the incoming light based off of the normals of your shader, and it didn't look that great at first so i had to do lots of tweaking to get it to look right. I guess it has to do with the type of material you're working with, but for the crystal bitss it took quite a bit of time to come out properly.
There was something nice that i learned during this process though. The Custom node shader is really powerful because it allows you to use any function that comes stocked in the HLSL library that may not be included in the UDK node system. For example, if I plug in a custom node, i could write an expression that utilizes the "smooth step" function, which essentially "softens" a hard edged mask. There are lots of useful functions in the library that you can utilize.
Here is a list of HLSL intrinsic functions for the tech savvy people:
http://msdn.microsoft.com/en-us/library/windows/desktop/ff471376(v=vs.85).aspx
Nice work. Looks just lovely.
Yeah, the Custom node is great. I've used it a few times to implement more complicated algorithms when I can't be arsed to translate them into a web of nodes (or, as you've already mentioned, when the HLSL method isn't available as a node). One thing to be aware of is that the Custom node doesn't compile as cleanly as the built-in stuff, since it can't take advantage of compiler optimisations in the same way as the nodes can.
It's great for little one-offs, though!
you did a very nice demo scene!
great job
IIRC one of the later builds of UDK from last year added material functions. some of them are node based reconstructions of the photoshop layer blend modes, and various filters. it sounds like what vurtousic was looking for is already availible in stock UDK through one material function node.
You Are Awesome .
Ehsan Gamer - hang tight... i can't say anything but it's possible that what you want is right around the corner
computron - Alot of those photoshop blending functions actually utilize the custom code node for the blends. you can look at the networks themselves if you are curious how they put them together.
I had a go, and made a little demo for testing out the parameters. Due to the way Unity's deferred lighting works, it will only render as a forward material, but it's so quick it won't add too much overhead.
Here's the webplayer. (Needs Unity plugin, obviously).
Edit: Unchanged, it runs at about 10fps on an iPad 1.
Not as far as I can tell, as Strumpy doesn't seem to expose a light direction node. Here's the Unity shader I used.
Now I'll try to stop derailing Virtuosic's thread
https://vimeo.com/36583615
it looks like a low framerate but its only the translation of the light source.
I agree with having more video tutorials from you. I would pay double for such good information/tutorials.
That pit scene you were working on was just too good. (shaders and all)
Go Canada!
lol synergy11... go canada? I'm amurican!
Ewwww
I played many shows their back in teh day.
I checked on Colins website and hes only got settings for Max
http://colinbarrebrisebois.com/category/subsurface-scattering/
Have you actually tried that? with the stock settings it just comes out as pure black because no rays are cast to the inside of a water tight object.
Max is using a completely different method of AO than Maya and Xnormal which allows for it to generate AO on a water tight inverted object.
I don't get it. Should we bake an inverted HighPoly Mesh of the Lowpoly version,
like standard baking method? (Cuz for me it just don't work. I've used Xnormal and 3DSMax, and both renders are fu****up.)
Or should we bake a HighPoly mesh AO which mean that the highpoly version should have UVs.
It would be great to have a kind of step by step, to know exactly how you get this "volume" map.
Flip the normals of both meshes, bake the AO from the high to the low, then flip the normals of the low so they're facing out again. You're baking AO from the inside of the inverted high-poly mesh, so you need to have the normals of the low-poly mesh flipped to take advantage of this.
Bake in Max, MentalRay gives me an image that looks like a splotchy mess. Nothing at all like an AO style map as shown by the OP.
Same here : black squares with XNormal, and some crappy render done with 3DSMax, not with MentalRay, but with LightTracer.