浏览代码

Fix potential negative specular lighting. Fix recreating the sampler state when a texture has been reloaded.

Lasse Öörni 10 年之前
父节点
当前提交
d7a16d6713

+ 1 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11Texture.cpp

@@ -302,7 +302,7 @@ void Texture::SetParametersDirty()
 
 void Texture::UpdateParameters()
 {
-    if (!parametersDirty_ || !object_)
+    if ((!parametersDirty_ && sampler_) || !object_)
         return;
 
     // Release old sampler

+ 1 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11Texture.h

@@ -99,7 +99,7 @@ public:
     /// Return data size in bytes for a pixel or block row.
     unsigned GetRowDataSize(int width) const;
     /// Return whether the parameters are dirty.
-    bool GetParametersDirty() const { return parametersDirty_; }
+    bool GetParametersDirty() const { return parametersDirty_ || !sampler_; }
 
     /// Set additional parameters from an XML file.
     void SetParameters(XMLFile* xml);

+ 1 - 1
bin/CoreData/Shaders/HLSL/Lighting.hlsl

@@ -115,7 +115,7 @@ float GetDiffuseVolumetric(float3 worldPos)
 float GetSpecular(float3 normal, float3 eyeVec, float3 lightDir, float specularPower)
 {
     float3 halfVec = normalize(normalize(eyeVec) + lightDir);
-    return pow(dot(normal, halfVec), specularPower);
+    return saturate(pow(dot(normal, halfVec), specularPower));
 }
 
 float GetIntensity(float3 color)