Ver código fonte

Fixed sphere light issue

dragonCASTjosh 8 anos atrás
pai
commit
eebc9f04c3

+ 2 - 0
Source/Samples/42_PBRMaterials/PBRMaterials.cpp

@@ -220,6 +220,8 @@ void PBRMaterials::SetupViewport()
     SharedPtr<RenderPath> effectRenderPath = viewport->GetRenderPath()->Clone();
     SharedPtr<RenderPath> effectRenderPath = viewport->GetRenderPath()->Clone();
     effectRenderPath->Append(cache->GetResource<XMLFile>("PostProcess/FXAA2.xml"));
     effectRenderPath->Append(cache->GetResource<XMLFile>("PostProcess/FXAA2.xml"));
     effectRenderPath->Append(cache->GetResource<XMLFile>("PostProcess/GammaCorrection.xml"));
     effectRenderPath->Append(cache->GetResource<XMLFile>("PostProcess/GammaCorrection.xml"));
+	effectRenderPath->Append(cache->GetResource<XMLFile>("PostProcess/Tonemap.xml"));
+	effectRenderPath->Append(cache->GetResource<XMLFile>("PostProcess/AutoExposure.xml"));
 
 
     viewport->SetRenderPath(effectRenderPath);
     viewport->SetRenderPath(effectRenderPath);
 }
 }

+ 10 - 10
bin/CoreData/Shaders/GLSL/PBR.glsl

@@ -63,8 +63,8 @@
 
 
     vec3 TubeLight(vec3 worldPos, vec3 lightVec, vec3 normal, vec3 toCamera, float roughness, vec3 specColor, vec3 diffColor, out float ndl)
     vec3 TubeLight(vec3 worldPos, vec3 lightVec, vec3 normal, vec3 toCamera, float roughness, vec3 specColor, vec3 diffColor, out float ndl)
     {
     {
-        float radius      = cLightRad;
-        float len         = cLightLength; 
+        float radius      = cLightRad / 100;
+        float len         = cLightLength / 10; 
         vec3 pos         = (cLightPosPS.xyz - worldPos);
         vec3 pos         = (cLightPosPS.xyz - worldPos);
         vec3 reflectVec  = reflect(-toCamera, normal);
         vec3 reflectVec  = reflect(-toCamera, normal);
         
         
@@ -92,22 +92,22 @@
         vec3 l = normalize(closestPoint);
         vec3 l = normalize(closestPoint);
         vec3 h = normalize(toCamera + l);
         vec3 h = normalize(toCamera + l);
 
 
-        ndl       =  clamp(dot(normal, lightVec), 0.0, 1.0);
+        ndl       = clamp(dot(normal, lightVec), 0.0, 1.0);
         float hdn = clamp(dot(h, normal), 0.0, 1.0);
         float hdn = clamp(dot(h, normal), 0.0, 1.0);
         float hdv = dot(h, toCamera);
         float hdv = dot(h, toCamera);
-        float ndv = clamp(dot(normal, toCamera), 0.0 ,1.0);
+        float ndv = clamp(dot(normal, toCamera), 0.0, 1.0);
         float hdl = clamp(dot(h, lightVec), 0.0, 1.0);
         float hdl = clamp(dot(h, lightVec), 0.0, 1.0);
 
 
         float distL      = length(closestPoint);
         float distL      = length(closestPoint);
         float alpha      = max(roughness, 0.08) * max(roughness, 0.08);
         float alpha      = max(roughness, 0.08) * max(roughness, 0.08);
         float alphaPrime = clamp(radius / (distL * 2.0) + alpha, 0.0, 1.0);
         float alphaPrime = clamp(radius / (distL * 2.0) + alpha, 0.0, 1.0);
 
 
-       vec3 diffuseFactor = Diffuse(diffColor, roughness, ndv, ndl, hdv)  * ndl;
-       vec3 fresnelTerm = Fresnel(specColor, hdv, hdl) ;
-       float distTerm = Distribution(hdn, roughness);
-       float visTerm = Visibility(ndl, ndv, roughness);
-       vec3 specularFactor = distTerm * visTerm * fresnelTerm * ndl/ M_PI;
-       return diffuseFactor + specularFactor;
+        vec3 diffuseFactor = Diffuse(diffColor, roughness, ndv, ndl, hdv)  * ndl;
+        vec3 fresnelTerm = Fresnel(specColor, hdv, hdl) ;
+        float distTerm = Distribution(hdn, roughness);
+        float visTerm = Visibility(ndl, ndv, roughness);
+        vec3 specularFactor = distTerm * visTerm * fresnelTerm * ndl/ M_PI;
+        return diffuseFactor + specularFactor;
     }
     }
 
 
 	//Return the PBR BRDF value
 	//Return the PBR BRDF value