Skip to content

Commit

Permalink
Fixed a few issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tippesi committed Jan 26, 2024
1 parent 8d04983 commit 377d0bd
Show file tree
Hide file tree
Showing 50 changed files with 164 additions and 160 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
uses: friendlyanon/setup-vcpkg@v1
# Committish: The commit sha of the vcpkg repo, same as in vcpkg.json
with:
committish: 6c937c32233bdf295ab2140dbce97fd00084a5f3
committish: 5786fcb0cb5eb08d1931a230dad9701e7a6c37f0
cache: ${{ env.USE_CACHE }}

# This doesn't work when the Visual Studio C++ CLI was set up first (maybe needs a setup with 2019 version)
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
uses: friendlyanon/setup-vcpkg@v1
# Committish: The commit sha of the vcpkg repo, same as in vcpkg.json
with:
committish: 6c937c32233bdf295ab2140dbce97fd00084a5f3
committish: 5786fcb0cb5eb08d1931a230dad9701e7a6c37f0
cache: ${{ env.USE_CACHE }}

- name: Setup Ninja
Expand Down Expand Up @@ -310,7 +310,7 @@ jobs:
uses: friendlyanon/setup-vcpkg@v1
# Committish: The commit sha of the vcpkg repo, same as in vcpkg.json
with:
committish: 6c937c32233bdf295ab2140dbce97fd00084a5f3
committish: 5786fcb0cb5eb08d1931a230dad9701e7a6c37f0
cache: ${{ env.USE_CACHE }}

- name: Setup Ninja
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: friendlyanon/setup-vcpkg@v1
# Committish: The commit sha of the vcpkg repo, same as in vcpkg.json
with:
committish: 6c937c32233bdf295ab2140dbce97fd00084a5f3
committish: 5786fcb0cb5eb08d1931a230dad9701e7a6c37f0

- name: Setup Microsoft Visual C++ CLI
uses: ilammy/msvc-dev-cmd@v1
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
uses: friendlyanon/setup-vcpkg@v1
# Committish: The commit sha of the vcpkg repo, same as in vcpkg.json
with:
committish: 6c937c32233bdf295ab2140dbce97fd00084a5f3
committish: 5786fcb0cb5eb08d1931a230dad9701e7a6c37f0

- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master
Expand Down
4 changes: 2 additions & 2 deletions data/shader/ao/rtao.csh
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ void main() {
ivec2 offset = offsets[offsetIdx];

vec2 recontructTexCoord = (2.0 * vec2(pixel) + offset + vec2(0.5)) / (2.0 * vec2(resolution));
vec3 worldPos = vec3(globalData[0].ivMatrix * vec4(ConvertDepthToViewSpace(depth, recontructTexCoord), 1.0));
vec3 worldNorm = normalize(vec3(globalData[0].ivMatrix * vec4(DecodeNormal(textureLod(normalTexture, texCoord, 0).rg), 0.0)));
vec3 worldPos = vec3(globalData.ivMatrix * vec4(ConvertDepthToViewSpace(depth, recontructTexCoord), 1.0));
vec3 worldNorm = normalize(vec3(globalData.ivMatrix * vec4(DecodeNormal(textureLod(normalTexture, texCoord, 0).rg), 0.0)));

float ao = 0.0;

Expand Down
2 changes: 1 addition & 1 deletion data/shader/ao/ssao.csh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void main() {

// project sample position (to sample texture) (to get position on screen/texture)
vec4 offset = vec4(ssaoSample, 1.0);
offset = globalData[0].pMatrix * offset; // from view to clip-space
offset = globalData.pMatrix * offset; // from view to clip-space
offset.xyz /= offset.w; // perspective divide
offset.xyz = offset.xyz * 0.5 + 0.5; // transform to range 0.0 - 1.0

Expand Down
8 changes: 4 additions & 4 deletions data/shader/atmosphere.csh
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ void main() {
#ifndef ENVIRONMENT_PROBE
// Calculate velocity
vec3 ndcCurrent = (globalData[0].pMatrix * vec4(viewPos, 1.0)).xyw;
vec3 ndcLast = (globalData[0].pvMatrixLast * vec4(worldPos, 1.0)).xyw;
vec3 ndcCurrent = (globalData.pMatrix * vec4(viewPos, 1.0)).xyw;
vec3 ndcLast = (globalData.pvMatrixLast * vec4(worldPos, 1.0)).xyw;
vec2 ndcL = ndcLast.xy / ndcLast.z;
vec2 ndcC = ndcCurrent.xy / ndcCurrent.z;
ndcL -= globalData[0].jitterLast;
ndcC -= globalData[0].jitterCurrent;
ndcL -= globalData.jitterLast;
ndcC -= globalData.jitterCurrent;
vec2 velocity = (ndcL - ndcC) * 0.5;
Expand Down
4 changes: 2 additions & 2 deletions data/shader/clouds/integrate.csh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void main() {

vec4 ComputeVolumetricClouds(vec3 fragPos, float depth) {

vec3 rayDirection = normalize(vec3(globalData[0].ivMatrix * vec4(fragPos, 0.0)));
vec3 rayOrigin = globalData[0].cameraLocation.xyz;
vec3 rayDirection = normalize(vec3(globalData.ivMatrix * vec4(fragPos, 0.0)));
vec3 rayOrigin = globalData.cameraLocation.xyz;

float inDist, outDist;
CalculateRayLength(rayOrigin, rayDirection, inDist, outDist);
Expand Down
4 changes: 2 additions & 2 deletions data/shader/common/convert.hsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

vec3 ConvertDepthToViewSpace(float depth, vec2 texcoords) {

vec4 viewSpace = globalData[0].ipMatrix * vec4(texcoords * 2.0 - 1.0, depth, 1.0);
vec4 viewSpace = globalData.ipMatrix * vec4(texcoords * 2.0 - 1.0, depth, 1.0);
return viewSpace.xyz / viewSpace.w;

}

float ConvertDepthToViewSpaceDepth(float depth) {

vec2 viewSpace = (globalData[0].ipMatrix * vec4(0.0, 0.0, depth, 1.0)).zw;
vec2 viewSpace = (globalData.ipMatrix * vec4(0.0, 0.0, depth, 1.0)).zw;
return viewSpace.x / viewSpace.y;

}
Expand Down
2 changes: 1 addition & 1 deletion data/shader/common/ign.hsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// https://blog.demofox.org/2022/01/01/interleaved-gradient-noise-a-different-kind-of-low-discrepancy-sequence/
float GetInterleavedGradientNoise(vec2 screenPos) {
uint frame = globalData[0].frameCount % 64u;
uint frame = globalData.frameCount % 64u;
float x = float(screenPos.x) + 5.588238 * float(frame);
float y = float(screenPos.y) + 5.588238 * float(frame);

Expand Down
4 changes: 2 additions & 2 deletions data/shader/ddgi/probeDebug.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ void main() {
vec2 ndcL = ndcLastVS.xy / ndcLastVS.z;
vec2 ndcC = ndcCurrentVS.xy / ndcCurrentVS.z;

ndcL -= globalData[0].jitterLast;
ndcC -= globalData[0].jitterCurrent;
ndcL -= globalData.jitterLast;
ndcC -= globalData.jitterCurrent;

velocityFS = (ndcL - ndcC) * 0.5;

Expand Down
6 changes: 3 additions & 3 deletions data/shader/ddgi/probeDebug.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ void main() {
vec3 probeOffset = GetProbeOffset(gl_InstanceIndex);
vec3 probePosition = GetProbePosition(probeCoord);

mat4 mvMatrix = globalData[0].vMatrix;
mat4 mvMatrix = globalData.vMatrix;

// Move any animation code to their own compute shaders
vec3 position = probeOffset + probePosition + vPosition * scale;
vec4 positionToCamera = mvMatrix * vec4(position, 1.0);

gl_Position = globalData[0].pMatrix * positionToCamera;
gl_Position = globalData.pMatrix * positionToCamera;

// Needed for velocity buffer calculation
ndcCurrentVS = vec3(gl_Position.xy, gl_Position.w);
// For moving objects we need the last frames matrix
vec3 lastPosition = position;
vec4 last = globalData[0].pvMatrixLast * vec4(lastPosition, 1.0);
vec4 last = globalData.pvMatrixLast * vec4(lastPosition, 1.0);
ndcLastVS = vec3(last.xy, last.w);

worldSpaceNormal = normalize(vPosition);
Expand Down
4 changes: 2 additions & 2 deletions data/shader/deferred/geometry.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ void main() {
vec2 ndcL = ndcLastVS.xy / ndcLastVS.z;
vec2 ndcC = ndcCurrentVS.xy / ndcCurrentVS.z;

ndcL -= globalData[0].jitterLast;
ndcC -= globalData[0].jitterCurrent;
ndcL -= globalData.jitterLast;
ndcC -= globalData.jitterCurrent;

velocityFS = (ndcL - ndcC) * 0.5;

Expand Down
10 changes: 5 additions & 5 deletions data/shader/deferred/geometry.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,30 @@ void main() {
texCoordVS = PushConstants.invertUVs > 0 ? vec2(vTexCoord.x, 1.0 - vTexCoord.y) : vTexCoord;
#endif

mat4 mvMatrix = globalData[0].vMatrix * mMatrix;
mat4 mvMatrix = globalData.vMatrix * mMatrix;

vec3 position = vPosition;
vec3 lastPosition = vPosition;

if (PushConstants.vegetation > 0) {

position = WindAnimation(windNoiseMap, vPosition, PushConstants.windBendScale,
PushConstants.windWiggleScale, PushConstants.windTextureLod, globalData[0].time, mMatrix[3].xyz);
PushConstants.windWiggleScale, PushConstants.windTextureLod, globalData.time, mMatrix[3].xyz);
lastPosition = WindAnimation(windNoiseMap, vPosition, PushConstants.windBendScale,
PushConstants.windWiggleScale, PushConstants.windTextureLod,
globalData[0].time - globalData[0].deltaTime, mMatrix[3].xyz);
globalData.time - globalData.deltaTime, mMatrix[3].xyz);

}

vec4 positionToCamera = mvMatrix * vec4(position, 1.0);
positionVS = positionToCamera.xyz;

gl_Position = globalData[0].pMatrix * positionToCamera;
gl_Position = globalData.pMatrix * positionToCamera;

// Needed for velocity buffer calculation
ndcCurrentVS = vec3(gl_Position.xy, gl_Position.w);
// For moving objects we need the last frames matrix
vec4 last = globalData[0].pvMatrixLast * mMatrixLast * vec4(lastPosition, 1.0);
vec4 last = globalData.pvMatrixLast * mMatrixLast * vec4(lastPosition, 1.0);
ndcLastVS = vec3(last.xy, last.w);

// Only after ndc calculation apply the clip correction
Expand Down
10 changes: 5 additions & 5 deletions data/shader/deferred/indirect.csh
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ void main() {
// We don't have any light direction, that's why we use vec3(0.0, -1.0, 0.0) as a placeholder
Surface surface = GetSurface(texCoord, depth, vec3(0.0, -1.0, 0.0), geometryNormal);

vec3 worldView = normalize(vec3(globalData[0].ivMatrix * vec4(surface.P, 0.0)));
vec3 worldPosition = vec3(globalData[0].ivMatrix * vec4(surface.P, 1.0));
vec3 worldNormal = normalize(vec3(globalData[0].ivMatrix * vec4(surface.N, 0.0)));
vec3 geometryWorldNormal = normalize(vec3(globalData[0].ivMatrix * vec4(geometryNormal, 0.0)));
vec3 worldView = normalize(vec3(globalData.ivMatrix * vec4(surface.P, 0.0)));
vec3 worldPosition = vec3(globalData.ivMatrix * vec4(surface.P, 1.0));
vec3 worldNormal = normalize(vec3(globalData.ivMatrix * vec4(surface.N, 0.0)));
vec3 geometryWorldNormal = normalize(vec3(globalData.ivMatrix * vec4(geometryNormal, 0.0)));

// Indirect diffuse BRDF
#ifdef DDGI
Expand All @@ -204,7 +204,7 @@ void main() {
#endif

// Indirect specular BRDF
vec3 R = normalize(mat3(globalData[0].ivMatrix) * reflect(-surface.V, surface.N));
vec3 R = normalize(mat3(globalData.ivMatrix) * reflect(-surface.V, surface.N));
float mipLevel = surface.material.roughness * float(Uniforms.specularProbeMipLevels - 1);
vec3 prefilteredSpecular = textureLod(specularProbe, R, mipLevel).rgb;
// We multiply by local sky visibility because the reflection probe only includes the sky
Expand Down
9 changes: 5 additions & 4 deletions data/shader/deferred/sss.csh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ layout(push_constant) uniform constants {

// https://blog.demofox.org/2022/01/01/interleaved-gradient-noise-a-different-kind-of-low-discrepancy-sequence/
float GetInterleavedGradientNoise(vec2 screenPos) {
uint frame = globalData[0].frameCount % 64u;
uint frame = globalData.frameCount % 64u;
float x = float(screenPos.x) + 5.588238 * float(frame);
float y = float(screenPos.y) + 5.588238 * float(frame);

Expand All @@ -43,7 +43,7 @@ float EdgeFadeOut(vec2 screenPos, float fadeDist) {

vec2 PosToUV(vec3 pos) {

vec4 clipSpace = globalData[0].pMatrix * vec4(pos, 1.0);
vec4 clipSpace = globalData.pMatrix * vec4(pos, 1.0);
clipSpace.xyz /= clipSpace.w;
return clipSpace.xy * 0.5 + 0.5;

Expand Down Expand Up @@ -109,7 +109,7 @@ void main() {
#ifdef TRACE_WORLD_SPACE
rayPos += rayDir * stepLength;

vec4 offset = globalData[0].pMatrix * vec4(rayPos, 1.0);
vec4 offset = globalData.pMatrix * vec4(rayPos, 1.0);
offset.xyz /= offset.w;
uvPos = offset.xy * 0.5 + 0.5;
#else
Expand All @@ -132,7 +132,8 @@ void main() {
float depthDelta = rayDepth - stepLinearDepth;

// Check if the camera can't "see" the ray (ray depth must be larger than the camera depth, so positive depth_delta)
if (depthDelta > 0.0 && depthDelta < depthThickness && depthDelta < 0.5 * rayLength) {
if (depthDelta > 0.0 && depthDelta < depthThickness &&
depthDelta < 0.5 * rayLength && depthDelta > 0.2 * depthThickness) {
// Mark as occluded
occlusion = 1.0;
resultDelta = depthDelta;
Expand Down
8 changes: 3 additions & 5 deletions data/shader/globals.hsh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#ifdef AE_BINDLESS
#define UNIFORM_COUNT 8192
#define TEXTURE_COUNT 16384
#else
#define UNIFORM_COUNT 1
#define TEXTURE_COUNT 1
#endif

layout(set = 0, binding = 3, std140) uniform GlobalBuffer {
layout(set = 1, binding = 31, std140) uniform GlobalBuffer {
vec4 frustumPlanes[6];
mat4 vMatrix;
mat4 pMatrix;
Expand All @@ -27,9 +25,9 @@ layout(set = 0, binding = 3, std140) uniform GlobalBuffer {
float time;
float deltaTime;
uint frameCount;
} globalData[UNIFORM_COUNT];
} globalData;

layout(set = 0, binding = 4) uniform texture2D bindlessTextures[TEXTURE_COUNT];
layout(set = 0, binding = 3) uniform texture2D bindlessTextures[TEXTURE_COUNT];

layout(set = 1, binding = 12) uniform sampler2D dfgTexture;

Expand Down
8 changes: 4 additions & 4 deletions data/shader/impostor/impostor.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void main() {
vec3 geometryNormal = 2.0 * texture(normalMap, vec3(texCoordVS, float(indexVS)), uniforms.mipBias).rgb - 1.0;
#endif

geometryNormal = normalize(vec3(globalData[0].vMatrix * vec4(geometryNormal, 0.0)));
geometryNormal = normalize(vec3(globalData.vMatrix * vec4(geometryNormal, 0.0)));
// We want the normal always two face the camera for two sided materials
geometryNormal *= -dot(geometryNormal, positionVS);
geometryNormal = normalize(geometryNormal);
Expand All @@ -109,8 +109,8 @@ void main() {
vec2 ndcL = ndcLastVS.xy / ndcLastVS.z;
vec2 ndcC = ndcCurrentVS.xy / ndcCurrentVS.z;

ndcL -= globalData[0].jitterLast;
ndcC -= globalData[0].jitterCurrent;
ndcL -= globalData.jitterLast;
ndcC -= globalData.jitterCurrent;

velocityFS = (ndcL - ndcC) * 0.5;

Expand All @@ -128,7 +128,7 @@ void main() {
#else
float depthOffset = texture(depthMap, vec3(texCoordVS, float(indexVS)), uniforms.mipBias).r;
#endif
vec3 modelPosition = modelPositionVS + depthOffset * -globalData[0].cameraDirection.xyz;
vec3 modelPosition = modelPositionVS + depthOffset * -globalData.cameraDirection.xyz;
vec4 modelPositionFS = instanceMatrix * vec4(modelPosition.xyz, 1.0);
float modelDepth = modelPositionFS.z / modelPositionFS.w;
gl_FragDepth = modelDepth;
Expand Down
14 changes: 7 additions & 7 deletions data/shader/impostor/impostor.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void main() {
texCoordVS = 0.5 * vPosition + 0.5;

vec3 pos = vec3(mMatrix * vec4(uniforms.center.xyz, 1.0));
vec3 dir = normalize(globalData[0].cameraLocation.xyz - pos);
vec3 dir = normalize(globalData.cameraLocation.xyz - pos);

float frames = float(uniforms.views);

Expand Down Expand Up @@ -140,23 +140,23 @@ void main() {
right = viewPlane.right;
#endif

// up = globalData[0].cameraUp;
// right = globalData[0].cameraRight;
// up = globalData.cameraUp;
// right = globalData.cameraRight;

vec4 modelPosition = vec4((normalize(up.xyz) * position.y
+ normalize(right.xyz) * position.x) + uniforms.center.xyz, 1.0);
positionVS = vec3(globalData[0].vMatrix * mMatrix * modelPosition);
positionVS = vec3(globalData.vMatrix * mMatrix * modelPosition);

#ifdef PIXEL_DEPTH_OFFSET
instanceMatrix = globalData[0].pMatrix * globalData[0].vMatrix * mMatrix;
instanceMatrix = globalData.pMatrix * globalData.vMatrix * mMatrix;
modelPositionVS = modelPosition.xyz;
#endif

gl_Position = globalData[0].pMatrix * vec4(positionVS, 1.0);
gl_Position = globalData.pMatrix * vec4(positionVS, 1.0);

ndcCurrentVS = vec3(gl_Position.xy, gl_Position.w);
// For moving objects we need the last matrix
vec4 last = globalData[0].pvMatrixLast * mMatrix * modelPosition;
vec4 last = globalData.pvMatrixLast * mMatrix * modelPosition;
ndcLastVS = vec3(last.xy, last.w);

}
6 changes: 3 additions & 3 deletions data/shader/ocean/caustics.csh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ layout(push_constant) uniform constants {
// Modified from Shadertoy: https://www.shadertoy.com/view/XtKfRG
float caustics(vec3 pos) {
mat3 m = mat3(-2,-1,2, 3,-2,1, 1,2,2);
vec3 a = vec3(pos.xz * 0.5, globalData[0].time / 4.0) * m;
vec3 a = vec3(pos.xz * 0.5, globalData.time / 4.0) * m;
vec3 b = a * m * 0.4;
vec3 c = b * m * 0.3;
return pow(
Expand All @@ -49,7 +49,7 @@ void main() {

float depth = textureLod(depthTexture, texCoord, 0.0).r;
vec3 viewSpacePos = ConvertDepthToViewSpace(depth, texCoord);
vec3 pixelPos = vec3(globalData[0].ivMatrix * vec4(viewSpacePos, 1.0));
vec3 pixelPos = vec3(globalData.ivMatrix * vec4(viewSpacePos, 1.0));

float distanceToCamera = length(viewSpacePos);
float fadeout = min(1.0, 1.0 - (distanceToCamera - fadeoutDistance) / (fadeoutFalloff * fadeoutDistance));
Expand All @@ -60,7 +60,7 @@ void main() {

float shadowFactor = max(CalculateCascadedShadow(light.shadow, cascadeMaps, viewSpacePos, vec3(0.0, 1.0, 0.0), 0.0), 0.0);

vec3 pos = vec3(pixelPos.x, globalData[0].time * 0.5, pixelPos.z);
vec3 pos = vec3(pixelPos.x, globalData.time * 0.5, pixelPos.z);
pos *= 2.0;

vec3 o = vec3(1.0, 0.0, 1.0)*0.02;
Expand Down
2 changes: 1 addition & 1 deletion data/shader/ocean/depth.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void main() {
/*
StencilFeatures features = CreateStencilFeatures();
vec3 viewDir = normalize(fPosition - globalData[0].cameraLocation.xyz);
vec3 viewDir = normalize(fPosition - globalData.cameraLocation.xyz);
bool frontFacing = dot(normalize(fNormal), viewDir) < 0.0 ? true : false;
if (!gl_FrontFacing && !frontFacing) {
Expand Down
Loading

0 comments on commit 377d0bd

Please sign in to comment.