Texture pipeline, pixel-art shader

This commit is contained in:
2025-11-11 19:47:16 +01:00
parent f2eff70179
commit 3379717cf5
9 changed files with 218 additions and 15 deletions

View File

@@ -141,10 +141,22 @@ vec3 lightOutgoingRadiance(
return (scatteredFactor + reflectedFactor) * incomingRadiance * dotNL;
}
vec4 texture2DArrayAA(texture2DArray tex, vec2 texCoord) {
vec2 size = vec2(textureSize(sampler2DArray(tex, _Sampler), 0).xy);
vec2 texCoordPX = texCoord * size;
vec2 seam = floor(texCoordPX + vec2(0.5));
texCoordPX = (texCoordPX - seam) / fwidth(texCoordPX) + seam;
texCoordPX = clamp(texCoordPX, seam - 0.5, seam + 0.5);
vec3 texCoord3 = vec3(texCoordPX / size, float(_TextureIndex));
return texture(sampler2DArray(tex, _Sampler), texCoord3);
}
void main() {
vec4 baseColorTexel = texture(sampler2DArray(_BaseColorTexture, _Sampler), vec3(var_texCoord, float(_TextureIndex)));
vec4 occlusionRoughnessMetallicTexel = texture(sampler2DArray(_OcclusionRoughnessMetallicTexture, _Sampler), vec3(var_texCoord, float(_TextureIndex)));
vec4 normalTextureTexel = texture(sampler2DArray(_NormalTexture, _Sampler), vec3(var_texCoord, float(_TextureIndex)));
vec4 baseColorTexel = texture2DArrayAA(_BaseColorTexture, var_texCoord);
vec4 occlusionRoughnessMetallicTexel = texture2DArrayAA(_OcclusionRoughnessMetallicTexture, var_texCoord);
vec4 normalTextureTexel = texture2DArrayAA(_NormalTexture, var_texCoord);
vec3 baseColor = baseColorTexel.rgb;
float occlusion = occlusionRoughnessMetallicTexel.r;

BIN
assets/textures/BaseColor.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/textures/Normal.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/textures/OcclusionRoughnessMetallic.png (Stored with Git LFS) Normal file

Binary file not shown.