mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-04 12:05:13 +00:00
Merge pull request #1582 from Azaezel/SubSurf
Reimplements a form of subsurface scattering
This commit is contained in:
commit
ee6d9961e3
10 changed files with 95 additions and 19 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() )
|
||||
|
|
|
|||
|
|
@ -918,9 +918,6 @@ function MaterialEditorGui::guiSync( %this, %material )
|
|||
MaterialEditorPropertiesWindow-->vertLitCheckbox.setValue((%material).vertLit[%layer]);
|
||||
MaterialEditorPropertiesWindow-->vertColorSwatch.color = (%material).vertColor[%layer];
|
||||
MaterialEditorPropertiesWindow-->subSurfaceCheckbox.setValue((%material).subSurface[%layer]);
|
||||
MaterialEditorPropertiesWindow-->subSurfaceColorSwatch.color = (%material).subSurfaceColor[%layer];
|
||||
MaterialEditorPropertiesWindow-->subSurfaceRolloffTextEdit.setText((%material).subSurfaceRolloff[%layer]);
|
||||
MaterialEditorPropertiesWindow-->minnaertTextEdit.setText((%material).minnaertConstant[%layer]);
|
||||
|
||||
// Animation properties
|
||||
MaterialEditorPropertiesWindow-->RotationAnimation.setValue(0);
|
||||
|
|
|
|||
|
|
@ -147,6 +147,17 @@ void main()
|
|||
return;
|
||||
}
|
||||
|
||||
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||
vec3 subsurface = vec3(0.0,0.0,0.0);
|
||||
if (getFlag( matInfo.r, 1 ))
|
||||
{
|
||||
subsurface = colorSample.rgb;
|
||||
if (colorSample.r>colorSample.g)
|
||||
subsurface = vec3(0.772549, 0.337255, 0.262745);
|
||||
else
|
||||
subsurface = vec3(0.337255, 0.772549, 0.262745);
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||
vec3 normal = prepassSample.rgb;
|
||||
|
|
@ -258,6 +269,5 @@ void main()
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
OUT_col = AL_DeferredOutput(lightColorOut+subsurface*(1.0-Sat_NL_Att), colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,17 @@ void main()
|
|||
return;
|
||||
}
|
||||
|
||||
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||
vec3 subsurface = vec3(0.0,0.0,0.0);
|
||||
if (getFlag( matInfo.r, 1 ))
|
||||
{
|
||||
subsurface = colorSample.rgb;
|
||||
if (colorSample.r>colorSample.g)
|
||||
subsurface = vec3(0.772549, 0.337255, 0.262745);
|
||||
else
|
||||
subsurface = vec3(0.337255, 0.772549, 0.262745);
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uvScene );
|
||||
vec3 normal = prepassSample.rgb;
|
||||
|
|
@ -195,6 +206,5 @@ void main()
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
vec4 colorSample = texture( colorBuffer, uvScene );
|
||||
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
OUT_col = AL_DeferredOutput(lightColorOut+subsurface*(1.0-Sat_NL_Att), colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,6 +202,17 @@ void main()
|
|||
return;
|
||||
}
|
||||
|
||||
vec4 colorSample = texture( colorBuffer, uv0 );
|
||||
vec3 subsurface = vec3(0.0,0.0,0.0);
|
||||
if (getFlag( matInfo.r, 1 ))
|
||||
{
|
||||
subsurface = colorSample.rgb;
|
||||
if (colorSample.r>colorSample.g)
|
||||
subsurface = vec3(0.772549, 0.337255, 0.262745);
|
||||
else
|
||||
subsurface = vec3(0.337255, 0.772549, 0.262745);
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
vec4 prepassSample = prepassUncondition( prePassBuffer, uv0 );
|
||||
vec3 normal = prepassSample.rgb;
|
||||
|
|
@ -312,6 +323,5 @@ void main()
|
|||
lightColorOut = debugColor;
|
||||
#endif
|
||||
|
||||
vec4 colorSample = texture( colorBuffer, uv0 );
|
||||
OUT_col = AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
OUT_col = AL_DeferredOutput(lightColorOut+subsurface*(1.0-Sat_NL_Att), colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,6 +149,16 @@ float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
|
|||
{
|
||||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
float4 colorSample = TORQUE_TEX2D( colorBuffer, uvScene );
|
||||
float3 subsurface = float3(0.0,0.0,0.0);
|
||||
if (getFlag( matInfo.r, 1 ))
|
||||
{
|
||||
subsurface = colorSample.rgb;
|
||||
if (colorSample.r>colorSample.g)
|
||||
subsurface = float3(0.772549, 0.337255, 0.262745);
|
||||
else
|
||||
subsurface = float3(0.337255, 0.772549, 0.262745);
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
float4 prepassSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
|
||||
|
|
@ -263,6 +273,5 @@ float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
float4 colorSample = TORQUE_TEX2D( colorBuffer, uvScene );
|
||||
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
return AL_DeferredOutput(lightColorOut+subsurface*(1.0-Sat_NL_Att), colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,17 @@ float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
|
|||
return float4(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
float4 colorSample = TORQUE_TEX2D( colorBuffer, uvScene );
|
||||
float3 subsurface = float3(0.0,0.0,0.0);
|
||||
if (getFlag( matInfo.r, 1 ))
|
||||
{
|
||||
subsurface = colorSample.rgb;
|
||||
if (colorSample.r>colorSample.g)
|
||||
subsurface = float3(0.772549, 0.337255, 0.262745);
|
||||
else
|
||||
subsurface = float3(0.337255, 0.772549, 0.262745);
|
||||
}
|
||||
|
||||
// Sample/unpack the normal/z data
|
||||
float4 prepassSample = TORQUE_PREPASS_UNCONDITION( prePassBuffer, uvScene );
|
||||
float3 normal = prepassSample.rgb;
|
||||
|
|
@ -194,6 +205,5 @@ float4 main( ConvexConnectP IN ) : TORQUE_TARGET0
|
|||
addToResult = ( 1.0 - shadowed ) * abs(lightMapParams);
|
||||
}
|
||||
|
||||
float4 colorSample = TORQUE_TEX2D( colorBuffer, uvScene );
|
||||
return AL_DeferredOutput(lightColorOut, colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
return AL_DeferredOutput(lightColorOut+subsurface*(1.0-Sat_NL_Att), colorSample.rgb, matInfo, addToResult, specular, Sat_NL_Att);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.rgb;
|
||||
if (colorSample.r>colorSample.g)
|
||||
subsurface = float3(0.772549, 0.337255, 0.262745);
|
||||
else
|
||||
subsurface = float3(0.337255, 0.772549, 0.262745);
|
||||
}
|
||||
// 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*(1.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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -918,9 +918,6 @@ function MaterialEditorGui::guiSync( %this, %material )
|
|||
MaterialEditorPropertiesWindow-->vertLitCheckbox.setValue((%material).vertLit[%layer]);
|
||||
MaterialEditorPropertiesWindow-->vertColorSwatch.color = (%material).vertColor[%layer];
|
||||
MaterialEditorPropertiesWindow-->subSurfaceCheckbox.setValue((%material).subSurface[%layer]);
|
||||
MaterialEditorPropertiesWindow-->subSurfaceColorSwatch.color = (%material).subSurfaceColor[%layer];
|
||||
MaterialEditorPropertiesWindow-->subSurfaceRolloffTextEdit.setText((%material).subSurfaceRolloff[%layer]);
|
||||
MaterialEditorPropertiesWindow-->minnaertTextEdit.setText((%material).minnaertConstant[%layer]);
|
||||
|
||||
// Animation properties
|
||||
MaterialEditorPropertiesWindow-->RotationAnimation.setValue(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue