Преглед на файлове

Merge pull request #961 from Azaezel/alpha41/ignorelighting

add an ignoreLighting entry to materials
Brian Roberts преди 2 години
родител
ревизия
aa16c4e23a

+ 4 - 0
Engine/source/materials/materialDefinition.cpp

@@ -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),

+ 1 - 0
Engine/source/materials/materialDefinition.h

@@ -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];

+ 3 - 1
Engine/source/materials/processedShaderMaterial.cpp

@@ -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() )

+ 4 - 0
Templates/BaseGame/game/core/rendering/shaders/gl/lighting.glsl

@@ -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;

+ 4 - 1
Templates/BaseGame/game/core/rendering/shaders/lighting.hlsl

@@ -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++)
    {

+ 5 - 0
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/pointLightP.glsl

@@ -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);

+ 5 - 1
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/reflectionProbeArrayP.glsl

@@ -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);  

+ 5 - 1
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/spotLightP.glsl

@@ -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);

+ 5 - 1
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/gl/vectorLightP.glsl

@@ -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);
 

+ 4 - 1
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/pointLightP.hlsl

@@ -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;

+ 6 - 1
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/reflectionProbeArrayP.hlsl

@@ -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);  

+ 4 - 1
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/spotLightP.hlsl

@@ -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;

+ 4 - 1
Templates/BaseGame/game/core/rendering/shaders/lighting/advanced/vectorLightP.hlsl

@@ -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);
 

+ 23 - 0
Templates/BaseGame/game/tools/materialEditor/gui/guiMaterialPropertiesWindow.ed.gui

@@ -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";

+ 1 - 0
Templates/BaseGame/game/tools/materialEditor/scripts/materialEditor.ed.tscript

@@ -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]);