Subsurface Scattering From GLSL to Unreal Material

I’m trying to fake subsurface scattering in Unreal but am running into problems translating it from a GLSL shader I found into the material editor. My math is pretty rusty and I don’t know how to calculate things like attenuation in Unreal.

Here’s the GLSL version: Subsurface Scatter Shader | machines don't care

I have the Half Lambert and tried setting up the attenuation but have no idea how to approach it. Anybody interested in helping?

Interesting technique.
Unfortunately in the stock Unreal’s material editor you don’t have access to
the following data:

LightColor
LightPos
VertPos

Also there is no max() function.

The obvious solution is making the new nodes. But even if no one can do
that, it’s still possible to work around those limitations for a certain extent:

  • Expose all light parameters to material instances, so a programmer can drive
    those parameters. You’ll have to hardwired the number of lights:

    • If you use this shader on a skeletal mesh using LightEnvironment which is
      one distant light attached to the character then it’s no problem.
    • If you intend the shader for skeletals without LightEnv then it starts to get
      messy: You’ll probably need several versions of the shader, handling different
      number of lights, collect relevant light parameters around the mesh, make
      material instances on the fly and swap them when lighting changes. (Unless
      of course the shader is fast enough even with 3-4 lights.)
    • As for static meshes… well each SM would need it’s unique MatInst, which
      is hard to manage. I think it would be even less practical then the
      previous two methods.
  • The closest thing you have to vertex position is the per pixel WorldPosition.

  • The max() function could be done in the Custom node.

Alternatively you could mess with the TransmissionMask and
TransmissionColor accompanied by a hand painted “thickness” texture. We got
decent results with those on a female face.

Welcome to www.coverallchance.comWood FurnitureDiscount FurnitureTeak FurnitureOutdoor FireplaceTeak PatioFurniture TeakOutdoor FurniturePatio HeatersFire Pit

???[b]???[/b]???:???[b]???[/b]???[b]???[/b]???1???type 1 diabetes??2???(type 2 diabetes)???gestational diabetes???1???2???30??? ???gestational diabetes??? ???2???90???2???1 ??? 5 ???2 ??? 50% ??? 2 ?[b]???[/b]??? ??? ???[b]???[/b]???


Live Sex Webshows

[QUOTE=Zoltan;3637]Interesting technique.
Unfortunately in the stock Unreal’s material editor you don’t have access to
the following data:

LightColor
LightPos
VertPos

Also there is no max() function.

The obvious solution is making the new nodes. But even if no one can do
that, it’s still possible to work around those limitations for a certain extent:

  • Expose all light parameters to material instances, so a programmer can drive
    those parameters. You’ll have to hardwired the number of lights:

    • If you use this shader on a skeletal mesh using LightEnvironment which is
      one distant light attached to the character then it’s no problem.
    • If you intend the shader for skeletals without LightEnv then it starts to get
      messy: You’ll probably need several versions of the shader, handling different
      number of lights, collect relevant light parameters around the mesh, make
      material instances on the fly and swap them when lighting changes. (Unless
      of course the shader is fast enough even with 3-4 lights.)
    • As for static meshes… well each SM would need it’s unique MatInst, which
      is hard to manage. I think it would be even less practical then the
      previous two methods.
  • The closest thing you have to vertex position is the per pixel WorldPosition.

  • The max() function could be done in the Custom node.

Alternatively you could mess with the TransmissionMask and
TransmissionColor accompanied by a hand painted “thickness” texture. We got
decent results with those on a female face.[/QUOTE]

I am just going to throw this out there but unreal does have the option in the material editor to add your own HLSL code. If you add a custom node to the material editor there is an input called Code. When you select that input a input box will be shown allowing you to then input your custom HLSL code.

However I am not 100% sure if the HLSL functions that Zoltan said you would need are something that is native to Unreal or something that a programmer would have to add.