Skip to content

Commit

Permalink
Updated coreData
Browse files Browse the repository at this point in the history
  • Loading branch information
gogoprog committed May 24, 2017
1 parent fdaca08 commit 8a0f3ab
Show file tree
Hide file tree
Showing 105 changed files with 3,762 additions and 331 deletions.
5 changes: 4 additions & 1 deletion res/coreData/RenderPaths/Deferred.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<rendertarget name="albedo" sizedivisor="1 1" format="rgba" />
<rendertarget name="normal" sizedivisor="1 1" format="rgba" />
<rendertarget name="depth" sizedivisor="1 1" format="lineardepth" />
<command type="clear" color="1 1 1 1" output="depth" />
<command type="clear" color="fog" depth="1.0" stencil="0" />
<command type="scenepass" pass="deferred" marktostencil="true" vertexlights="true" metadata="gbuffer">
<output index="0" name="viewport" />
Expand All @@ -18,6 +19,8 @@
<command type="scenepass" pass="refract">
<texture unit="environment" name="viewport" />
</command>
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" />
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha">
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postalpha" sort="backtofront" />
</renderpath>
4 changes: 3 additions & 1 deletion res/coreData/RenderPaths/DeferredHWDepth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<command type="scenepass" pass="refract" depthstencil="depth">
<texture unit="environment" name="viewport" />
</command>
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" depthstencil="depth" />
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" depthstencil="depth" psdefines="HWDEPTH">
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postalpha" sort="backtofront" depthstencil="depth" />
</renderpath>
6 changes: 4 additions & 2 deletions res/coreData/RenderPaths/ForwardDepth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
<rendertarget name="depth" sizedivisor="1 1" format="lineardepth" />
<command type="clear" color="1 1 1 1" depth="1.0" stencil="0" output="depth" />
<command type="scenepass" pass="depth" output="depth" />
<command type="clear" color="fog" />
<command type="clear" color="fog" depth="1.0" stencil="0" />
<command type="scenepass" pass="base" vertexlights="true" metadata="base" />
<command type="forwardlights" pass="light" />
<command type="scenepass" pass="postopaque" />
<command type="scenepass" pass="refract">
<texture unit="environment" name="viewport" />
</command>
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" />
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha">
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postalpha" sort="backtofront" />
</renderpath>
8 changes: 4 additions & 4 deletions res/coreData/RenderPaths/ForwardHWDepth.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<renderpath>
<rendertarget name="depth" sizedivisor="1 1" format="readabledepth" />
<command type="clear" depth="1.0" output="depth" />
<command type="scenepass" pass="shadow" output="depth" />
<command type="clear" color="fog" depthstencil="depth" />
<command type="clear" color="fog" depth="1.0" stencil="0" depthstencil="depth" />
<command type="scenepass" pass="base" vertexlights="true" metadata="base" depthstencil="depth" />
<command type="forwardlights" pass="light" depthstencil="depth" />
<command type="scenepass" pass="postopaque" depthstencil="depth" />
<command type="scenepass" pass="refract" depthstencil="depth">
<texture unit="environment" name="viewport" />
</command>
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" depthstencil="depth" />
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" depthstencil="depth" psdefines="HWDEPTH">
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postalpha" sort="backtofront" depthstencil="depth" />
</renderpath>
32 changes: 32 additions & 0 deletions res/coreData/RenderPaths/PBRDeferred.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<renderpath>
<rendertarget name="specular" sizedivisor="1 1" format="rgba16f" />
<rendertarget name="albedo" sizedivisor="1 1" format="rgba16f" />
<rendertarget name="normal" sizedivisor="1 1" format="rgba16f" />
<rendertarget name="depth" sizedivisor="1 1" format="lineardepth" />
<command type="clear" color="0 0 0 0" depth="1.0" stencil="0" />
<command type="clear" color="0 0 0 0" output="albedo" />
<command type="clear" color="0 0 0 0" output="specular" />
<command type="clear" color="0 0 0 0" output="normal" />
<command type="clear" color="0 0 0 0" depth="1.0" output="depth" />
<command type="scenepass" pass="base" vertexlights="true" metadata="base" />
<command type="scenepass" pass="deferred" marktostencil="true" vertexlights="true" metadata="gbuffer">
<output index="0" name="specular" />
<output index="1" name="albedo" />
<output index="2" name="normal" />
<output index="3" name="depth" />
</command>
<command type="lightvolumes" vs="PBRDeferred" ps="PBRDeferred" psdefines="PBRDEFERRED PBR" vsdefines="PBR" output="viewport">
<texture unit="specular" name="specular" />
<texture unit="albedo" name="albedo" />
<texture unit="normal" name="normal" />
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postopaque" />
<command type="scenepass" pass="refract">
<texture unit="environment" name="viewport" />
</command>
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha">
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postalpha" sort="backtofront" />
</renderpath>
31 changes: 31 additions & 0 deletions res/coreData/RenderPaths/PBRDeferredHWDepth.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<renderpath>
<rendertarget name="specular" sizedivisor="1 1" format="rgba16f" />
<rendertarget name="albedo" sizedivisor="1 1" format="rgba16f" />
<rendertarget name="normal" sizedivisor="1 1" format="rgba16f" />
<rendertarget name="depth" sizedivisor="1 1" format="readabledepth" />
<command type="clear" color="0 0 0 0" depth="1.0" stencil="0" depthstencil="depth" />
<command type="clear" color="0 0 0 0" output="albedo" depthstencil="depth"/>
<command type="clear" color="0 0 0 0" output="specular" depthstencil="depth" />
<command type="clear" color="0 0 0 0" output="normal" depthstencil="depth" />
<command type="clear" color="0 0 0 0" depth="1.0" output="depth" depthstencil="depth" />
<command type="scenepass" pass="base" vertexlights="true" metadata="base" depthstencil="depth" />
<command type="scenepass" pass="deferred" marktostencil="true" vertexlights="true" metadata="gbuffer" depthstencil="depth">
<output index="0" name="specular" />
<output index="1" name="albedo" />
<output index="2" name="normal" />
</command>
<command type="lightvolumes" vs="PBRDeferred" ps="PBRDeferred" psdefines="PBRDEFERRED PBR HWDEPTH" vsdefines="PBR" output="viewport" depthstencil="depth">
<texture unit="specular" name="specular" />
<texture unit="albedo" name="albedo" />
<texture unit="normal" name="normal" />
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postopaque" depthstencil="depth"/>
<command type="scenepass" pass="refract" depthstencil="depth">
<texture unit="environment" name="viewport" />
</command>
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" depthstencil="depth" psdefines="HWDEPTH">
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postalpha" sort="backtofront" depthstencil="depth" />
</renderpath>
5 changes: 4 additions & 1 deletion res/coreData/RenderPaths/Prepass.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<rendertarget name="light" sizedivisor="1 1" format="rgba" />
<rendertarget name="normal" sizedivisor="1 1" format="rgba" />
<rendertarget name="depth" sizedivisor="1 1" format="lineardepth" />
<command type="clear" color="1 1 1 1" output="depth" />
<command type="clear" color="fog" depth="1.0" stencil="0" />
<command type="scenepass" pass="prepass" marktostencil="true" metadata="gbuffer">
<output index="0" name="normal" />
Expand All @@ -19,6 +20,8 @@
<command type="scenepass" pass="refract">
<texture unit="environment" name="viewport" />
</command>
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" />
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha">
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postalpha" sort="backtofront" />
</renderpath>
4 changes: 3 additions & 1 deletion res/coreData/RenderPaths/PrepassHWDepth.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<command type="scenepass" pass="refract" depthstencil="depth">
<texture unit="environment" name="viewport" />
</command>
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" depthstencil="depth" />
<command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" depthstencil="depth" psdefines="HWDEPTH">
<texture unit="depth" name="depth" />
</command>
<command type="scenepass" pass="postalpha" sort="backtofront" depthstencil="depth" />
</renderpath>
135 changes: 135 additions & 0 deletions res/coreData/Shaders/GLSL/BRDF.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#line 20001
#ifdef COMPILEPS
#ifdef PBR
// Following BRDF methods are based upon research Frostbite EA
//[Lagrade et al. 2014, "Moving Frostbite to Physically Based Rendering"]

//Schlick Fresnel
//specular = the rgb specular color value of the pixel
//VdotH = the dot product of the camera view direction and the half vector
vec3 SchlickFresnel(vec3 specular, float VdotH)
{
return specular + (vec3(1.0, 1.0, 1.0) - specular) * pow(1.0 - VdotH, 5.0);
}

//Schlick Gaussian Fresnel
//specular = the rgb specular color value of the pixel
//VdotH = the dot product of the camera view direction and the half vector
vec3 SchlickGaussianFresnel(in vec3 specular, in float VdotH)
{
float sphericalGaussian = pow(2.0, (-5.55473 * VdotH - 6.98316) * VdotH);
return specular + (vec3(1.0, 1.0, 1.0) - specular) * sphericalGaussian;
}

//Get Fresnel
//specular = the rgb specular color value of the pixel
//VdotH = the dot product of the camera view direction and the half vector
vec3 Fresnel(vec3 specular, float VdotH)
{
return SchlickFresnel(specular, VdotH);
}

// Smith GGX corrected Visibility
// NdotL = the dot product of the normal and direction to the light
// NdotV = the dot product of the normal and the camera view direction
// roughness = the roughness of the pixel
float SmithGGXSchlickVisibility(float NdotL, float NdotV, float roughness)
{
float rough2 = roughness * roughness;
float lambdaV = NdotL * sqrt((-NdotV * rough2 + NdotV) * NdotV + rough2);
float lambdaL = NdotV * sqrt((-NdotL * rough2 + NdotL) * NdotL + rough2);

return 0.5 / (lambdaV + lambdaL);
}

// Get Visibility
// NdotL = the dot product of the normal and direction to the light
// NdotV = the dot product of the normal and the camera view direction
// roughness = the roughness of the pixel
float Visibility(float NdotL, float NdotV, float roughness)
{
return SmithGGXSchlickVisibility(NdotL, NdotV, roughness);
}

// Blinn Distribution
// NdotH = the dot product of the normal and the half vector
// roughness = the roughness of the pixel
float BlinnPhongDistribution(in float NdotH, in float roughness)
{
float specPower = max((2.0 / (roughness * roughness)) - 2.0, 1e-4); // Calculate specular power from roughness
return pow(clamp(NdotH, 0.0, 1.0), specPower);
}

// Beckmann Distribution
// NdotH = the dot product of the normal and the half vector
// roughness = the roughness of the pixel
float BeckmannDistribution(in float NdotH, in float roughness)
{
float rough2 = roughness * roughness;
float roughnessA = 1.0 / (4.0 * rough2 * pow(NdotH, 4.0));
float roughnessB = NdotH * NdotH - 1.0;
float roughnessC = rough2 * NdotH * NdotH;
return roughnessA * exp(roughnessB / roughnessC);
}

// GGX Distribution
// NdotH = the dot product of the normal and the half vector
// roughness = the roughness of the pixel
float GGXDistribution(float NdotH, float roughness)
{
float rough2 = roughness * roughness;
float tmp = (NdotH * rough2 - NdotH) * NdotH + 1.0;
return rough2 / (tmp * tmp);
}

// Get Distribution
// NdotH = the dot product of the normal and the half vector
// roughness = the roughness of the pixel
float Distribution(float NdotH, float roughness)
{
return GGXDistribution(NdotH, roughness);
}

// Lambertian Diffuse
// diffuseColor = the rgb color value of the pixel
// roughness = the roughness of the pixel
// NdotV = the normal dot with the camera view direction
// NdotL = the normal dot with the light direction
// VdotH = the camera view direction dot with the half vector
vec3 LambertianDiffuse(vec3 diffuseColor, float NdotL)
{
return diffuseColor * NdotL;
}

// Burley Diffuse
// diffuseColor = the rgb color value of the pixel
// roughness = the roughness of the pixel
// NdotV = the normal dot with the camera view direction
// NdotL = the normal dot with the light direction
// VdotH = the camera view direction dot with the half vector
vec3 BurleyDiffuse(vec3 diffuseColor, float roughness, float NdotV, float NdotL, float VdotH)
{
float energyBias = mix(roughness, 0.0, 0.5);
float energyFactor = mix(roughness, 1.0, 1.0 / 1.51);
float fd90 = energyBias + 2.0 * VdotH * VdotH * roughness;
float f0 = 1.0;
float lightScatter = f0 + (fd90 - f0) * pow(1.0 - NdotL, 5.0);
float viewScatter = f0 + (fd90 - f0) * pow(1.0 - NdotV, 5.0);

return diffuseColor * lightScatter * viewScatter * energyFactor;
}

//Get Diffuse
// diffuseColor = the rgb color value of the pixel
// roughness = the roughness of the pixel
// NdotV = the normal dot with the camera view direction
// NdotL = the normal dot with the light direction
// VdotH = the camera view direction dot with the half vector
vec3 Diffuse(vec3 diffuseColor, float roughness, float NdotV, float NdotL, float VdotH)
{
//return LambertianDiffuse(diffuseColor, NdotL);
return BurleyDiffuse(diffuseColor, roughness, NdotV, NdotL, VdotH);
}

#endif
#endif
7 changes: 7 additions & 0 deletions res/coreData/Shaders/GLSL/Constants.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#define M_PI 3.14159265358979323846
#define M_EPSILON 0.0001

#ifdef PBR
#define ROUGHNESS_FLOOR 0.003
#define METALNESS_FLOOR 0.03
#endif
8 changes: 6 additions & 2 deletions res/coreData/Shaders/GLSL/DeferredLight.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ void PS()
vec4 normalInput = texture2DProj(sNormalBuffer, vScreenPos);
#endif

// Position acquired via near/far ray is relative to camera. Bring position to world space
vec3 eyeVec = -worldPos;
worldPos += cCameraPosPS;

vec3 normal = normalize(normalInput.rgb * 2.0 - 1.0);
vec4 projWorldPos = vec4(worldPos, 1.0);
vec3 lightColor;
Expand All @@ -74,7 +78,7 @@ void PS()
float diff = GetDiffuse(normal, worldPos, lightDir);

#ifdef SHADOW
diff *= GetShadowDeferred(projWorldPos, depth);
diff *= GetShadowDeferred(projWorldPos, normal, depth);
#endif

#if defined(SPOTLIGHT)
Expand All @@ -88,7 +92,7 @@ void PS()
#endif

#ifdef SPECULAR
float spec = GetSpecular(normal, -worldPos, lightDir, normalInput.a * 255.0);
float spec = GetSpecular(normal, eyeVec, lightDir, normalInput.a * 255.0);
gl_FragColor = diff * vec4(lightColor * (albedoInput.rgb + spec * cLightColor.a * albedoInput.aaa), 0.0);
#else
gl_FragColor = diff * vec4(lightColor * albedoInput.rgb, 0.0);
Expand Down
Loading

0 comments on commit 8a0f3ab

Please sign in to comment.