Need for speed

This commit is contained in:
luboslenco 2018-12-05 17:47:45 +01:00
parent f04105b2d3
commit 0cc0915e44
38 changed files with 139 additions and 189 deletions

View File

@ -8,7 +8,6 @@
"blend_source": "blend_one",
"blend_destination": "blend_one",
"blend_operation": "add",
"color_write_alpha": false,
"links": [],
"texture_params": [],
"vertex_shader": "../include/pass.vert.glsl",

View File

@ -8,11 +8,12 @@ in vec2 texCoord;
out vec4 fragColor;
void main() {
vec4 col = texture(tex, texCoord);
float brightness = dot(col.rgb, vec3(0.2126, 0.7152, 0.0722));
vec3 col = textureLod(tex, texCoord, 0.0).rgb;
float brightness = dot(col, vec3(0.2126, 0.7152, 0.0722));
if (brightness > bloomThreshold) {
fragColor.rgb = col.rgb;
return;
fragColor.rgb = col;
}
else {
fragColor.rgb = vec3(0.0);
}
fragColor.rgb = vec3(0.0);
}

View File

@ -2,7 +2,6 @@
"contexts": [
{
"name": "bloom_pass",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",

View File

@ -2,7 +2,6 @@
"contexts": [
{
"name": "blur_adaptive_pass_x",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -18,7 +17,6 @@
},
{
"name": "blur_adaptive_pass_y",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -36,7 +34,6 @@
{
"name": "blur_adaptive_pass_x2",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -52,7 +49,6 @@
},
{
"name": "blur_adaptive_pass_y3",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -68,7 +64,6 @@
},
{
"name": "blur_adaptive_pass_y3_blend",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",

View File

@ -2,7 +2,6 @@
"contexts": [
{
"name": "blur_bilat_blend_pass_y",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",

View File

@ -2,7 +2,6 @@
"contexts": [
{
"name": "blur_bilat_pass_x",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -22,7 +21,6 @@
},
{
"name": "blur_bilat_pass_y",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -42,7 +40,6 @@
},
{
"name": "blur_bilat_pass_y_blend",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",

View File

@ -2,7 +2,6 @@
"contexts": [
{
"name": "blur_edge_pass_x",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -18,7 +17,6 @@
},
{
"name": "blur_edge_pass_y",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -34,7 +32,6 @@
},
{
"name": "blur_edge_pass_y_blend",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -54,7 +51,6 @@
{
"name": "blur_edge_pass_y_blend_add",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",

View File

@ -2,7 +2,6 @@
"contexts": [
{
"name": "blur_gaus_pass_x",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -22,7 +21,6 @@
},
{
"name": "blur_gaus_pass_y",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -42,7 +40,6 @@
},
{
"name": "blur_gaus_pass_y_blend",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",

View File

@ -2,7 +2,6 @@
"contexts": [
{
"name": "blur_pass_x",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -18,7 +17,6 @@
},
{
"name": "blur_pass_y",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -36,7 +34,6 @@
{
"name": "blur_pass_x2",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -52,7 +49,6 @@
},
{
"name": "blur_pass_y2",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",

View File

@ -2,7 +2,6 @@
"contexts": [
{
"name": "blur_shadow_pass_x",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -18,7 +17,6 @@
},
{
"name": "blur_shadow_pass_y",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -34,7 +32,6 @@
},
{
"name": "blur_shadow_pass_y_blend",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -54,7 +51,6 @@
{
"name": "blur_shadow_pass_y_blend_add",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",

View File

@ -3,7 +3,6 @@
{
"name": "combine_pass",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [],

View File

@ -3,7 +3,6 @@
{
"name": "compositor_pass",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [

View File

@ -3,7 +3,6 @@
{
"name": "debug_normals",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [

View File

@ -3,7 +3,6 @@
{
"name": "debug_velocity",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [],

View File

@ -179,7 +179,7 @@ void main() {
vec3 f0 = surfaceF0(g1.rgb, metrough.x);
float depth = texture(gbufferD, texCoord).r * 2.0 - 1.0;
vec3 p = getPos(eye, eyeLook, viewRay, depth, cameraProj);
vec3 p = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
vec3 v = normalize(eye - p);
float dotNV = max(dot(n, v), 0.0);

View File

@ -174,7 +174,7 @@
"ifdef": ["_Clusters", "_ShadowMapCube"]
}
],
"vertex_shader": "deferred_light.vert.glsl",
"vertex_shader": "../include/pass_viewray.vert.glsl",
"fragment_shader": "deferred_light.frag.glsl"
}
]

View File

@ -1,28 +0,0 @@
#version 450
#include "compiled.inc"
uniform mat4 invVP;
uniform vec3 eye;
in vec2 pos;
out vec2 texCoord;
out vec3 viewRay;
void main() {
// Scale vertex attribute to [0-1] range
const vec2 madd = vec2(0.5, 0.5);
texCoord = pos.xy * madd + madd;
#ifdef HLSL
texCoord.y = 1.0 - texCoord.y;
#endif
gl_Position = vec4(pos.xy, 0.0, 1.0);
// NDC (at the back of cube)
vec4 v = vec4(pos.x, pos.y, 1.0, 1.0);
v = vec4(invVP * v);
v.xyz /= v.w;
viewRay = v.xyz - eye;
}

View File

@ -0,0 +1,13 @@
#version 450
#include "compiled.inc"
uniform sampler2D texdepth;
in vec2 texCoord;
void main() {
float d = textureLod(texdepth, texCoord, 0.0).r;
// Select max depth from 2x2 area..
gl_FragDepth = d;
}

View File

@ -0,0 +1,14 @@
{
"contexts": [
{
"name": "downsample_depth",
"depth_write": true,
"compare_mode": "always",
"cull_mode": "none",
"links": [],
"texture_params": [],
"vertex_shader": "../include/pass.vert.glsl",
"fragment_shader": "downsample_depth.frag.glsl"
}
]
}

View File

@ -3,7 +3,6 @@
{
"name": "fxaa_pass",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [

View File

@ -21,7 +21,7 @@ out vec4 fragColor;
vec2 getVelocity(vec2 coord, float depth) {
vec4 currentPos = vec4(coord.xy * 2.0 - 1.0, depth, 1.0);
vec4 worldPos = vec4(getPos(eye, eyeLook, viewRay, depth, cameraProj), 1.0);
vec4 worldPos = vec4(getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj), 1.0);
vec4 previousPos = prevVP * worldPos;
previousPos /= previousPos.w;
vec2 velocity = (currentPos - previousPos).xy / 40.0;

View File

@ -3,7 +3,6 @@
{
"name": "motion_blur_pass",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [

View File

@ -3,7 +3,6 @@
{
"name": "motion_blur_veloc_pass",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [

View File

@ -3,7 +3,6 @@
{
"name": "probe_cubemap",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "less",
"cull_mode": "clockwise",
"blend_source": "blend_one",

View File

@ -3,7 +3,6 @@
{
"name": "probe_planar",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "less",
"cull_mode": "clockwise",
"blend_source": "blend_one",

View File

@ -16,80 +16,69 @@
#include "compiled.inc"
#include "std/gbuffer.glsl"
const int kernelSize = 12;
const vec2 kernel[12] = vec2[] (
vec2(1.0, 0.0),
vec2(0.8660254, 0.4999999),
vec2(0.5, 0.8660254),
vec2(0.0, 1.0),
vec2(-0.4999999, 0.8660254),
vec2(-0.8660254, 0.5),
vec2(-1.0, 0.0),
vec2(-0.8660254, -0.4999999),
vec2(-0.5, -0.8660254),
vec2(0.0, -1.0),
vec2(0.4999999, -0.8660254),
vec2(0.8660254, -0.5)
);
uniform sampler2D gbufferD;
uniform sampler2D gbuffer0;
uniform sampler2D snoise;
uniform mat4 invVP;
uniform vec3 eye;
// uniform vec3 eyeLook;
uniform vec2 cameraProj;
uniform vec3 eyeLook;
uniform vec2 screenSize;
uniform vec2 aspectRatio;
in vec2 texCoord;
// in vec3 viewRay;
in vec3 viewRay;
out vec4 fragColor;
float doAO(vec2 kernelVec, vec2 randomVec, mat2 rotMat, vec3 currentPos, vec3 n, float currentDistance) {
kernelVec.xy *= aspectRatio;
float radius = ssaoSize * randomVec.y;
kernelVec.xy = ((rotMat * kernelVec.xy) / currentDistance) * radius;
vec2 coord = texCoord + kernelVec.xy;
float depth = texture(gbufferD, coord).r * 2.0 - 1.0;
vec3 pos = getPos2NoEye(eye, invVP, depth, coord) - currentPos;
float angle = dot(pos, n);
// angle *= step(0.3, angle / length(pos)); // Fix intersect
angle *= step(0.1, angle / length(pos));
angle -= currentDistance * 0.001;
angle = max(0.0, angle);
// angle /= dot(pos, pos) / min(currentDistance * 0.25, 1.0) + 0.00001; // Fix darkening
angle /= dot(pos, pos) / min(currentDistance * 0.25, 1.0) + 0.001;
return angle;
}
void main() {
float depth = texture(gbufferD, texCoord).r * 2.0 - 1.0;
if (depth == 1.0) {
fragColor.r = 1.0;
return;
}
const int kernelSize = 12;
const vec2 kernel[12] = vec2[] (
vec2(1.0, 0.0),
vec2(0.8660254, 0.4999999),
vec2(0.5, 0.8660254),
vec2(0.0, 1.0),
vec2(-0.4999999, 0.8660254),
vec2(-0.8660254, 0.5),
vec2(-1.0, 0.0),
vec2(-0.8660254, -0.4999999),
vec2(-0.5, -0.8660254),
vec2(0.0, -1.0),
vec2(0.4999999, -0.8660254),
vec2(0.8660254, -0.5)
);
float depth = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
if (depth == 1.0) { fragColor.r = 1.0; return; }
vec2 enc = texture(gbuffer0, texCoord).rg;
vec2 enc = textureLod(gbuffer0, texCoord, 0.0).rg;
vec3 n;
n.z = 1.0 - abs(enc.x) - abs(enc.y);
n.xy = n.z >= 0.0 ? enc.xy : octahedronWrap(enc.xy);
n = normalize(n);
vec3 currentPos = getPos2NoEye(eye, invVP, depth, texCoord);
vec3 vray = normalize(viewRay);
vec3 currentPos = getPosNoEye(eyeLook, vray, depth, cameraProj);
float currentDistance = length(currentPos);
float currentDistanceA = currentDistance * 0.002;
float currentDistanceB = min(currentDistance * 0.25, 1.0);
vec2 randomVec = texture(snoise, (texCoord * screenSize) / 8.0).xy;
randomVec = randomVec * 2.0 - 1.0;
vec2 randomVec = textureLod(snoise, (texCoord * screenSize) / 8.0, 0.0).xy * 2.0 - 1.0;
mat2 rotMat = mat2(vec2(cos(randomVec.x * PI), -sin(randomVec.x * PI)),
vec2(sin(randomVec.x * PI), cos(randomVec.x * PI)));
float radius = ssaoSize * randomVec.y;
fragColor.r = 0;
for (int i = 0; i < 12; ++i) {
fragColor.r += doAO(kernel[i], randomVec, rotMat, currentPos, n, currentDistance);
vec2 k = ((rotMat * kernel[i] * aspectRatio) / currentDistance) * radius;
depth = textureLod(gbufferD, texCoord + k, 0.0).r * 2.0 - 1.0;
vec3 pos = getPosNoEye(eyeLook, vray, depth, cameraProj) - currentPos;
float angle = dot(pos, n);
angle *= step(0.1, angle / length(pos)); // Fix intersect
angle -= currentDistanceA;
angle = max(0.0, angle);
angle /= dot(pos, pos) / currentDistanceB + 0.015; // Fix darkening
fragColor.r += angle;
}
fragColor.r *= ssaoStrength / kernelSize;
fragColor.r = max(0.0, 1.0 - fragColor.r);
fragColor.r = 1.0 - fragColor.r;
}

View File

@ -3,9 +3,6 @@
{
"name": "ssao_pass",
"depth_write": false,
"color_write_alpha": false,
"color_write_green": false,
"color_write_blue": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [
@ -23,8 +20,11 @@
},
{
"name": "eyeLook",
"link": "_cameraLook",
"ifdef": ["_Disabled"]
"link": "_cameraLook"
},
{
"name": "cameraProj",
"link": "_cameraPlaneProj"
},
{
"name": "screenSize",
@ -36,7 +36,7 @@
}
],
"texture_params": [],
"vertex_shader": "../include/pass.vert.glsl",
"vertex_shader": "../include/pass_viewray.vert.glsl",
"fragment_shader": "ssao_pass.frag.glsl"
}
]

View File

@ -2,7 +2,6 @@
"contexts": [
{
"name": "ssgi_blur_pass_x",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -18,7 +17,6 @@
},
{
"name": "ssgi_blur_pass_y",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -34,7 +32,6 @@
},
{
"name": "ssgi_blur_pass_y_blend",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",
@ -54,7 +51,6 @@
{
"name": "ssgi_blur_pass_y_blend_add",
"color_write_alpha": false,
"depth_write": false,
"compare_mode": "always",
"cull_mode": "none",

View File

@ -22,8 +22,8 @@ float depth;
const int numBinarySearchSteps = 7;
const int maxSteps = 18;
vec2 getProjectedCoord(vec3 hitCoord) {
vec4 projectedCoord = P * vec4(hitCoord, 1.0);
vec2 getProjectedCoord(const vec3 hit) {
vec4 projectedCoord = P * vec4(hit, 1.0);
projectedCoord.xy /= projectedCoord.w;
projectedCoord.xy = projectedCoord.xy * 0.5 + 0.5;
#ifdef HLSL
@ -32,22 +32,22 @@ vec2 getProjectedCoord(vec3 hitCoord) {
return projectedCoord.xy;
}
float getDeltaDepth(vec3 hitCoord) {
depth = texture(gbufferD, getProjectedCoord(hitCoord)).r * 2.0 - 1.0;
float getDeltaDepth(const vec3 hit) {
depth = textureLod(gbufferD, getProjectedCoord(hit), 0.0).r * 2.0 - 1.0;
vec3 viewPos = getPosView(viewRay, depth, cameraProj);
return viewPos.z - hitCoord.z;
return viewPos.z - hit.z;
}
vec4 binarySearch(vec3 dir) {
vec4 binarySearch(vec3 dir) {
float ddepth;
for (int i = 0; i < numBinarySearchSteps; i++) {
dir *= 0.5;
hitCoord -= dir;
if (getDeltaDepth(hitCoord) < 0.0) hitCoord += dir;
ddepth = getDeltaDepth(hitCoord);
if (ddepth < 0.0) hitCoord += dir;
}
// Ugly discard of hits too far away
if (abs(getDeltaDepth(hitCoord)) > 0.01) {
return vec4(0.0);
}
if (abs(ddepth) > 0.01) return vec4(0.0);
return vec4(getProjectedCoord(hitCoord), 0.0, 1.0);
}
@ -61,25 +61,15 @@ vec4 rayCast(vec3 dir) {
}
void main() {
vec4 g0 = texture(gbuffer0, texCoord);
vec4 g0 = textureLod(gbuffer0, texCoord, 0.0);
float roughness = unpackFloat(g0.b).y;
if (roughness == 1.0) { fragColor.rgb = vec3(0.0); return; }
if (roughness == 1.0) {
fragColor.rgb = vec3(0.0);
return;
}
float spec = fract(texture(gbuffer1, texCoord).a);
if (spec == 0.0) {
fragColor.rgb = vec3(0.0);
return;
}
float spec = fract(textureLod(gbuffer1, texCoord, 0.0).a);
if (spec == 0.0) { fragColor.rgb = vec3(0.0); return; }
float d = texture(gbufferD, texCoord).r * 2.0 - 1.0;
if (d == 1.0) {
fragColor.rgb = vec3(0.0);
return;
}
float d = textureLod(gbufferD, texCoord, 0.0).r * 2.0 - 1.0;
if (d == 1.0) { fragColor.rgb = vec3(0.0); return; }
vec2 enc = g0.rg;
vec3 n;
@ -88,17 +78,13 @@ void main() {
n = normalize(n);
#ifdef _SSRZOnly
if (n.z <= 0.9) {
fragColor.rgb = vec3(0.0);
return;
}
if (n.z <= 0.9) { fragColor.rgb = vec3(0.0); return; }
#endif
vec4 viewNormal = vec4(n, 1.0);
viewNormal = tiV * viewNormal;
vec4 viewNormal = tiV * vec4(n, 1.0);
vec3 viewPos = getPosView(viewRay, d, cameraProj);
vec3 reflected = normalize(reflect((viewPos), normalize(viewNormal.xyz)));
vec3 reflected = normalize(reflect(viewPos, viewNormal.xyz));
hitCoord = viewPos.xyz;
vec3 dir = reflected * max(ssrMinRayStep, -viewPos.z) * (1.0 - rand(texCoord) * ssrJitter * roughness);
@ -109,17 +95,14 @@ void main() {
float reflectivity = 1.0 - roughness;
float intensity = pow(reflectivity, ssrFalloffExp) *
screenEdgeFactor * clamp(-reflected.z, 0.0, 1.0) *
clamp((ssrSearchDist - length(viewPos.xyz - hitCoord)) * (1.0 / ssrSearchDist), 0.0, 1.0) * coords.w;
screenEdgeFactor *
clamp(-reflected.z, 0.0, 1.0) *
clamp((ssrSearchDist - length(viewPos.xyz - hitCoord)) *
(1.0 / ssrSearchDist), 0.0, 1.0) *
coords.w;
intensity = clamp(intensity, 0.0, 1.0);
if (intensity == 0.0) {
fragColor.rgb = vec3(0.0);
return;
}
vec3 reflCol = texture(tex, coords.xy).rgb;
vec3 reflCol = textureLod(tex, coords.xy, 0.0).rgb;
reflCol = clamp(reflCol, 0.0, 1.0);
fragColor.rgb = reflCol * intensity * 0.5;
}

View File

@ -3,7 +3,6 @@
{
"name": "ssr_pass",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [

View File

@ -19,18 +19,18 @@ vec3 getPosView(const vec3 viewRay, const float depth, const vec2 cameraProj) {
}
vec3 getPos(const vec3 eye, const vec3 eyeLook, const vec3 viewRay, const float depth, const vec2 cameraProj) {
vec3 vray = normalize(viewRay);
// eyeLook, viewRay should be normalized
float linearDepth = cameraProj.y / ((depth * 0.5 + 0.5) - cameraProj.x);
float viewZDist = dot(eyeLook, vray);
vec3 wposition = eye + vray * (linearDepth / viewZDist);
float viewZDist = dot(eyeLook, viewRay);
vec3 wposition = eye + viewRay * (linearDepth / viewZDist);
return wposition;
}
vec3 getPosNoEye(const vec3 eyeLook, const vec3 viewRay, const float depth, const vec2 cameraProj) {
vec3 vray = normalize(viewRay);
// eyeLook, viewRay should be normalized
float linearDepth = cameraProj.y / ((depth * 0.5 + 0.5) - cameraProj.x);
float viewZDist = dot(eyeLook, vray);
vec3 wposition = vray * (linearDepth / viewZDist);
float viewZDist = dot(eyeLook, viewRay);
vec3 wposition = viewRay * (linearDepth / viewZDist);
return wposition;
}

View File

@ -3,7 +3,6 @@
{
"name": "supersample_resolve",
"depth_write": false,
"color_write_alpha": false,
"compare_mode": "always",
"cull_mode": "none",
"links": [

View File

@ -25,7 +25,7 @@ out float fragColor[2];
void main() {
float depth = texture(gbufferD, texCoord).r * 2.0 - 1.0;
vec3 p = getPos(eye, eyeLook, viewRay, depth, cameraProj);
vec3 p = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
vec4 lightPosition = LWVP * vec4(p, 1.0);
vec3 lPos = lightPosition.xyz / lightPosition.w;

View File

@ -70,7 +70,7 @@ void main() {
float pixelRayMarchNoise = texture(snoise, texCoord * 100).r * 2.0 - 1.0;
float depth = texture(gbufferD, texCoord).r * 2.0 - 1.0;
vec3 worldPos = getPos(eye, eyeLook, viewRay, depth, cameraProj);
vec3 worldPos = getPos(eye, eyeLook, normalize(viewRay), depth, cameraProj);
vec3 viewVec = worldPos - eye;
float worldPosDist = length(viewVec);

View File

@ -179,7 +179,8 @@ void main() {
}
vec3 color = vec3(1.0);//colorOriginal.rgb;
vec3 position = getPos(eye, eyeLook, viewRay, gdepth, cameraProj);
vec3 vray = normalize(viewRay);
vec3 position = getPos(eye, eyeLook, vray, gdepth, cameraProj);
if (eye.z < seaLevel) {
// fragColor = colorOriginal;
@ -217,7 +218,7 @@ void main() {
// vec2 texco = texCoord.xy;
// texco.x += sin((time) * 0.002 + 3.0 * abs(position.z)) * (refractionScale * min(depthZ, 1.0));
// vec3 refraction = texture(tex, texco).rgb;
// vec3 _p = getPos(eye, eyeLook, viewRay, 1.0 - texture(gbuffer0, texco).a, cameraProj);
// vec3 _p = getPos(eye, eyeLook, vray, 1.0 - texture(gbuffer0, texco).a, cameraProj);
// if (_p.z > seaLevel) {
// refraction = colorOriginal.rgb;
// }

View File

@ -300,6 +300,17 @@ class RenderPathDeferred {
path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend");
#if rp_ssr_half
{
path.loadShader("shader_datas/downsample_depth/downsample_depth");
var t = new RenderTargetRaw();
t.name = "half";
t.width = 0;
t.height = 0;
t.scale = 0.5;
t.format = "DEPTH16";
path.createRenderTarget(t);
}
{
var t = new RenderTargetRaw();
t.name = "ssra";
@ -750,13 +761,19 @@ class RenderPathDeferred {
#if rp_ssr_half
var targeta = "ssra";
var targetb = "ssrb";
path.setTarget("half");
path.bindTarget("_main", "texdepth");
path.drawShader("shader_datas/downsample_depth/downsample_depth");
var targetdepth = "_half";
#else
var targeta = "buf";
var targetb = "gbuffer1";
var targetdepth = "_main";
#end
path.setTarget(targeta);
path.bindTarget("tex", "tex");
path.bindTarget("_main", "gbufferD");
path.bindTarget(targetdepth, "gbufferD");
path.bindTarget("gbuffer0", "gbuffer0");
path.bindTarget("gbuffer1", "gbuffer1");
path.drawShader("shader_datas/ssr_pass/ssr_pass");

View File

@ -308,6 +308,7 @@ def build():
assets.add_shader_pass('blur_adaptive_pass')
if rpdat.arm_ssr_half_res:
assets.add_khafile_def('rp_ssr_half')
assets.add_shader_pass('downsample_depth')
if rpdat.rp_ssr_z_only:
wrd.world_defs += '_SSRZOnly'

View File

@ -486,8 +486,8 @@ const float seaFade = """ + str(round(rpdat.arm_ocean_fade * 100) / 100) + """;
if rpdat.rp_ssgi == 'SSAO' or rpdat.rp_volumetriclight:
scale = 0.5 if rpdat.arm_ssao_half_res else 1.0
f.write(
"""const float ssaoSize = """ + str(round((rpdat.arm_ssgi_step / 16) * 100) / 100) + """;
const float ssaoStrength = """ + str(round((rpdat.arm_ssgi_strength / 10) * 100) / 100) + """;
"""const float ssaoSize = """ + str(round((rpdat.arm_ssgi_step / 32) * 100) / 100) + """;
const float ssaoStrength = """ + str(round((rpdat.arm_ssgi_strength / 2) * 100) / 100) + """;
const float ssaoTextureScale = """ + str(scale) + """;
""")
if rpdat.rp_ssgi == 'RTGI' or rpdat.rp_ssgi == 'RTAO':