mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-27 15:25:40 +00:00
Merge pull request #943 from Azaezel/alpha403/emissiveToReciveShadows
emissive to recivesShadows
This commit is contained in:
commit
95b8028e5a
23 changed files with 80 additions and 128 deletions
|
|
@ -146,13 +146,6 @@ void main()
|
|||
//create surface
|
||||
Surface surface = createSurface( normDepth, colorBuffer, matInfoBuffer,
|
||||
uvScene, eyePosWorld, wsEyeRay, cameraToWorld);
|
||||
|
||||
//early out if emissive
|
||||
if (getFlag(surface.matFlag, 0))
|
||||
{
|
||||
OUT_col = vec4(0, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 L = lightPosition - surface.P;
|
||||
float dist = length(L);
|
||||
|
|
@ -162,22 +155,22 @@ void main()
|
|||
float distToLight = dist / lightRange;
|
||||
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, L);
|
||||
|
||||
#ifdef NO_SHADOW
|
||||
float shadowed = 1.0;
|
||||
#else
|
||||
|
||||
float shadow = 1.0;
|
||||
#ifndef NO_SHADOW
|
||||
if (getFlag(surface.matFlag, 0)) //also skip if we don't recieve shadows
|
||||
{
|
||||
#ifdef SHADOW_CUBE
|
||||
|
||||
// TODO: We need to fix shadow cube to handle soft shadows!
|
||||
float occ = texture( shadowMap, tMul( worldToLightProj, -surfaceToLight.L ) ).r;
|
||||
float shadowed = saturate( exp( lightParams.y * ( occ - distToLight ) ) );
|
||||
shadow = saturate( exp( lightParams.y * ( occ - distToLight ) ) );
|
||||
|
||||
#else
|
||||
vec2 shadowCoord = decodeShadowCoord( tMul( worldToLightProj, -surfaceToLight.L ) ).xy;
|
||||
float shadowed = softShadow_filter(shadowMap, ssPos.xy/ssPos.w, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
||||
vec2 shadowCoord = decodeShadowCoord( tMul( worldToLightProj, -surfaceToLight.L ) ).xy;
|
||||
shadow = softShadow_filter(shadowMap, ssPos.xy/ssPos.w, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
||||
#endif
|
||||
|
||||
#endif // !NO_SHADOW
|
||||
}
|
||||
#endif // !NO_SHADOW
|
||||
|
||||
vec3 lightCol = lightColor.rgb;
|
||||
#ifdef USE_COOKIE_TEX
|
||||
|
|
@ -225,7 +218,7 @@ void main()
|
|||
#endif
|
||||
|
||||
//get punctual light contribution
|
||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadowed);
|
||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
|
||||
}
|
||||
|
||||
OUT_col = vec4(lighting, 0);
|
||||
|
|
|
|||
|
|
@ -55,13 +55,6 @@ void main()
|
|||
|
||||
//create surface
|
||||
Surface surface = createSurface(normDepth, colorBuffer, matInfoBuffer, IN_uv0.xy, eyePosWorld, IN_wsEyeRay, cameraToWorld);
|
||||
|
||||
//early out if emissive
|
||||
if (getFlag(surface.matFlag, 0))
|
||||
{
|
||||
OUT_col = vec4(surface.albedo, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_SSAO_MASK
|
||||
float ssao = 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( IN_uv0.xy, rtParams7 ) ).r;
|
||||
|
|
|
|||
|
|
@ -80,13 +80,6 @@ void main()
|
|||
//create surface
|
||||
Surface surface = createSurface( normDepth, colorBuffer,matInfoBuffer,
|
||||
uvScene, eyePosWorld, wsEyeRay, cameraToWorld);
|
||||
|
||||
//early out if emissive
|
||||
if (getFlag(surface.matFlag, 0))
|
||||
{
|
||||
OUT_col = vec4(0, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec3 L = lightPosition - surface.P;
|
||||
float dist = length(L);
|
||||
|
|
@ -96,9 +89,10 @@ void main()
|
|||
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, L);
|
||||
vec3 lightCol = lightColor.rgb;
|
||||
|
||||
#ifdef NO_SHADOW
|
||||
float shadowed = 1.0;
|
||||
#else
|
||||
float shadow = 1.0;
|
||||
#ifndef NO_SHADOW
|
||||
if (getFlag(surface.matFlag, 0)) //also skip if we don't recieve shadows
|
||||
{
|
||||
// Get the shadow texture coordinate
|
||||
vec4 pxlPosLightProj = tMul( worldToLightProj, vec4( surface.P, 1 ) );
|
||||
vec2 shadowCoord = ( ( pxlPosLightProj.xy / pxlPosLightProj.w ) * 0.5 ) + vec2( 0.5, 0.5 );
|
||||
|
|
@ -106,7 +100,7 @@ void main()
|
|||
|
||||
//distance to light in shadow map space
|
||||
float distToLight = pxlPosLightProj.z / lightRange;
|
||||
float shadowed = softShadow_filter(shadowMap, ssPos.xy/ssPos.w, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
||||
shadow = softShadow_filter(shadowMap, ssPos.xy/ssPos.w, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
||||
#ifdef USE_COOKIE_TEX
|
||||
// Lookup the cookie sample.
|
||||
vec4 cookie = texture(cookieMap, shadowCoord);
|
||||
|
|
@ -117,6 +111,7 @@ void main()
|
|||
// regions of the cookie texture.
|
||||
lightCol *= max(cookie.r, max(cookie.g, cookie.b));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -156,7 +151,7 @@ void main()
|
|||
#endif
|
||||
|
||||
//get Punctual light contribution
|
||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadowed);
|
||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
|
||||
//get spot angle attenuation
|
||||
lighting *= getSpotAngleAtt(-surfaceToLight.L, lightDirection, lightSpotParams );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,24 +186,17 @@ void main()
|
|||
//create surface
|
||||
Surface surface = createSurface( normDepth, colorBuffer, matInfoBuffer,
|
||||
uv0, eyePosWorld, wsEyeRay, cameraToWorld);
|
||||
|
||||
//early out if emissive
|
||||
if (getFlag(surface.matFlag, 0))
|
||||
{
|
||||
OUT_col = vec4(0, 0, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//create surface to light
|
||||
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, -lightDirection);
|
||||
|
||||
//light color might be changed by PSSM_DEBUG_RENDER
|
||||
vec3 lightingColor = lightColor.rgb;
|
||||
|
||||
#ifdef NO_SHADOW
|
||||
float shadow = 1.0;
|
||||
#else
|
||||
|
||||
float shadow = 1.0;
|
||||
#ifndef NO_SHADOW
|
||||
if (getFlag(surface.matFlag, 0)) //also skip if we don't recieve shadows
|
||||
{
|
||||
// Fade out the shadow at the end of the range.
|
||||
vec4 zDist = vec4(zNearFarInvNearFar.x + zNearFarInvNearFar.y * surface.depth);
|
||||
float fadeOutAmt = ( zDist.x - fadeStartLength.x ) * fadeStartLength.y;
|
||||
|
|
@ -211,7 +204,7 @@ void main()
|
|||
vec4 shadowed_colors = AL_VectorLightShadowCast( shadowMap, uv0.xy, worldToLightProj, surface.P, scaleX, scaleY, offsetX, offsetY,
|
||||
farPlaneScalePSSM, surfaceToLight.NdotL);
|
||||
|
||||
float shadow = shadowed_colors.a;
|
||||
shadow = shadowed_colors.a;
|
||||
|
||||
#ifdef PSSM_DEBUG_RENDER
|
||||
lightingColor = shadowed_colors.rgb;
|
||||
|
|
@ -223,7 +216,7 @@ void main()
|
|||
if ( fadeOutAmt > 1.0 )
|
||||
lightingColor = vec3(1.0,1.0,1.0);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif //NO_SHADOW
|
||||
|
||||
#ifdef DIFFUSE_LIGHT_VIZ
|
||||
|
|
|
|||
|
|
@ -147,12 +147,6 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|||
Surface surface = createSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
|
||||
uvScene, eyePosWorld, wsEyeRay, cameraToWorld);
|
||||
|
||||
//early out if emissive
|
||||
if (getFlag(surface.matFlag, 0))
|
||||
{
|
||||
return float4(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
float3 L = lightPosition - surface.P;
|
||||
float dist = length(L);
|
||||
float3 lighting = 0.0.xxx;
|
||||
|
|
@ -162,21 +156,21 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|||
float distToLight = dist / lightRange;
|
||||
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, L);
|
||||
|
||||
#ifdef NO_SHADOW
|
||||
float shadowed = 1.0;
|
||||
#else
|
||||
|
||||
float shadow = 1.0;
|
||||
#ifndef NO_SHADOW
|
||||
if (getFlag(surface.matFlag, 0)) //also skip if we don't recieve shadows
|
||||
{
|
||||
#ifdef SHADOW_CUBE
|
||||
|
||||
// TODO: We need to fix shadow cube to handle soft shadows!
|
||||
float occ = TORQUE_TEXCUBE( shadowMap, mul( worldToLightProj, -surfaceToLight.L ) ).r;
|
||||
float shadowed = saturate( exp( lightParams.y * ( occ - distToLight ) ) );
|
||||
shadow = saturate( exp( lightParams.y * ( occ - distToLight ) ) );
|
||||
|
||||
#else
|
||||
float2 shadowCoord = decodeShadowCoord( mul( worldToLightProj, -surfaceToLight.L ) ).xy;
|
||||
float shadowed = softShadow_filter(TORQUE_SAMPLER2D_MAKEARG(shadowMap), ssPos.xy, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
||||
shadow = softShadow_filter(TORQUE_SAMPLER2D_MAKEARG(shadowMap), ssPos.xy, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif // !NO_SHADOW
|
||||
|
||||
float3 lightCol = lightColor.rgb;
|
||||
|
|
@ -221,7 +215,7 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|||
#endif
|
||||
|
||||
//get punctual light contribution
|
||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadowed);
|
||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
|
||||
}
|
||||
|
||||
return float4(lighting, 0);
|
||||
|
|
|
|||
|
|
@ -51,12 +51,6 @@ float4 main(PFXVertToPix IN) : SV_TARGET
|
|||
Surface surface = createSurface(normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
|
||||
IN.uv0.xy, eyePosWorld, IN.wsEyeRay, cameraToWorld);
|
||||
|
||||
//early out if emissive
|
||||
if (getFlag(surface.matFlag, 0))
|
||||
{
|
||||
return float4(surface.albedo, 0);
|
||||
}
|
||||
|
||||
#ifdef USE_SSAO_MASK
|
||||
float ssao = 1.0 - TORQUE_TEX2D( ssaoMask, viewportCoordToRenderTarget( IN.uv0.xy, rtParams7 ) ).r;
|
||||
surface.ao = min(surface.ao, ssao);
|
||||
|
|
|
|||
|
|
@ -86,12 +86,6 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|||
Surface surface = createSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
|
||||
uvScene, eyePosWorld, wsEyeRay, cameraToWorld);
|
||||
|
||||
//early out if emissive
|
||||
if (getFlag(surface.matFlag, 0))
|
||||
{
|
||||
return float4(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
float3 L = lightPosition - surface.P;
|
||||
float dist = length(L);
|
||||
float3 lighting = 0.0.xxx;
|
||||
|
|
@ -100,17 +94,18 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|||
{
|
||||
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, L);
|
||||
float3 lightCol = lightColor.rgb;
|
||||
|
||||
#ifdef NO_SHADOW
|
||||
float shadowed = 1.0;
|
||||
#else
|
||||
|
||||
float shadow = 1.0;
|
||||
#ifndef NO_SHADOW
|
||||
if (getFlag(surface.matFlag, 0)) //also skip if we don't recieve shadows
|
||||
{
|
||||
// Get the shadow texture coordinate
|
||||
float4 pxlPosLightProj = mul( worldToLightProj, float4( surface.P, 1 ) );
|
||||
float2 shadowCoord = ( ( pxlPosLightProj.xy / pxlPosLightProj.w ) * 0.5 ) + float2( 0.5, 0.5 );
|
||||
shadowCoord.y = 1.0f - shadowCoord.y;
|
||||
//distance to light in shadow map space
|
||||
float distToLight = pxlPosLightProj.z / lightRange;
|
||||
float shadowed = softShadow_filter(TORQUE_SAMPLER2D_MAKEARG(shadowMap), ssPos.xy, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
||||
shadow = softShadow_filter(TORQUE_SAMPLER2D_MAKEARG(shadowMap), ssPos.xy, shadowCoord, shadowSoftness, distToLight, surfaceToLight.NdotL, lightParams.y);
|
||||
#ifdef USE_COOKIE_TEX
|
||||
// Lookup the cookie sample.
|
||||
float4 cookie = TORQUE_TEX2D(cookieMap, shadowCoord);
|
||||
|
|
@ -121,6 +116,7 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|||
// regions of the cookie texture.
|
||||
lightCol *= max(cookie.r, max(cookie.g, cookie.b));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DIFFUSE_LIGHT_VIZ
|
||||
|
|
@ -153,7 +149,7 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
|||
#endif
|
||||
|
||||
//get Punctual light contribution
|
||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadowed);
|
||||
lighting = getPunctualLight(surface, surfaceToLight, lightCol, lightBrightness, lightInvSqrRange, shadow);
|
||||
//get spot angle attenuation
|
||||
lighting *= getSpotAngleAtt(-surfaceToLight.L, lightDirection, lightSpotParams );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,23 +176,17 @@ float4 main(FarFrustumQuadConnectP IN) : SV_TARGET
|
|||
//create surface
|
||||
Surface surface = createSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
|
||||
IN.uv0, eyePosWorld, IN.wsEyeRay, cameraToWorld);
|
||||
|
||||
//early out if emissive
|
||||
if (getFlag(surface.matFlag, 0))
|
||||
{
|
||||
return float4(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
//create surface to light
|
||||
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, -lightDirection);
|
||||
|
||||
//light color might be changed by PSSM_DEBUG_RENDER
|
||||
float3 lightingColor = lightColor.rgb;
|
||||
|
||||
#ifdef NO_SHADOW
|
||||
float shadow = 1.0;
|
||||
#else
|
||||
|
||||
float shadow = 1.0;
|
||||
#ifndef NO_SHADOW
|
||||
if (getFlag(surface.matFlag, 0)) //also skip if we don't recieve shadows
|
||||
{
|
||||
// Fade out the shadow at the end of the range.
|
||||
float4 zDist = (zNearFarInvNearFar.x + zNearFarInvNearFar.y * surface.depth);
|
||||
float fadeOutAmt = ( zDist.x - fadeStartLength.x ) * fadeStartLength.y;
|
||||
|
|
@ -200,7 +194,7 @@ float4 main(FarFrustumQuadConnectP IN) : SV_TARGET
|
|||
float4 shadowed_colors = AL_VectorLightShadowCast( TORQUE_SAMPLER2D_MAKEARG(shadowMap), IN.uv0.xy, worldToLightProj, surface.P, scaleX, scaleY, offsetX, offsetY,
|
||||
farPlaneScalePSSM, surfaceToLight.NdotL);
|
||||
|
||||
float shadow = shadowed_colors.a;
|
||||
shadow = shadowed_colors.a;
|
||||
|
||||
#ifdef PSSM_DEBUG_RENDER
|
||||
lightingColor = shadowed_colors.rgb;
|
||||
|
|
@ -212,7 +206,7 @@ float4 main(FarFrustumQuadConnectP IN) : SV_TARGET
|
|||
if ( fadeOutAmt > 1.0 )
|
||||
lightingColor = 1.0;
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif //NO_SHADOW
|
||||
|
||||
#ifdef DIFFUSE_LIGHT_VIZ
|
||||
|
|
|
|||
|
|
@ -3156,7 +3156,7 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) {
|
|||
};
|
||||
new GuiCheckBoxCtrl() {
|
||||
canSaveDynamicFields = "0";
|
||||
internalName = "emissiveCheckbox";
|
||||
internalName = "receiveShadowsCheckbox";
|
||||
Enabled = "1";
|
||||
isContainer = "0";
|
||||
Profile = "ToolsGuiCheckBoxProfile";
|
||||
|
|
@ -3167,11 +3167,11 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) {
|
|||
MinExtent = "8 2";
|
||||
canSave = "1";
|
||||
Visible = "1";
|
||||
Command = "MaterialEditorGui.updateActiveMaterial(\"emissive[\" @ MaterialEditorGui.currentLayer @ \"]\",$ThisControl.getValue());";
|
||||
Command = "MaterialEditorGui.updateActiveMaterial(\"receiveShadows[\" @ MaterialEditorGui.currentLayer @ \"]\",$ThisControl.getValue());";
|
||||
tooltipprofile = "ToolsGuiDefaultProfile";
|
||||
ToolTip = "Emissive causes an object to not be affected by lights. Good for light sources.";
|
||||
ToolTip = "Do we recieve shadows?";
|
||||
hovertime = "1000";
|
||||
text = "Emissive";
|
||||
text = "receiveShadows";
|
||||
groupNum = "-1";
|
||||
buttonType = "ToggleButton";
|
||||
useMouseEvents = "0";
|
||||
|
|
|
|||
|
|
@ -935,7 +935,7 @@ function MaterialEditorGui::guiSync( %this, %material )
|
|||
MaterialEditorPropertiesWindow-->glowMulTextEdit.setText((%material).glowMul[%layer]);
|
||||
MaterialEditorPropertiesWindow-->glowMulSlider.setValue((%material).glowMul[%layer]);
|
||||
MaterialEditorPropertiesWindow-->glowCheckbox.setValue((%material).glow[%layer]);
|
||||
MaterialEditorPropertiesWindow-->emissiveCheckbox.setValue((%material).emissive[%layer]);
|
||||
MaterialEditorPropertiesWindow-->receiveShadowsCheckbox.setValue((%material).receiveShadows[%layer]);
|
||||
MaterialEditorPropertiesWindow-->parallaxTextEdit.setText((%material).parallaxScale[%layer]);
|
||||
MaterialEditorPropertiesWindow-->parallaxSlider.setValue((%material).parallaxScale[%layer]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue