-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* render graph 1st iteration * fixed running on integrated GPU * basic deferred shading * ajusted config for integrated gpu * fixed present mode * cleanup shader * deleted dead code * fixed the skybox implementation
- Loading branch information
1 parent
6354a35
commit ba4cafb
Showing
52 changed files
with
2,121 additions
and
1,093 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
#version 460 | ||
#extension GL_GOOGLE_include_directive : require | ||
#include "vertex_common.glsl" | ||
|
||
void main() | ||
{ | ||
DrawVertex v = FetchVertexData(); | ||
|
||
mat4 model = TransformBuffer.Data[gl_BaseInstance]; | ||
vec4 worldPosition = model * vec4(v.x, v.y, v.z, 1.0); | ||
gl_Position = Camera.Projection * Camera.View * worldPosition; | ||
} |
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,85 @@ | ||
#extension GL_EXT_nonuniform_qualifier : require | ||
#extension GL_EXT_shader_explicit_arithmetic_types_int64: enable | ||
|
||
struct MaterialData | ||
{ | ||
vec4 AmbientColor; | ||
vec4 EmissiveColor; | ||
vec4 AlbedoColor; | ||
vec4 DiffuseColor; | ||
vec4 RoughnessColor; | ||
|
||
float TransparencyFactor; | ||
float MetallicFactor; | ||
float AlphaTest; | ||
|
||
uint64_t EmissiveTextureMap; | ||
uint64_t AlbedoTextureMap; | ||
uint64_t NormalTextureMap; | ||
uint64_t OpacityTextureMap; | ||
}; | ||
|
||
// http://www.thetenthplanet.de/archives/1180 | ||
// modified to fix handedness of the resulting cotangent frame | ||
mat3 cotangentFrame( vec3 N, vec3 p, vec2 uv ) | ||
{ | ||
// get edge vectors of the pixel triangle | ||
vec3 dp1 = dFdx( p ); | ||
vec3 dp2 = dFdy( p ); | ||
vec2 duv1 = dFdx( uv ); | ||
vec2 duv2 = dFdy( uv ); | ||
|
||
// solve the linear system | ||
vec3 dp2perp = cross( dp2, N ); | ||
vec3 dp1perp = cross( N, dp1 ); | ||
vec3 T = dp2perp * duv1.x + dp1perp * duv2.x; | ||
vec3 B = dp2perp * duv1.y + dp1perp * duv2.y; | ||
|
||
// construct a scale-invariant frame | ||
float invmax = inversesqrt( max( dot(T,T), dot(B,B) ) ); | ||
|
||
// calculate handedness of the resulting cotangent frame | ||
float w = (dot(cross(N, T), B) < 0.0) ? -1.0 : 1.0; | ||
|
||
// adjust tangent if needed | ||
T = T * w; | ||
|
||
return mat3( T * invmax, B * invmax, N ); | ||
} | ||
|
||
vec3 perturbNormal(vec3 n, vec3 v, vec3 normalSample, vec2 uv) | ||
{ | ||
vec3 map = normalize( 2.0 * normalSample - vec3(1.0) ); | ||
mat3 TBN = cotangentFrame(n, v, uv); | ||
return normalize(TBN * map); | ||
} | ||
|
||
void runAlphaTest(float alpha, float alphaThreshold) | ||
{ | ||
if (alphaThreshold > 0.0) | ||
{ | ||
// http://alex-charlton.com/posts/Dithering_on_the_GPU/ | ||
// https://forums.khronos.org/showthread.php/5091-screen-door-transparency | ||
mat4 thresholdMatrix = mat4( | ||
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0, | ||
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0, | ||
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0, | ||
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0 | ||
); | ||
|
||
alpha = clamp(alpha - 0.5 * thresholdMatrix[int(mod(gl_FragCoord.x, 4.0))][int(mod(gl_FragCoord.y, 4.0))], 0.0, 1.0); | ||
|
||
if (alpha < alphaThreshold) | ||
discard; | ||
} | ||
} | ||
|
||
#define INVALID_TEXTURE_INDEX 0xFFFFFFFFu | ||
|
||
layout(set = 0, binding = 5) readonly buffer MatSB { MaterialData Data[]; } MaterialDataBuffer; | ||
layout(set = 0, binding = 9) uniform sampler2D TextureArray[]; | ||
|
||
MaterialData FetchMaterial(uint dataIndex) | ||
{ | ||
return MaterialDataBuffer.Data[dataIndex]; | ||
} |
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,28 @@ | ||
#version 460 | ||
#extension GL_GOOGLE_include_directive : require | ||
#include "fragment_common.glsl" | ||
|
||
layout (location = 0) in vec3 FragmentPosition; | ||
layout (location = 1) in vec3 WorldNormal; | ||
layout (location = 2) in vec2 TextureCoord; | ||
layout (location = 3) in flat uint MaterialIdx; | ||
|
||
layout (location = 0) out vec4 OutAlbedoColor; | ||
layout (location = 1) out vec4 OutSpecular; | ||
layout (location = 2) out vec3 OutNormal; | ||
layout (location = 3) out vec3 OutPosition; | ||
|
||
void main() | ||
{ | ||
MaterialData material = FetchMaterial(MaterialIdx); | ||
|
||
OutNormal = normalize(WorldNormal); | ||
OutPosition = FragmentPosition; | ||
OutSpecular = vec4(1.0); | ||
|
||
if (material.AlbedoTextureMap < INVALID_TEXTURE_INDEX) | ||
{ | ||
uint texId = uint(material.AlbedoTextureMap); | ||
OutAlbedoColor = texture( TextureArray[nonuniformEXT(texId)], TextureCoord); | ||
} | ||
} |
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,26 @@ | ||
#version 460 | ||
#extension GL_GOOGLE_include_directive : require | ||
#include "vertex_common.glsl" | ||
|
||
|
||
layout (location = 0) out vec3 FragmentPosition; | ||
layout (location = 1) out vec3 WorldNormal; | ||
layout (location = 2) out vec2 TextureCoord; | ||
layout (location = 3) out flat uint MaterialIdx; | ||
layout (location = 4) out vec4 ViewPosition; | ||
|
||
void main() | ||
{ | ||
DrawVertex v = FetchVertexData(); | ||
mat4 model = FetchTransform(); | ||
|
||
vec4 worldPosition = model * vec4(v.x, v.y, v.z, 1.0); | ||
FragmentPosition = worldPosition.xyz; | ||
|
||
WorldNormal = transpose(inverse(mat3(model))) * vec3(v.nx, v.ny, v.nz); | ||
TextureCoord = vec2(v.u, v.v); | ||
MaterialIdx = DrawDataBuffer.Data[gl_BaseInstance].MaterialIndex; | ||
ViewPosition = Camera.Position; | ||
|
||
gl_Position = Camera.Projection * Camera.View * worldPosition; | ||
} |
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
File renamed without changes.
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,14 @@ | ||
#version 460 | ||
#extension GL_GOOGLE_include_directive : require | ||
#include "vertex_common.glsl" | ||
|
||
layout (location = 0) out vec3 dir; | ||
|
||
void main() | ||
{ | ||
DrawVertex v = FetchVertexData(); | ||
|
||
dir = vec3(v.x, -v.y, v.z); | ||
vec4 position = Camera.Projection * Camera.RotScaleView * vec4(v.x, v.y, v.z, 1.0f); | ||
gl_Position = position.xyww; | ||
} |
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.