ソースを参照

Re-ordered the deferred g-buffer to allow GL3 to receive the material roughness.

hdunderscore 9 年 前
コミット
310252fa25

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

@@ -73,11 +73,11 @@ void PS()
         vec4 specularInput = texture2DProj(sSpecMap, vScreenPos);
         vec4 specularInput = texture2DProj(sSpecMap, vScreenPos);
     #endif
     #endif
 
 
-    vec3 normal = normalize(normalInput.rgb);
-    float roughness = depthInput.a;//length(normal);
-    //normal = normalize(normal);
+    vec3 normal = normalInput.rgb;
+    float roughness = length(normal);
+    normal = normalize(normal);
 
 
-    vec3 specColor = vec3(specularInput.a, albedoInput.a, normalInput.a);
+    vec3 specColor = specularInput.rgb;
 
 
     vec4 projWorldPos = vec4(worldPos, 1.0);
     vec4 projWorldPos = vec4(worldPos, 1.0);
 
 

+ 5 - 5
bin/CoreData/Shaders/GLSL/PBRLitSolid.glsl

@@ -207,12 +207,12 @@ void PS()
             gl_FragColor = vec4(GetLitFog(finalColor, fogFactor), diffColor.a);
             gl_FragColor = vec4(GetLitFog(finalColor, fogFactor), diffColor.a);
         #endif
         #endif
     #elif defined(DEFERRED)
     #elif defined(DEFERRED)
-        // Fill deferred G-buffer'
+        // Fill deferred G-buffer
         const vec3 spareData = vec3(0,0,0); // Can be used to pass more data to deferred renderer
         const vec3 spareData = vec3(0,0,0); // Can be used to pass more data to deferred renderer
-        gl_FragData[0] = vec4(spareData, specColor.r);
-        gl_FragData[1] = vec4(diffColor.rgb, specColor.g);
-        gl_FragData[2] = vec4(normal, specColor.b);
-        gl_FragData[3] = vec4(EncodeDepth(vWorldPos.w), roughness);
+        gl_FragData[0] = vec4(specColor, spareData.r);
+        gl_FragData[1] = vec4(diffColor.rgb, spareData.g);
+        gl_FragData[2] = vec4(normal * roughness, spareData.b);
+        gl_FragData[3] = vec4(EncodeDepth(vWorldPos.w), 0);
     #else
     #else
         // Ambient & per-vertex lighting
         // Ambient & per-vertex lighting
         vec3 finalColor = vVertexLight * diffColor.rgb;
         vec3 finalColor = vVertexLight * diffColor.rgb;

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

@@ -84,7 +84,7 @@ void PS(
     const float roughness = length(normal);
     const float roughness = length(normal);
     normal = normalize(normal);
     normal = normalize(normal);
 
 
-    const float3 specColor = float3(specularInput.a, albedoInput.a, normalInput.a);
+    const float3 specColor = specularInput.rgb;
 
 
     const float4 projWorldPos = float4(worldPos, 1.0);
     const float4 projWorldPos = float4(worldPos, 1.0);
 
 

+ 3 - 3
bin/CoreData/Shaders/HLSL/PBRLitSolid.hlsl

@@ -294,9 +294,9 @@ void PS(
     #elif defined(DEFERRED)
     #elif defined(DEFERRED)
         // Fill deferred G-buffer
         // Fill deferred G-buffer
         const float3 spareData = 0; // Can be used to pass more data to deferred renderer
         const float3 spareData = 0; // Can be used to pass more data to deferred renderer
-        oColor = float4(spareData, specColor.r);
-        oAlbedo = float4(diffColor.rgb, specColor.g);
-        oNormal = float4(normalize(normal) * roughness, specColor.b);
+        oColor = float4(specColor, spareData.r);
+        oAlbedo = float4(diffColor.rgb, spareData.g);
+        oNormal = float4(normalize(normal) * roughness, spareData.b);
         oDepth = iWorldPos.w;
         oDepth = iWorldPos.w;
     #else
     #else
         // Ambient & per-vertex lighting
         // Ambient & per-vertex lighting