HDR, Bloom and SSR

This commit is contained in:
Halbear 2026-09-04 00:23:48 +01:00
parent 577836a03f
commit 04befce27d
44 changed files with 1377 additions and 269 deletions

View file

@ -7,6 +7,7 @@ layout(location = 1) in vec3 inNormal;
layout(location = 2) in vec3 inTangent;
layout(location = 3) in vec3 inBitangent;
layout(location = 4) in vec2 inTextCoords;
layout(location = 5) in mat4 viewMatrix;
layout(location = 1) out vec4 outAlbedo ;
layout(location = 0) out vec4 outPos;
@ -15,6 +16,7 @@ layout(location = 3) out vec4 outPBR;
layout(location = 4) out vec4 outEmissive;
layout(location = 5) out vec4 outTranslucency;
layout(location = 6) out vec4 outOpacity;
layout(location = 7) out vec4 outViewPos;
const float bayerMatrix[16] = float[](
0.0 / 16.0, 8.0 / 16.0, 2.0 / 16.0, 10.0 / 16.0,
@ -42,6 +44,10 @@ struct Material {
uint hasOpacityMap; //88
uint OpacityMapIdx; //92
float OpacityFactor; //96
float reflectiveness; //100
float refractiveness; //104
float Padding1; //108
float Padding2; //112
};
layout(set = 2, binding = 0) readonly buffer MaterialUniform {
Material materials[];
@ -68,6 +74,9 @@ void main()
{
outPos = inPos;
vec4 viewPos = vec4(viewMatrix * vec4(inPos.xyz, 1.0));
outViewPos = viewPos;
Material material = matUniform.materials[push_constants.materialIdx];
int textureIndex = int(material.textureIdx);
if (textureIndex >= MAX_TEXTURES){
@ -84,11 +93,6 @@ void main()
} else {
outAlbedo = material.diffuseColor;
}
/*int Intensity = 4;
int x = int(gl_FragCoord.x) % Intensity;
int y = int(gl_FragCoord.y) % Intensity;
float threshold = bayerMatrix[y * Intensity + x];
if(outAlbedo.a < threshold || outAlbedo.a < 0.05f) discard;*/
vec4 Opacity = vec4(outAlbedo.a,outAlbedo.a,outAlbedo.a,1);
if(material.OpacityFactor != 1) Opacity = vec4(material.OpacityFactor, material.OpacityFactor, material.OpacityFactor, 1);
@ -102,12 +106,11 @@ void main()
outAlbedo = vec4(outAlbedo.rgb, opacityf);
if(outAlbedo.a < 0.75) discard;
if(outAlbedo.a < 0.9) discard;
mat3 TBN = mat3(inTangent, inBitangent, inNormal);
vec3 newNormal = calcNormal(material, inNormal, inTextCoords, TBN);
outNormal = vec4(newNormal, outAlbedo.a);
float ao = 0.5f;
float roughnessFactor = 0.0f;
@ -133,6 +136,9 @@ void main()
}
outTranslucency = Translucency;
outPBR = vec4(ao, roughnessFactor, metallicFactor, outAlbedo.a);
float Refractiveness = material.refractiveness;
float Reflectiveness = material.reflectiveness;
outNormal = vec4(newNormal, Refractiveness);
outPBR = vec4(ao, roughnessFactor, metallicFactor, Reflectiveness);
}