stagedraw: experimental boss zoom shader tweak

This commit is contained in:
Andrei Alexeyev 2021-12-12 12:38:55 +02:00
parent fc50fcc468
commit b0578cad61
No known key found for this signature in database
GPG key ID: 72D26128040B9690
2 changed files with 19 additions and 6 deletions

View file

@ -1,6 +1,7 @@
#version 330 core
#include "lib/render_context.glslh"
#include "lib/util.glslh"
#include "interface/standard.glslh"
UNIFORM(1) vec2 blur_orig; // center
@ -10,6 +11,10 @@ UNIFORM(4) float rad;
UNIFORM(5) float ratio; // texture h/w
UNIFORM(6) vec4 color;
vec2 distort(vec2 p, float f) {
return mix(p * f * rot(tau * f), p, f);
}
vec3 sampleZoom(vec3 ca) {
vec2 pos = texCoordRaw - blur_orig;
vec2 posProportional = pos * vec2(1, ratio);
@ -17,16 +22,18 @@ vec3 sampleZoom(vec3 ca) {
vec3 z = ca * vec3(length(posProportional) / blur_rad);
vec3 result;
if(all(greaterThan(z, vec3(1.26)))) {
const float threshold = 0.94;
if(all(greaterThan(z, vec3(threshold)))) {
result = texture(tex, texCoordRaw).rgb;
} else {
z = 1.5 * z * z * z;
z = 4 * z * z * z;
z = tanh(z);
z = sqrt(z);
vec2 posR = pos * z.r + blur_orig;
vec2 posG = pos * z.g + blur_orig;
vec2 posB = pos * z.b + blur_orig;
vec2 posR = distort(pos, z.r) + blur_orig;
vec2 posG = distort(pos, z.g) + blur_orig;
vec2 posB = distort(pos, z.b) + blur_orig;
result = vec3(
texture(tex, posR).r,
@ -35,6 +42,12 @@ vec3 sampleZoom(vec3 ca) {
);
}
#if 0
if(result == texture(tex, texCoordRaw).rgb) {
result = vec3(1);
}
#endif
return result;
}

View file

@ -680,7 +680,7 @@ static bool boss_distortion_rule(Framebuffer *fb) {
r_disable(RCAP_DEPTH_TEST);
cmplx fpos = global.boss->pos;;
cmplx pos = fpos + 15 * cdir(global.frames/12.0);
cmplx pos = fpos;
r_shader("boss_zoom");
r_uniform_vec2("blur_orig", creal(pos) / VIEWPORT_W, 1-cimag(pos) / VIEWPORT_H);