Graphics/DeferredRenderTechnique: Optimize Deferred Shading
No longer copies depth twice Former-commit-id: aa2096ade409861b773bc7302ced27ae84fab858 [formerly 80fd00bd4a75506b128b70a545eb43ff6a3a7071] [formerly d8576a8858caca9314ea67661af0ce7d9077ba9d [formerly e626f2fd62d19ca5f952485478bfe46f4a803227]] Former-commit-id: 363c93e397887e66b25446927bc5ef89e761c488 [formerly a8bee284456d7f46d182ae7df2d565fa29e55b61] Former-commit-id: 168792d853247ada5add8f97057c213af7c801b3
This commit is contained in:
@@ -11,17 +11,12 @@ uniform vec4 LightDirection;
|
||||
uniform sampler2D GBuffer0;
|
||||
uniform sampler2D GBuffer1;
|
||||
uniform sampler2D GBuffer2;
|
||||
uniform sampler2D DepthBuffer;
|
||||
|
||||
uniform mat4 InvViewProjMatrix;
|
||||
uniform vec2 InvTargetSize;
|
||||
uniform vec4 SceneAmbient;
|
||||
|
||||
float ColorToFloat(vec3 color)
|
||||
{
|
||||
const vec3 byte_to_float = vec3(1.0, 1.0/256, 1.0/(256*256));
|
||||
return dot(color, byte_to_float);
|
||||
}
|
||||
|
||||
#define kPI 3.1415926536
|
||||
|
||||
vec3 DecodeNormal(in vec4 encodedNormal)
|
||||
@@ -44,7 +39,7 @@ void main()
|
||||
vec3 diffuseColor = gVec0.xyz;
|
||||
vec3 normal = DecodeNormal(gVec1);
|
||||
float specularMultiplier = gVec0.w;
|
||||
float depth = ColorToFloat(gVec2.xyz);
|
||||
float depth = textureLod(DepthBuffer, texCoord, 0.0).r;
|
||||
float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5);
|
||||
|
||||
vec3 lightDir = -LightDirection.xyz;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -19,6 +19,7 @@ uniform vec2 LightParameters3;
|
||||
uniform sampler2D GBuffer0;
|
||||
uniform sampler2D GBuffer1;
|
||||
uniform sampler2D GBuffer2;
|
||||
uniform sampler2D DepthBuffer;
|
||||
|
||||
uniform mat4 InvViewProjMatrix;
|
||||
uniform vec2 InvTargetSize;
|
||||
@@ -57,7 +58,7 @@ void main()
|
||||
vec3 diffuseColor = gVec0.xyz;
|
||||
vec3 normal = DecodeNormal(gVec1);
|
||||
float specularMultiplier = gVec0.w;
|
||||
float depth = ColorToFloat(gVec2.xyz);
|
||||
float depth = textureLod(DepthBuffer, texCoord, 0.0).r;
|
||||
float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5);
|
||||
|
||||
vec3 viewSpace = vec3(texCoord*2.0 - 1.0, depth*2.0 - 1.0);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -68,21 +68,6 @@ uniform vec4 SceneAmbient;
|
||||
uniform sampler2D TextureOverlay;
|
||||
|
||||
/********************Fonctions********************/
|
||||
vec3 FloatToColor(float f)
|
||||
{
|
||||
vec3 color;
|
||||
|
||||
f *= 256.0;
|
||||
color.x = floor(f);
|
||||
|
||||
f = (f - color.x) * 256.0;
|
||||
color.y = floor(f);
|
||||
|
||||
color.z = f - color.y;
|
||||
color.xy *= 0.00390625; // *= 1.0/256
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
#define kPI 3.1415926536
|
||||
|
||||
@@ -184,7 +169,7 @@ void main()
|
||||
*/
|
||||
RenderTarget0 = vec4(diffuseColor.rgb, dot(specularColor, vec3(0.3, 0.59, 0.11)));
|
||||
RenderTarget1 = vec4(EncodeNormal(normal));
|
||||
RenderTarget2 = vec4(FloatToColor(gl_FragCoord.z), (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
|
||||
RenderTarget2 = vec4(0.0, 0.0, 0.0, (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
|
||||
#else // FLAG_DEFERRED
|
||||
#if ALPHA_MAPPING
|
||||
diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r;
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user