Translucency with SSS (sub surface scattering)

Hello,
Not sure if i may post blend of depicted screenshost here as the models and few textures are not mine. I think i got these from Crysis :).

Here are some screenshots:

http://img521.imageshack.us/img521/3690/sss5.jpg

http://img15.imageshack.us/img15/4231/sss3k.jpg

http://img14.imageshack.us/img14/2707/sss4d.jpg

http://img41.imageshack.us/img41/4820/sss1g.jpg

http://img26.imageshack.us/img26/7244/sss2z.jpg
And here is simple demo with translucent suzanne.
Translucenct_suzanne.blend (426 KB)

controls:
mouse/wasd - look/move
left mouse button+mouse movement - move light
UP/DOWN arrowkeys - chahge material thickness
Numpad keys:
changes
7/4 - red scattering value
8/5 - green scattering value
9/6 - blue scattering value

I will upload nicer demo as soon is i create my own scene to present this shader.

Niice! Thats really awesome!

this is pretty nifty. thanks for the blend!

whao, it’s really good

we should call you the GLSLBlenderMan !!!

Sweet shader Martinsh!!
The only drawback is that the shader doesn’t update when you rotate the object.
And I also take the chance to upload the ATI version of the shader.

Attachments

Translucenct_suzanneATI.blend (343 KB)

thanks! this is GPL or similar, right? :slight_smile:

EDIT: i tried it out and it doesn’t work. i’m on an NVidia GEForce 6200. a lot of your other shaders dont work either. ???

EDIT 2: i got this error:
"
---- Fragment Shader Error ----
0(50) : warning C7011: implicit cast from “int” to “float”

---- GLSL Program ----
Fragment info

0(50) : warning C7011: implicit cast from “int” to “float”
0(70) : warning C7011: implicit cast from “vec4” to “vec3”
0(72) : warning C7011: implicit cast from “vec4” to “vec3”
0(15) : error C5041: cannot locate suitable resource to bind parameter “normal”
0(15) : error C5041: cannot locate suitable resource to bind parameter “lightDir”

---- GLSL program failed to link ----
"

:eek: amazing. Good work (as usual).

EDIT: i tried it out and it doesn’t work. i’m on an NVidia GEForce 6200. a lot of your other shaders dont work either. ???

I’ve tried to solve it but my guess is that the 6200 may be too old to support some shaders after all (I’m testing on my old pc).

So far I think that this graphic card can’t handle so many variables of the type “varying vec3”; tested changing the last too, “normal” and “lightDir”, to simple vec3 ant this let continue the shader but it doesn’t work leaving the monkey head black.

@Cloud_GL
i couldnt find lines you changed in shader to get it work on ATI cards, except mat3 to vec3, which isnt right, because vec3 has 3 values, but mat3 is 3x3 matrix, so it has 9 values and the reflection isnt working in ATI version of the shader. Are you sure, that mat3 isn`t working on ATI cards?

Here is prettier demo. I removed all warnings like int to float and vec3 to vec4 stuff…

http://img30.imageshack.us/img30/6899/sss1.jpg

http://img19.imageshack.us/img19/4766/sss2k.jpg

http://img15.imageshack.us/img15/7900/sss3m.jpg

http://img13.imageshack.us/img13/2108/sss4b.jpg

download: (rightclick and Save As…)
http://www.twilight22.com/blenderartists/translucent_sss_demo.blend

controls:
mouse/wasd - look/move
left mouse button+mouse movement - move light

1 - milk
2 - orange juice

UP/DOWN arrowkeys - chahge material thickness
Numpad keys:
changes
7/4 - red scattering value
8/5 - green scattering value
9/6 - blue scattering value

u/j - red specular color
i/k - green specular color
o/l - blue specular color

Very cool. I would love to be able to tweak this in the viewport.
Questions from a blender noob.
What shader writing tool did you use to make this? If any?
Is this like the video texture swapping?
Does the script need a material with a matching name assigned to the object to use it?

Incredibly great!

Are you sure, that mat3 isn`t working on ATI cards?

So far yeah I haven’t been able to run it:
“Matrix construction from matrixs not allowed in GLSL1.10” Says the comand line.
Anyways, you sure you need it? Here is a screenshot on mine working using vec3 instead of mat3, and looks pretty similar to the one you posted…

Besides that now I got a warning:
“Built-in varying gl_Texcoord[0]has mismatched acces semantics between vertexshader and fragment shader”
Maybe this is cause of the vec3 conversion I did?

Attachments


WOW, is that really in the game engine. :eek::eek::eek: :eek::eek::eek: :eek::eek::eek: :eek::eek::eek:

Fantastic Martinsh! as Always ^^

Those pictures looks great, but in the GE the milk/orange juice remains black and the console gives me this error:

---- GLSL Program ----
Fragment info

0(14) : error C5041: cannot locate suitable resource to bind parameter "lightDir
"

---- GLSL program failed to link ----

I have GLSL activated, Blender 2.49, nVidia 6600gt. I don’t have any experience in GLSL, so that the error-message doesn’t help me

ParnoidAndroid

As soon as I hit ‘P’ I get this error in the console: Fragment info -------------------- 0(14) : error C5041: cannot locate suitable resource to bind parameter “lightDir” ---- GLSL program failed to link ----- So I don’t see any effect at all in the shaders, I’m using XP PRO, NVIDIA Card.

@ ParanoidAndroid, SamCameron - I would assume that you need a GPU with pixel shader 2.0. Do your cards have that?

You can tweak values in game itself :slight_smile:
controls are explained below the download link.

I use Blenders text editor tool to write this :) Anyway these shaders doesnt come from nowhere. I use whitepapers, coding forums etc. to look for code samples. Then i combine them in Blender.

No this isnt anything like VideoTex swapping, in fact, this doenst use textures at all. Except for cube map for glass.

Tu use this shader, you have to write name of your translucent object in beginning of the script where is “obj = objlist[‘OBGlass’]” and name of light object where is “lamp = objlist[‘OBLamp’]”, thats it. Your object doesnt even need UV map and any texture applied on it, so it is quite easy to use. Note that currently it will work only with 1 light source.

cool.
thanks dude. i’ll try some more swapping later from home. i’d love to see how this would look on a organic character model.
great work btw!
cheers.