View Full Version : Real Time Skin Shader - public release.

09 September 2005, 06:12 AM
Hi everyone, I'm not a big poster here, but I thought I'd make a post to mention I've released an HLSL skin shader I've been working on recently.

-It's HLSL, so usable in most 3d apps directx viewports
-Normal map lighting model
-front on and fresnel specular
-attenuation blooming (simulates the effect of harsh translucency blooming)

It has its shortcomings and limitations, I'm an artist not a coder so the code is ugly, and it only supports one light at the moment... however, you can get some damn nice results, so enjoy, and post your results! :D

Here's a quick example of what it's capable of:
Skin shader example 01 (The Squishy) (

go here ( grab it!

To understand how to apply HLSL shaders, Ben Cloward has an excellent tutorial on the matter in 3DSMax here (

Here's a quick overview of how to use the shader:

In regards to the settings, it defaults to some more stable base numbers and plugs in the blank_ textures provided. It's incredibly flexible for a number of different surface type effects, so don't be too worried about moving too far away from these defaults.
I suggest first moving the light source far away and balancing out the settings translucency settings so that the bloom settings won't be interferring with this initial setup; move the light closer and play with the attenuation bloom/focus controls seperately. Fresnel settings are dependant on the base specular settings since it's all one pass, so I'd suggest doing the base spec settings then go onto the fresnel stuff after that's all good - just check the glancing angle flare that the fresnel settings give by rotating the view around your model. Pretty easy, but it all can be very tweaky.

Texture passes:
- Diffuse: RGB, alpha is not yet supported.
- Specular: RGB is the colour and power of the specular component. The alpha is the glossiness of the specular.
- Translucency: RGB is the colour and intensity. The alpha is the amount that the light can bleed along the normals (which in turn is then amplified by the attenuation bloom) - think of the alpha like the internal depth, and the rgb like the density of the internals... so alpha is the scatter radius and rgb is light penetration amount.
- Normal: rgb, xyz... pretty standard :)

09 September 2005, 08:24 AM
This is very very interesting indeed. Thanks very much for posting this up, I've been looking for something like this for quite a while. Kind of scared to see you paint, model, texture AND code, it can't leave you much time in the day.

I've done some very quick tests and have a couple of questions.

The great 'squishy' images show a different set of controls to the ones I'm getting when I download the shader and run it in Max 7.5. I'm wondering whether the UI shown in the images is the final one or the one the shader gives when loaded. For example the image shows controlls for "Translucent Colour" where as the loaded shader has a "Translucency Map" slot.

Does the "Trandlucency Map" control the colour and strength of the translucency effect or just the strength with a hidden 'fixed' translucency colour?

Have you thought of adding a ambient look up term, either to two colour swatches for world up and down or to a low rez cube map? Our initial tests show seems helpful on a skin shader.

Anyway thanks again for sharing this up


09 September 2005, 09:32 AM
Sweet!!....I was looking for a solution to SSS in 3dsmax, this solution looks real good to me jistyles, and as soon as I get to the stage I will quite readily apply this shader...btw awesome example of what it's capable of looks the ticket to what's needed..:thumbsup:...and thank you again so much for posting up a release...

09 September 2005, 09:53 AM
Thanks man! That's really awesome! I haven't seen such translucent skin shaders in any of the popular games yet. I'm currently busy on a female. I'll see what the shader is capable of and show you the result ;)

Thanks for your input!

09 September 2005, 10:26 AM
This is fantastic, thank you for sharing this. Can't wait to try it out, just what i was looking for. Excellent work. :thumbsup:

09 September 2005, 12:49 PM
thats so nice
Thanks a lot. I've made a teapot test and it works excelent. I'm looking forward to map it on everything I can find on my machine. :thumbsup:


btw: Cool game art on you site

09 September 2005, 02:29 PM
Congrats on such a cool shader, Joel! I'm going to be using this one a lot. I'll also be learning a lot from how it works! If you're interested in making it support multiple light sources, it's pretty easy to do. You can break it down so that each light is one pass. You can take a look at my Normal Map Specular shader to see how to do it: (

This shader supports three light sources and just runs three times, once for each light.

09 September 2005, 05:46 PM
This looks quite good. I might just give it a bash.

Thanks for posting it :thumbsup:

Are you going to release updates for it?


PS: Some quality work on your site by the way :)

09 September 2005, 10:21 PM
Hey! You got it done!

Nice job man it works really well!

I think its time you unleash your 3d skills upon cgtalk with a new detailed model that takes advantage of this shader :scream:

09 September 2005, 03:07 AM
Hey everyone, glad to see the response is so positive :D
I'll try my best to answer everyones questions.

Jol: Thanks for the comments! The squishy image is an older work in progress test model I made just for the purpose of authoring this shader... as such the settings are from the shader at an earlier stage of life. I will put up a quick set of instructions on the use of the shader in the first post to help the learning curve along a bit.
The world up/down ambient lookup sounds like hemispherical lighting - I'd considered doing a few improvements to the lighting model like that, but before then I will need to optomise the current code. It's pushing the limits of 2.0 pixel shader instructions just in terms of amount of instructions... it's not that it's slow, more that it's just sloppy code ;)

johnwoo: Hey cheers! I really like your work, so I'm going to be very interested in what you're able to pull off on your gorey organic characters. The shader does have its limitations so doesn't really stand up to the vray or mental ray pre-rendered shaders, but for a real time pixel shader you can get some nice looking results :thumbsup:

FeRdI: You're welcome dude! Thanks for the compliment, looking forward to seeing what you come up with!

CG_Gordon: Thankya!

florian: hahaha :D There's gotta be at least 20+ skin shader teapots on my computer from developing this thing, it's like they're still multiplying! Glad you like it, feel free to post or email me anything you come up with - I would love to see what people do with it - and thanks a heap for the compliment!

bcloward: Hey Ben! Thanks for the kind words - you helped me a great deal in learning to author shaders, and I'll be sure to give the multiple light support a go after I've optomised it. The 3 light setup looks pretty easy to implement, nice and elegant way you've gone about it! good job!

mindrot: Heya Mr. Rot, yup I'll be releasing updates - I have plans to improve it to a certain point, so I should be supporting it for a little while yet. Thanks for the compliment too! :D

Hazardous: cheers JT! and I agree on the whole sharing the art lovin' on cgtalk - good and open international community around these areas. Are you posting your rider updates here? That guy is looking slick :applause: Gotta catch you online sometime soon, I've been neglecting IM for a while to shave off time to develop this shader and my own work, so I should try and get an active presence back online huh :)

10 October 2005, 05:54 AM
Hey everyone, it's been a little while but R3 is now ready for public consumption :)
The main addition here is the ability to choose from a 1, 2, or 3 light setup depending on your needs, as well as a few minor optimizations and tweaks to the lighting model. Enjoy!

You can grab it from my page here, as well as check the progress:

Thanks for sending all the pics too! Seeing people put this to use is what motivates me to improve on it :) thanks guys, you know who you all are :D


edit: Just wanted to chuck in the last wip test image too... I think I'll focus on doing a character with this shader and testing it out in a production environment for a bit over the next few weeks. From here I'll probably focus on optimizations and functionality.

10 October 2005, 09:52 AM
Sweet!!...I'm still experimenting with the 1st release shader, but I'm just d/loading the update now...Unfortunately I won't be applying it to the current w.i.p but definitely for whatever I do next...that is a given certain...and again thank you so much for a generous rock man :buttrock:

10 October 2005, 09:55 AM
This is a fantastic update Joel, just what I was looking for. Looking forward to trying out on my lunch break. :thumbsup:

10 October 2005, 10:39 AM
i downloaded the first one, but didnt get round to using it, this update is a good reminder to get in gear and produce something with it.

10 October 2005, 02:09 PM
So can someone render out an image with this shader applied to it?
Or is it for realtime viewports only?

10 October 2005, 06:07 AM
johnwoo, CG_Gordon, SHEPEIRO: Cheers guys, looking forward to seeing what people do with it :D

modeling_man: It's for realtime viewport only, unless you have xsi which I believe has the ability to render hardsware shaders like this. The main benifit and purpose of hlsl shaders like this one is that it's the exact same piece of code as used in-engine, so you're able to see exactly what it looks like while creating your assets before having to put it in game. Eg, no more back and forth between your 3d app and the game to preview what it'll look like. Hope that explains it :)

10 October 2005, 07:25 AM
ah but a screenshot of a viewport would work then ey :D

would love to see some more uses. I think I read on on of the forums [either here, cgchat or polycount, not sure which one] that people've sent you samples of their use. perhaps you could put up a gallery on your site. that would be ace :)

10 October 2005, 07:27 AM
This shader is ace. Been trying it out properly over the last hour or so and it works excellently. Will hopefully have something to post up soon. Great job Joel, now hows that hair shader coming along? :D


10 October 2005, 10:37 AM
Hey, the shader sounds pretty nifty. :D

I have a couple questions though:

Does the shader work for max 5? I read part of the tut you linked to and it says something about HLSL for 6 or 7 does that mean only 6 or 7 or higher?

Does the shader work for most games or is it only for games that have HLSL enabled in the engine?

Hmm I think thats all the questions I have for now perhaps a couple more later. ;)

10 October 2005, 05:03 AM
Yves Adam: Yup, a screengrab of the viewport is fine -- you can use the max preview animation to save animations too :)

CG_Gordon: glad to see you're likeing it :) doh... hair shader... umm yeah, getting a little caught up just on the skin shader so far :D but! As soon as I figure out how to render depth volumes cheaply (SO CLOSE!!! NEARLY THERE!), then I'll have a new revised skin shader with true sub-surface scattering. Unfortunately that's chewing up my little free time, but as I said it's pretty close to completion.

AnOldFriend: I don't think max5 had the directx 9 shader support, but I'm not 100% sure - maybe someone can confirm this? And yes, the .fx code could be directly used in any engine with support for it.

Alex McGilvray
10 October 2005, 07:06 AM
thanks very much for your contribution, I cant wait to get back to town and try this on my current model :D:D:D

10 October 2005, 11:55 AM
Hi jistyles, first of all, great thanks for your awesome fx shader! here i would like ask a question, do you know how to add a transparency to a realtime fx shader? i really hope to know whether directx 9 support realtime transparency(opacity) or not.

so waiting for you reply here. or send me PM.

thanks a lot

10 October 2005, 06:51 AM
Man! great work on your shader, gunna give it go. Thanks for sharing it with us.


10 October 2005, 01:55 AM
hi jistyles

thanks ~

your ss shader very cool!

10 October 2005, 03:00 PM

this shader looks really cool.
so i downloaded it, followed ben's tutorial, but i can't get the shader to work.
when i try ben's normal specular shader i get a custom interface with slots for normals etc.
when i apply jistyles shader i get nothing, no options at all and my model turns into wireframe.
anyone know why this would be?
i'm using max 7.

hope someone can help me with this.


EDIT: hmm after testing again i can't get ben's HLSL shader to work either. no options or anything, and it too turns my model wireframe.
i'm thinking perhaps my gfx card doesn't support them (gf4 ti4200) but surely the diffuse etc slots would appear?


10 October 2005, 06:00 PM
Hi Rob!

Here's how to tell if a shader will work with your graphics card:

1. Open the shader file in Notepad or some other text editor.
2. Scroll down to the bottom of the file and find the line that says "VertexShader = compile"

Right after the word "compile" it will say "vs_1_0" or "vs_1_1" or "vs_2_0" This is a code that tells the vertex shader what version to use. If it says to use version 2, it won't run on a GeForce 4 card. GeForce 4 only supports up to vertex shader 1.3

You also need to check what pixel shader version it's using. Look for the line that says "PixelShader = compile" Right after that it will say "ps_1_1" or "ps_2_0" Again, if it's higher than 1.3, you're out of luck with a GeForce 4.

That's probably not what you wanted to hear, but at least now you know how to find out for sure if a shader will work with your card or not.

10 October 2005, 06:03 PM
One more thing I forgot - If your card won't run the shader, none of the settings will show up. The shader won't work at all. There's no such thing as running a shader half way. It just works or it doesn't work.

10 October 2005, 08:57 PM

thanks for the advice Ben.
hmm i need vertex shader 2.
still, buying a new computer soon so not long to wait until i can get it up and running.


CGTalk Moderation
10 October 2005, 08:57 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.