Browse Source

Remove isAreaLight variable completely from Light class, as it's unused. Some cleanup / comment changes. Fix PBRDeferred GLSL shader.

Lasse Öörni 9 years ago
parent
commit
ade01f61af

+ 0 - 2
Source/Urho3D/AngelScript/GraphicsAPI.cpp

@@ -1220,8 +1220,6 @@ static void RegisterLight(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Light", "float get_length() const", asMETHOD(Light, GetLength), asCALL_THISCALL);
     engine->RegisterObjectMethod("Light", "void set_usePhysicalValues(bool)", asMETHOD(Light, SetUsePhysicalValues), asCALL_THISCALL);
     engine->RegisterObjectMethod("Light", "bool get_usePhysicalValues() const", asMETHOD(Light, GetUsePhysicalValues), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Light", "void set_isAreaLight(bool)", asMETHOD(Light, SetIsAreaLight), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Light", "bool get_isAreaLight() const", asMETHOD(Light, GetIsAreaLight), asCALL_THISCALL);
     engine->RegisterObjectMethod("Light", "void set_specularIntensity(float)", asMETHOD(Light, SetSpecularIntensity), asCALL_THISCALL);
     engine->RegisterObjectMethod("Light", "float get_specularIntensity() const", asMETHOD(Light, GetSpecularIntensity), asCALL_THISCALL);
     engine->RegisterObjectMethod("Light", "void set_brightness(float)", asMETHOD(Light, SetBrightness), asCALL_THISCALL);

+ 0 - 2
Source/Urho3D/Graphics/Batch.cpp

@@ -356,7 +356,6 @@ void Batch::Prepare(View* view, Camera* camera, bool setModelTransform, bool all
                         graphics->SetShaderParameter(VSP_LIGHTMATRICES, lightVecRot.Data(), 16);
 #else
                         graphics->SetShaderParameter(VSP_LIGHTMATRICES, lightVecRot.Data(), 12);
-
 #endif
                     }
                     break;
@@ -376,7 +375,6 @@ void Batch::Prepare(View* view, Camera* camera, bool setModelTransform, bool all
                 light->GetEffectiveSpecularIntensity()) * fade);
             graphics->SetShaderParameter(PSP_LIGHTDIR, lightDir);
             graphics->SetShaderParameter(PSP_LIGHTPOS, lightPos);
-            //graphics->define
             graphics->SetShaderParameter(PSP_LIGHTRAD, light->GetRadius());
             graphics->SetShaderParameter(PSP_LIGHTLENGTH, light->GetLength());
 

+ 1 - 9
Source/Urho3D/Graphics/Light.cpp

@@ -111,8 +111,7 @@ Light::Light(Context* context) :
     shadowNearFarRatio_(DEFAULT_SHADOWNEARFARRATIO),
     shadowMaxExtrusion_(DEFAULT_SHADOWMAXEXTRUSION),
     perVertex_(false),
-    usePhysicalValues_(false),
-    isAreaLight_(false)
+    usePhysicalValues_(false)
 {
 }
 
@@ -132,7 +131,6 @@ void Light::RegisterObject(Context* context)
     URHO3D_ACCESSOR_ATTRIBUTE("Brightness Multiplier", GetBrightness, SetBrightness, float, DEFAULT_BRIGHTNESS, AM_DEFAULT);
     URHO3D_ACCESSOR_ATTRIBUTE("Temperature", GetTemperature, SetTemperature, float, DEFAULT_TEMPERATURE, AM_DEFAULT);
     URHO3D_ATTRIBUTE("Use Physical Values", bool, usePhysicalValues_, false, AM_DEFAULT);
-    //URHO3D_ATTRIBUTE("Is Area Light", bool, isAreaLight_, false, AM_DEFAULT);
     URHO3D_ACCESSOR_ATTRIBUTE("Radius", GetRadius, SetRadius, float, DEFAULT_RADIUS, AM_DEFAULT);
     URHO3D_ACCESSOR_ATTRIBUTE("Length", GetLength, SetLength, float, DEFAULT_LENGTH, AM_DEFAULT);
     URHO3D_ACCESSOR_ATTRIBUTE("Range", GetRange, SetRange, float, DEFAULT_RANGE, AM_DEFAULT);
@@ -330,12 +328,6 @@ void Light::SetUsePhysicalValues(bool enable)
     MarkNetworkUpdate();
 }
 
-void Light::SetIsAreaLight(bool enable)
-{
-    isAreaLight_ = enable;
-    MarkNetworkUpdate();
-}
-
 void Light::SetSpecularIntensity(float intensity)
 {
     specularIntensity_ = Max(intensity, 0.0f);

+ 6 - 13
Source/Urho3D/Graphics/Light.h

@@ -180,14 +180,12 @@ public:
     void SetColor(const Color& color);
     /// Set temperature of the light in Kelvin. Modulates the light color when "use physical values" is enabled.
     void SetTemperature(float temperature);
-    /// Set radius of the light
+    /// Set area light radius. Greater than zero activates area light mode. Works only with PBR shaders.
     void SetRadius(float radius);
-    /// Set length of the light
+    /// Set tube area light length. Works only with PBR shaders.
     void SetLength(float length);
     /// Set use physical light values.
     void SetUsePhysicalValues(bool enable);
-    /// Set light to be an area light
-    void SetIsAreaLight(bool enable);
     /// Set specular intensity. Zero disables specular calculations.
     void SetSpecularIntensity(float intensity);
     /// Set light brightness multiplier. Both the color and specular intensity are multiplied with this. When "use physical values" is enabled, the value is specified in lumens.
@@ -233,18 +231,15 @@ public:
     /// Return the temperature of the light in Kelvin.
     float GetTemperature() const { return temperature_; }
 
-    /// Return the radius of the light
+    /// Return area light mode radius. Works only with PBR shaders.
     float GetRadius() const { return lightRad_; }
 
-    /// Return the length of the light
+    /// Return area tube light length. Works only with PBR shaders.
     float GetLength() const { return lightLength_; }
 
     /// Return if light uses temperature and brightness in lumens.
     bool GetUsePhysicalValues() const { return usePhysicalValues_; }
 
-    /// Return if we are using area lighting
-    bool GetIsAreaLight() const { return isAreaLight_; }
-
     /// Return the color value of the temperature in Kelvin.
     Color GetColorFromTemperature() const;
 
@@ -354,9 +349,9 @@ private:
     Color color_;
     /// Light temperature.
     float temperature_;
-    /// Radius of the light source. If above 0 it will turn the light into an area light.
+    /// Radius of the light source. If above 0 it will turn the light into an area light.  Works only with PBR shaders.
     float lightRad_;
-    /// Length of the light source. If above 0 and radius is above 0 it will create a tube light.
+    /// Length of the light source. If above 0 and radius is above 0 it will create a tube light. Works only with PBR shaders.
     float lightLength_;
     /// Shadow depth bias parameters.
     BiasParameters shadowBias_;
@@ -398,8 +393,6 @@ private:
     bool perVertex_;
     /// Use physical light values flag.
     bool usePhysicalValues_;
-    /// Use Area lighting flag. Currently not used.
-    bool isAreaLight_;
 };
 
 inline bool CompareLights(Light* lhs, Light* rhs)

+ 0 - 3
Source/Urho3D/LuaScript/pkgs/Graphics/Light.pkg

@@ -50,7 +50,6 @@ class Light : public Drawable
     void SetRadius(float redius);
     void SetLength(float length);
     void SetUsePhysicalValues(bool enable);
-    void SetIsAreaLight(bool enable);
     void SetSpecularIntensity(float intensity);
     void SetBrightness(float brightness);
     void SetRange(float range);
@@ -79,7 +78,6 @@ class Light : public Drawable
     Color GetEffectiveColor() const;
     Color GetColorFromTemperature() const;
     bool GetUsePhysicalValues() const;
-    bool GetIsAreaLight() const;
     float GetEffectiveSpecularIntensity() const;
     float GetRange() const;
     float GetFov() const;
@@ -106,7 +104,6 @@ class Light : public Drawable
     tolua_property__get_set float radius;
     tolua_property__get_set float length;
     tolua_property__get_set bool usePhysicalValues;
-    tolua_property__get_set bool isAreaLight;
     tolua_property__get_set float specularIntensity;
     tolua_property__get_set float brightness;
     tolua_property__get_set float range;

+ 2 - 2
bin/CoreData/Shaders/GLSL/PBRDeferred.glsl

@@ -117,9 +117,9 @@ void PS()
 
     float ndl = clamp(abs(dot(normal, lightVec)), M_EPSILON, 1.0);
 
-
     vec3 BRDF = GetBRDF(worldPos, lightDir, lightVec, toCamera, normal, roughness, albedoInput.rgb, specColor);
 
-    finalColor.rgb = BRDF * lightColor * (atten * shadow) / M_PI;
+    gl_FragColor.a = 1.0;
+    gl_FragColor.rgb = BRDF * lightColor * (atten * shadow) / M_PI;
 
 }