custommods
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include "/lib/outline/blackOutlineOffset.glsl"
|
||||
|
||||
void BlackOutline(inout vec3 color, sampler2D depth, float wFogMult) {
|
||||
float ph = 1.0 / 1080.0;
|
||||
float pw = ph / aspectRatio;
|
||||
|
||||
float outline = 1.0;
|
||||
float z = GetLinearDepth(texture2D(depth, texCoord).r) * far * 2.0;
|
||||
float minZ = 1.0, sampleZA = 0.0, sampleZB = 0.0;
|
||||
|
||||
for(int i = 0; i < 12; i++) {
|
||||
vec2 offset = vec2(pw, ph) * blackOutlineOffsets[i];
|
||||
sampleZA = texture2D(depth, texCoord + offset).r;
|
||||
sampleZB = texture2D(depth, texCoord - offset).r;
|
||||
float sampleZsum = GetLinearDepth(sampleZA) + GetLinearDepth(sampleZB);
|
||||
outline *= clamp(1.0 - (z - sampleZsum * far), 0.0, 1.0);
|
||||
minZ = min(minZ, min(sampleZA,sampleZB));
|
||||
}
|
||||
|
||||
vec4 viewPos = gbufferProjectionInverse * (vec4(texCoord.x, texCoord.y, minZ, 1.0) * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
|
||||
color = color * outline;
|
||||
|
||||
if (outline < 1.0) {
|
||||
vec3 nViewPos = normalize(viewPos.xyz);
|
||||
float NdotU = dot(nViewPos, upVec);
|
||||
float lViewPos = length(viewPos.xyz);
|
||||
vec3 worldPos = ViewToWorld(viewPos.xyz);
|
||||
vec3 theFog = startFog(color.rgb, nViewPos, lViewPos, worldPos, vec3(0.0), NdotU);
|
||||
color.rgb = mix(theFog, color.rgb, pow(outline, 4));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
float BlackOutlineMask(sampler2D depth0, sampler2D depth1) {
|
||||
float ph = 1.0 / 1080.0;
|
||||
float pw = ph / aspectRatio;
|
||||
|
||||
float mask = 0.0;
|
||||
for(int i = 0; i < 12; i++) {
|
||||
vec2 offset = vec2(pw, ph) * blackOutlineOffsets[i];
|
||||
mask += float(texture2D(depth0, texCoord + offset).r <
|
||||
texture2D(depth1, texCoord + offset).r);
|
||||
mask += float(texture2D(depth0, texCoord - offset).r <
|
||||
texture2D(depth1, texCoord - offset).r);
|
||||
}
|
||||
|
||||
return clamp(mask,0.0,1.0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
vec2 blackOutlineOffsets[12] = vec2[12](
|
||||
vec2(-2.0,2.0),
|
||||
vec2(-1.0,2.0),
|
||||
vec2( 0.0,2.0),
|
||||
vec2( 1.0,2.0),
|
||||
vec2( 2.0,2.0),
|
||||
vec2(-2.0,1.0),
|
||||
vec2(-1.0,1.0),
|
||||
vec2( 0.0,1.0),
|
||||
vec2( 1.0,1.0),
|
||||
vec2( 2.0,1.0),
|
||||
vec2( 1.0,0.0),
|
||||
vec2( 2.0,0.0)
|
||||
);
|
||||
@@ -0,0 +1,11 @@
|
||||
#include "/lib/outline/blackOutlineOffset.glsl"
|
||||
|
||||
void DepthOutline(inout float z) {
|
||||
float ph = 1.0 / 1080.0;
|
||||
float pw = ph / aspectRatio;
|
||||
for(int i = 0; i < 12; i++) {
|
||||
vec2 offset = vec2(pw, ph) * blackOutlineOffsets[i];
|
||||
z = min(z, texture2D(depthtex1, texCoord + offset).r);
|
||||
z = min(z, texture2D(depthtex1, texCoord - offset).r);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
vec2 promoOutlineOffsets[4] = vec2[4](vec2(-1.0,1.0),vec2(0.0,1.0),vec2(1.0,1.0),vec2(1.0,0.0));
|
||||
|
||||
void PromoOutline(inout vec3 color, sampler2D depth) {
|
||||
float ph = 1.0 / 1080.0;
|
||||
float pw = ph / aspectRatio;
|
||||
|
||||
float outlined = 1.0;
|
||||
float z = GetLinearDepth(texture2D(depth, texCoord).r) * far;
|
||||
float totalz = 0.0;
|
||||
float maxz = 0.0;
|
||||
float sampleza = 0.0;
|
||||
float samplezb = 0.0;
|
||||
|
||||
int sampleCount = PROMO_OUTLINE_THICKNESS * 4;
|
||||
|
||||
for(int i = 0; i < sampleCount; i++) {
|
||||
vec2 offset = (1.0 + floor(i / 4.0)) * vec2(pw, ph) * promoOutlineOffsets[int(mod(float(i), 4))];
|
||||
sampleza = GetLinearDepth(texture2D(depth, texCoord + offset).r) * far;
|
||||
samplezb = GetLinearDepth(texture2D(depth, texCoord - offset).r) * far;
|
||||
if (i < 4) maxz = max(maxz, max(sampleza, samplezb));
|
||||
|
||||
outlined *= clamp(1.0 - ((sampleza + samplezb) - z * 2.0) * 32.0 / z, 0.0, 1.0);
|
||||
|
||||
totalz += sampleza + samplezb;
|
||||
}
|
||||
|
||||
#if PROMO_OUTLINE_MODE == 2
|
||||
float outlinea = 1.0;
|
||||
float outlineb = 1.0;
|
||||
#else
|
||||
float outlinea = 1.0 - clamp((z * 8.0 - totalz) * 64.0 / z, 0.0, 1.0) *
|
||||
clamp(1.0 - ((z * 8.0 - totalz) * 32.0 - 1.0) / z, 0.0, 1.0);
|
||||
float outlineb = clamp(1.0 + 8.0 * (z - maxz) / z, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
float outAB = pow(outlinea * outlineb, 0.1);
|
||||
|
||||
float outlinec = clamp(1.0 + 64.0 * (z - maxz) / z, 0.0, 1.0);
|
||||
|
||||
float outline = (0.35 * outAB + 0.65) *
|
||||
(0.75 * (1.0 - outlined) * outlinec + 1.0);
|
||||
|
||||
float fog = 0.0;
|
||||
#ifdef FOG1
|
||||
float fogZ = texture2D(depthtex0, texCoord).r;
|
||||
vec4 screenPos = vec4(texCoord, fogZ, 1.0);
|
||||
vec4 viewPos = gbufferProjectionInverse * (screenPos * 2.0 - 1.0);
|
||||
viewPos /= viewPos.w;
|
||||
fog = length(viewPos) / far * 1.5 * (1.5/FOG1_DISTANCE_M);
|
||||
fog = 1.0 - exp(-0.1 * pow(fog, 10));
|
||||
#endif
|
||||
|
||||
float outlinePower = PROMO_OUTLINE_STRENGTH / PROMO_OUTLINE_THICKNESS;
|
||||
if (outline < 1.0) {
|
||||
outlinePower = PROMO_OUTLINE_STRENGTH;
|
||||
}
|
||||
outline = pow(outline, outlinePower);
|
||||
#if PROMO_OUTLINE_MODE == 3
|
||||
outline = abs(outline - 1.0) + 1.0;
|
||||
#endif
|
||||
vec3 color2 = color.rgb * outline;
|
||||
color = mix(color2, color, fog);
|
||||
}
|
||||
Reference in New Issue
Block a user