first commit
This commit is contained in:
commit
0f859671ea
308 files changed
+18617
No files matched your search
@@ -0,0 +1,15 @@
|
||||
float min1(float x) {
|
||||
return min(x, 1.0);
|
||||
}
|
||||
float max0(float x) {
|
||||
return max(x, 0.0);
|
||||
}
|
||||
float clamp01(float x) {
|
||||
return clamp(x, 0.0, 1.0);
|
||||
}
|
||||
vec2 clamp01(vec2 x) {
|
||||
return clamp(x, vec2(0.0), vec2(1.0));
|
||||
}
|
||||
vec3 clamp01(vec3 x) {
|
||||
return clamp(x, vec3(0.0), vec3(1.0));
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef INCLUDE_DFDX_DFDY
|
||||
#define INCLUDE_DFDX_DFDY
|
||||
|
||||
vec2 dcdx = dFdx(texCoord.xy);
|
||||
vec2 dcdy = dFdy(texCoord.xy);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
//Dithering from Jodie
|
||||
float Bayer2(vec2 a) {
|
||||
a = floor(a);
|
||||
return fract(a.x * 0.5 + a.y * a.y * 0.75);
|
||||
}
|
||||
|
||||
#define Bayer4(a) (Bayer2(a * 0.5) * 0.25 + Bayer2(a))
|
||||
#define Bayer8(a) (Bayer4(a * 0.5) * 0.25 + Bayer2(a))
|
||||
|
||||
float BayerCloud2(vec2 a) {
|
||||
a = floor(a);
|
||||
return fract(a.x * 0.5 + a.y * 0.75);
|
||||
}
|
||||
|
||||
#define BayerCloud4(a) (BayerCloud2(a * 0.5) * 0.25 + BayerCloud2(a))
|
||||
#define BayerCloud8(a) (BayerCloud4(a * 0.5) * 0.25 + BayerCloud2(a))
|
||||
@@ -0,0 +1,15 @@
|
||||
//Spheremap Transform from https://aras-p.info/texts/CompactNormalStorage.html
|
||||
vec2 EncodeNormal(vec3 n) {
|
||||
float f = sqrt(n.z * 8.0 + 8.0);
|
||||
return n.xy / f + 0.5;
|
||||
}
|
||||
|
||||
vec3 DecodeNormal(vec2 enc) {
|
||||
vec2 fenc = enc * 4.0 - 2.0;
|
||||
float f = dot(fenc,fenc);
|
||||
float g = sqrt(1.0 - f / 4.0);
|
||||
vec3 n;
|
||||
n.xy = fenc * g;
|
||||
n.z = 1.0 - f / 2.0;
|
||||
return n;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//Jitter offset from Chocapic13
|
||||
uniform float framemod8;
|
||||
uniform float framemod2;
|
||||
|
||||
vec2 jitterOffsets8[8] = vec2[8](
|
||||
vec2( 0.125,-0.375),
|
||||
vec2(-0.125, 0.375),
|
||||
vec2( 0.625, 0.125),
|
||||
vec2( 0.375,-0.625),
|
||||
vec2(-0.625, 0.625),
|
||||
vec2(-0.875,-0.125),
|
||||
vec2( 0.375,-0.875),
|
||||
vec2( 0.875, 0.875)
|
||||
);
|
||||
vec2 jitterOffsets2[2] = vec2[2](
|
||||
vec2( 1.0, 0.0),
|
||||
vec2( 0.0, 1.0)
|
||||
);
|
||||
|
||||
vec2 TAAJitter(vec2 coord, float w) {
|
||||
#if TAA_MODE == 0
|
||||
vec2 offset = jitterOffsets8[int(framemod8)] * (w / vec2(viewWidth, viewHeight));
|
||||
#else
|
||||
vec2 offset = jitterOffsets2[int(framemod2)] * (w / vec2(viewWidth, viewHeight));
|
||||
#endif
|
||||
return coord + offset;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
void DepthOutline(inout float z, sampler2D depthtex) {
|
||||
float ph = ceil(viewHeight / 1440.0) / viewHeight;
|
||||
float pw = ph / aspectRatio;
|
||||
|
||||
int sampleCount = viewHeight >= 720.0 ? 12 : 4;
|
||||
|
||||
#ifdef RETRO_FILTER
|
||||
ph = RETRO_FILTER_SIZE / viewHeight;
|
||||
pw = ph / aspectRatio;
|
||||
sampleCount = 4;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
vec2 offset = vec2(pw, ph) * outlineOffsets[i];
|
||||
for (int j = 0; j < 2; j++) {
|
||||
z = min(z, texture2D(depthtex, texCoord + offset).r);
|
||||
offset = -offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
float GetOutlineMask() {
|
||||
float ph = ceil(viewHeight / 1440.0) / viewHeight;
|
||||
float pw = ph / aspectRatio;
|
||||
|
||||
int sampleCount = viewHeight >= 720.0 ? 12 : 4;
|
||||
|
||||
#ifdef RETRO_FILTER
|
||||
ph = RETRO_FILTER_SIZE / viewHeight;
|
||||
pw = ph / aspectRatio;
|
||||
sampleCount = 4;
|
||||
#endif
|
||||
|
||||
float mask = 0.0;
|
||||
for (int i = 0; i < sampleCount; i++) {
|
||||
vec2 offset = vec2(pw, ph) * outlineOffsets[i];
|
||||
for (int j = 0; j < 2; j++){
|
||||
mask += float(texture2D(depthtex0, texCoord + offset).r <
|
||||
texture2D(depthtex1, texCoord + offset).r);
|
||||
offset = -offset;
|
||||
}
|
||||
}
|
||||
|
||||
return float(mask > 0.5);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
vec2 outlineOffsets[12] = vec2[12](
|
||||
vec2( 0.0, 1.0),
|
||||
vec2( 1.0, 0.0),
|
||||
vec2( 1.0, 1.0),
|
||||
vec2(-1.0, 1.0),
|
||||
vec2( 2.0, 0.0),
|
||||
vec2( 0.0, 2.0),
|
||||
vec2( 2.0, 1.0),
|
||||
vec2( 1.0, 2.0),
|
||||
vec2(-1.0, 2.0),
|
||||
vec2(-2.0, 1.0),
|
||||
vec2( 2.0, 2.0),
|
||||
vec2(-2.0, 2.0)
|
||||
);
|
||||
@@ -0,0 +1,20 @@
|
||||
#define diagonal3(m) vec3((m)[0].x, (m)[1].y, m[2].z)
|
||||
#define projMAD(m, v) (diagonal3(m) * (v) + (m)[3].xyz)
|
||||
|
||||
vec3 ToNDC(vec3 pos) {
|
||||
vec4 iProjDiag = vec4(gbufferProjectionInverse[0].x,
|
||||
gbufferProjectionInverse[1].y,
|
||||
gbufferProjectionInverse[2].zw);
|
||||
vec3 p3 = pos * 2.0 - 1.0;
|
||||
vec4 viewPos = iProjDiag * p3.xyzz + gbufferProjectionInverse[3];
|
||||
return viewPos.xyz / viewPos.w;
|
||||
}
|
||||
|
||||
vec3 ToWorld(vec3 pos) {
|
||||
return mat3(gbufferModelViewInverse) * pos + gbufferModelViewInverse[3].xyz;
|
||||
}
|
||||
|
||||
vec3 ToShadow(vec3 pos) {
|
||||
vec3 shadowpos = mat3(shadowModelView) * pos + shadowModelView[3].xyz;
|
||||
return projMAD(shadowProjection, shadowpos);
|
||||
}
|
||||
Reference in new issue
Block a user