mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-28 00:29:34 +00:00
reimplements a form of subsurface scattering
This commit is contained in:
parent
b4547da50b
commit
00cc949011
3 changed files with 36 additions and 3 deletions
|
|
@ -1153,7 +1153,8 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
|
|||
|
||||
// Deferred Shading: Determine Material Info Flags
|
||||
S32 matInfoFlags =
|
||||
(mMaterial->mEmissive[stageNum] ? 1 : 0);
|
||||
(mMaterial->mEmissive[stageNum] ? 1 : 0) | //emissive
|
||||
(mMaterial->mSubSurface[stageNum] ? 2 : 0); //subsurface
|
||||
mMaterial->mMatInfoFlags[stageNum] = matInfoFlags / 255.0f;
|
||||
shaderConsts->setSafe(handles->mMatInfoFlagsSC, mMaterial->mMatInfoFlags[stageNum]);
|
||||
if( handles->mAccuScaleSC->isValid() )
|
||||
|
|
|
|||
|
|
@ -202,6 +202,16 @@ float4 main( FarFrustumQuadConnectP IN ) : TORQUE_TARGET0
|
|||
return float4(1.0, 1.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
float4 colorSample = TORQUE_TEX2D( colorBuffer, IN.uv0 );
|
||||
float3 subsurface = float3(0.0,0.0,0.0);
|
||||
if (getFlag( matInfo.r, 1 ))
|
||||
{
|
||||
subsurface =colorSample;
|
||||
if (colorSample.r>colorSample.g)
|
||||
subsurface.r*=2;
|
||||
else
|
||||
subsurface.g*=2;
|
||||
}
|
||||
// Sample/unpack the normal/z data
|
||||
float4 prepassSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, IN.uv0 );
|
||||
float3 normal = prepassSample.rgb;
|
||||
|
|
@ -314,6 +324,5 @@ float4 main( FarFrustumQuadConnectP IN ) : TORQUE_TARGET0
|
|||
lightColorOut = debugColor;
|
||||
#endif
|
||||
|
||||
float4 colorSample = TORQUE_TEX2D( colorBuffer, IN.uv0 );
|
||||
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
return AL_DeferredOutput(lightColorOut+subsurface*(2.0-Sat_NL_Att), colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2240,6 +2240,29 @@
|
|||
useMouseEvents = "0";
|
||||
useInactiveState = "0";
|
||||
};
|
||||
new GuiCheckBoxCtrl() {
|
||||
canSaveDynamicFields = "0";
|
||||
internalName = "subSurfaceCheckbox";
|
||||
Enabled = "1";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiCheckBoxProfile";
|
||||
HorizSizing = "right";
|
||||
VertSizing = "bottom";
|
||||
position = "8 46";
|
||||
Extent = "79 16";
|
||||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
Command = "MaterialEditorGui.updateActiveMaterial(\"subSurface[\" @ MaterialEditorGui.currentLayer @ \"]\", $ThisControl.getValue());";
|
||||
tooltipprofile = "ToolsGuiDefaultProfile";
|
||||
ToolTip = "Enables the use of subsurface scattering for this layer.";
|
||||
hovertime = "1000";
|
||||
text = "Sub Surface";
|
||||
groupNum = "-1";
|
||||
buttonType = "ToggleButton";
|
||||
useMouseEvents = "0";
|
||||
useInactiveState = "0";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue