Merge pull request #961 from Azaezel/alpha41/ignorelighting

add an ignoreLighting entry to materials
This commit is contained in:
Brian Roberts 2023-02-15 14:37:24 -06:00 committed by GitHub
commit aa16c4e23a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 78 additions and 9 deletions

View file

@ -162,6 +162,7 @@ Material::Material()
mGlow[i] = false;
mReceiveShadows[i] = true;
mIgnoreLighting[i] = false;
mDetailScale[i].set(2.0f, 2.0f);
@ -347,6 +348,9 @@ void Material::initPersistFields()
"The 0 to 1 rolloff factor used in the subsurface scattering approximation.");
addField("receiveShadows", TypeBool, Offset(mReceiveShadows, Material), MAX_STAGES,
"Shadows being cast onto the material.");
addField("ignoreLighting", TypeBool, Offset(mIgnoreLighting, Material), MAX_STAGES,
"Enables emissive lighting for the material.");
addField("doubleSided", TypeBool, Offset(mDoubleSided, Material),

View file

@ -306,6 +306,7 @@ public:
bool mGlow[MAX_STAGES]; // entire stage glows
bool mReceiveShadows[MAX_STAGES];
bool mIgnoreLighting[MAX_STAGES];
Point2I mCellIndex[MAX_STAGES];
Point2I mCellLayout[MAX_STAGES];

View file

@ -1200,7 +1200,9 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
// Deferred Shading: Determine Material Info Flags
S32 matInfoFlags =
(mMaterial->mReceiveShadows[stageNum] ? 1 : 0) | //ReceiveShadows
(mMaterial->mSubSurface[stageNum] ? 1 << 2 : 0); //subsurface
(mMaterial->mSubSurface[stageNum] ? 1 << 2 : 0)| //subsurface
(mMaterial->mIgnoreLighting[stageNum] ? 1 << 3 : 0); //IgnoreLighting
mMaterial->mMatInfoFlags[stageNum] = matInfoFlags / 255.0f;
shaderConsts->setSafe(handles->mMatInfoFlagsSC, mMaterial->mMatInfoFlags[stageNum]);
if( handles->mAccuScaleSC->isValid() )

View file

@ -276,6 +276,10 @@ vec4 compute4Lights( Surface surface,
vec4 vectorLightingColor,
float vectorLightBrightness )
{
if (getFlag(surface.matFlag, 2))
{
return surface.baseColor;
}
vec3 finalLighting = vec3(0.0f);
int i;

View file

@ -277,8 +277,11 @@ float4 compute4Lights( Surface surface,
float4 vectorLightingColor,
float vectorLightBrightness )
{
if (getFlag(surface.matFlag, 2))
{
return surface.baseColor;
}
float3 finalLighting = 0.0.xxx;
int i;
for(i = 0; i < MAX_FORWARD_LIGHT; i++)
{

View file

@ -147,6 +147,11 @@ void main()
Surface surface = createSurface( normDepth, colorBuffer, matInfoBuffer,
uvScene, eyePosWorld, wsEyeRay, cameraToWorld);
if (getFlag(surface.matFlag, 2))
{
OUT_col = surface.baseColor;
return;
}
vec3 L = lightPosition - surface.P;
float dist = length(L);
vec3 lighting = vec3(0.0);

View file

@ -55,7 +55,11 @@ void main()
//create surface
Surface surface = createSurface(normDepth, colorBuffer, matInfoBuffer, IN_uv0.xy, eyePosWorld, IN_wsEyeRay, cameraToWorld);
if (getFlag(surface.matFlag, 2))
{
OUT_col = surface.baseColor;
return;
}
#ifdef USE_SSAO_MASK
float ssao = 1.0 - texture( ssaoMask, viewportCoordToRenderTarget( IN_uv0.xy, rtParams7 ) ).r;
surface.ao = min(surface.ao, ssao);

View file

@ -80,7 +80,11 @@ void main()
//create surface
Surface surface = createSurface( normDepth, colorBuffer,matInfoBuffer,
uvScene, eyePosWorld, wsEyeRay, cameraToWorld);
if (getFlag(surface.matFlag, 2))
{
OUT_col = surface.baseColor;
return;
}
vec3 L = lightPosition - surface.P;
float dist = length(L);
vec3 lighting = vec3(0.0);

View file

@ -186,7 +186,11 @@ void main()
//create surface
Surface surface = createSurface( normDepth, colorBuffer, matInfoBuffer,
uv0, eyePosWorld, wsEyeRay, cameraToWorld);
if (getFlag(surface.matFlag, 2))
{
OUT_col = surface.baseColor;
return;
}
//create surface to light
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, -lightDirection);

View file

@ -146,7 +146,10 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
//create surface
Surface surface = createSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
uvScene, eyePosWorld, wsEyeRay, cameraToWorld);
if (getFlag(surface.matFlag, 2))
{
return surface.baseColor;
}
float3 L = lightPosition - surface.P;
float dist = length(L);
float3 lighting = 0.0.xxx;

View file

@ -50,7 +50,12 @@ float4 main(PFXVertToPix IN) : SV_TARGET
//create surface
Surface surface = createSurface(normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
IN.uv0.xy, eyePosWorld, IN.wsEyeRay, cameraToWorld);
if (getFlag(surface.matFlag, 2))
{
return surface.baseColor;
}
#ifdef USE_SSAO_MASK
float ssao = 1.0 - TORQUE_TEX2D( ssaoMask, viewportCoordToRenderTarget( IN.uv0.xy, rtParams7 ) ).r;
surface.ao = min(surface.ao, ssao);

View file

@ -85,7 +85,10 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
//create surface
Surface surface = createSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
uvScene, eyePosWorld, wsEyeRay, cameraToWorld);
if (getFlag(surface.matFlag, 2))
{
return surface.baseColor;
}
float3 L = lightPosition - surface.P;
float dist = length(L);
float3 lighting = 0.0.xxx;

View file

@ -176,7 +176,10 @@ 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);
if (getFlag(surface.matFlag, 2))
{
return surface.baseColor;
}
//create surface to light
SurfaceToLight surfaceToLight = createSurfaceToLight(surface, -lightDirection);

View file

@ -3177,6 +3177,29 @@ $guiContent = new GuiControl(MaterialEditorGui,EditorGuiGroup) {
useMouseEvents = "0";
useInactiveState = "0";
};
new GuiCheckBoxCtrl() {
canSaveDynamicFields = "0";
internalName = "ignoreLightingCheckbox";
Enabled = "1";
isContainer = "0";
Profile = "ToolsGuiCheckBoxProfile";
HorizSizing = "right";
VertSizing = "bottom";
position = "116 4";
Extent = "60 16";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "MaterialEditorGui.updateActiveMaterial(\"ignoreLighting[\" @ MaterialEditorGui.currentLayer @ \"]\",$ThisControl.getValue());";
tooltipprofile = "ToolsGuiDefaultProfile";
ToolTip = "Are we at all influenced by light?";
hovertime = "1000";
text = "ignoreLight";
groupNum = "-1";
buttonType = "ToggleButton";
useMouseEvents = "0";
useInactiveState = "0";
};
};
new GuiContainer(){ // parallax
profile = "ToolsGuiTransparentProfile";

View file

@ -936,6 +936,7 @@ function MaterialEditorGui::guiSync( %this, %material )
MaterialEditorPropertiesWindow-->glowMulSlider.setValue((%material).glowMul[%layer]);
MaterialEditorPropertiesWindow-->glowCheckbox.setValue((%material).glow[%layer]);
MaterialEditorPropertiesWindow-->receiveShadowsCheckbox.setValue((%material).receiveShadows[%layer]);
MaterialEditorPropertiesWindow-->ignoreLightingCheckbox.setValue((%material).ignoreLighting[%layer]);
MaterialEditorPropertiesWindow-->parallaxTextEdit.setText((%material).parallaxScale[%layer]);
MaterialEditorPropertiesWindow-->parallaxSlider.setValue((%material).parallaxScale[%layer]);