Notifications
Clear all
[Closed] DBC Fast SSS Script – Simulation SSS
Jul 17, 2008 7:56 pm
I recently created this script to Simulation SSS(SubSurface Scattering). It build in Self-Illumination map.
--- DBC FastSSS Author: Hanrui
(
global sss_obj = undefined
global sss_light = undefined
global sss_map= undefined
global o_distance = undefined
global flag_autoupdata = false
global flag_AA = true
global offset_prv = 0
global str_mattype = undefined
fn filter_mesh obj = superclassof obj == Geometryclass
fn filter_light obj = superclassof obj == light
fn Updata_prv Img =
( view=render outputwidth:250 outputheight:240 vfb:off renderType: #selection antiAliasing: flag_AA
Img.bitmap=view
)
rollout DBC_Preview " Preview " width:280 height:380
(
bitmap preview_img "Bitmap" pos:[9,20] width:250 height:240 bitmap:(bitmap 50 50 color:black)
button btn_Refresh "Refresh" pos:[9,310] width:250 height:24
checkbox chk_autoupdata "Auto Refresh" pos:[9,275] width:84 height:20
checkbox chk_AA "Anti-Aliasing" pos:[100,275] width:84 height:20 checked:true
on btn_Refresh pressed do
(
select sss_obj
Updata_prv preview_img
)
on chk_autoupdata changed state do
(
flag_autoupdata=chk_autoupdata.checked
if flag_autoupdata do
(
select sss_obj
Updata_prv preview_img
)
)
on chk_AA changed state do
(
flag_AA = chk_AA.checked
select sss_obj
Updata_prv preview_img
)
)
-------------------------------------------------------------------------------------------------------
rollout DBC_main "Parameters" width:280 height:352
(
pickbutton pick_light "Pick Light" pos:[109,12] width:149 height:24 enabled:true message:"" filter:filter_light toolTip:"Pick a light"
pickbutton pick_obj "Pick Object" pos:[109,41] width:149 height:24 enabled:false message:"" filter:filter_mesh toolTip:"Pick a object"
colorPicker sss_color "color" pos:[9,11] width:83 height:53 enabled:false color:(color 255 255 255) fieldWidth:55
spinner spn_level "Intesity" pos:[25,99] width:90 height:16 enabled:false range:[0,100,1] scale:0.1
spinner spn_offset "Offset" pos:[166,99] width:90 height:16 enabled:false range:[-999999,999999,0] type:#float scale:0.1
slider sld_range "Range" pos:[9,139] width:262 height:44 enabled:false range:[50,100,100] ticks:1
label lab_Percentage "" pos:[215,139] width:48 height:18
on pick_light picked obj do
(
sss_light = obj
pick_light.text = obj.name
pick_obj.enabled = true
)
on pick_obj picked obj do
(
sss_obj = obj
pick_obj.text = obj.name
CenterPivot sss_obj
sss_map= falloff ()
sss_map.direction = 3
sss_map.type = 4
sss_map.node = sss_light
p_light=sss_light.pos
p_obj=sss_obj.pos
if sss_obj.material == undefined do
(
new_mat = StandardMaterial diffuse:(color 180 210 0)
sss_obj.material= new_mat
)
sss_map.farDistance = (distance p_obj p_light)*2
o_distance = sss_map.farDistance
str_mattype = (sss_obj.material as string)
if (findstring str_mattype "Standard") !=undefined do
(
sss_obj.material.SelfIllumMap=sss_map
sss_obj.material.useSelfIllumColor = on
)
if (findstring str_mattype "Raytrace") !=undefined do
(
sss_obj.material.Luminositymap=sss_map
)
sss_map.color2 = sss_color.color=sss_obj.material.diffuse
sss_color.enabled=true
spn_level.enabled=true
spn_offset.enabled=true
sld_range.enabled=true
)
on sss_color changed col do
(
sss_map.color2 = sss_color.color
if flag_autoupdata do (
select sss_obj
Updata_prv DBC_Preview.preview_img
)
)
on spn_level changed val do
(
if sss_obj != undefined do
( r
sss_map.texture_output.rgb_level = spn_level.value
)
if flag_autoupdata do (
select sss_obj
Updata_prv DBC_Preview.preview_img
)
)
on spn_offset changed val do
(
if sss_obj != undefined do
(
sss_map.nearDistance += spn_offset.value-offset_prv
sss_map.farDistance += spn_offset.value-offset_prv
)
offset_prv = spn_offset.value
if flag_autoupdata do (
select sss_obj
Updata_prv DBC_Preview.preview_img
)
)
on sld_range changed val do
(
sss_map.farDistance=o_distance*sld_range.value/100
temp= o_distance-sss_map.farDistance
--when %50 farDistance == nearDistance
if temp > sss_map.farDistance do ( temp=sss_map.farDistance)
sss_map.nearDistance = temp
lab_Percentage.caption = sld_range.value as string+"%"
sss_map.nearDistance += spn_offset.value
sss_map.farDistance += spn_offset.value
if flag_autoupdata do (
select sss_obj
Updata_prv DBC_Preview.preview_img
)
)
on sld_range buttondown do
(
sss_color.color= sss_map.color2
)
)
-------------------------------------------------------------------------------------------------------
rollout DBC_about "About ..."
(
label cloth_label00 "
"
label cloth_label01 "DBC Fast SSS Version 1.0"
label cloth_label02 "by DBC Studio"
label cloth_label03 "18 July 2008"
label cloth_label04 "[ http://Dabaichi.goofar.com ]( http://dabaichi.goofar.com/ )"
label cloth_label05 "
"
)
DBC_floater = newrolloutfloater "DBC Fast SSS 1.0" 280 600 100 100
addrollout DBC_main DBC_floater
addrollout DBC_Preview DBC_floater
addrollout DBC_about DBC_floater rolledup:true
)
1 Reply
Jul 17, 2008 7:56 pm
SSSSS (Simulation Sub Surface Scattering SelfIllumination)
That’s a lot of S’s
Neat trick though!