-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
105 changed files
with
3,762 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.