Skip to content
Snippets Groups Projects
Commit 7e3b7f9b authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

More rlv sphere shader fixes

parent 66564c88
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
* *
*/ */
/*[EXTRA_CODE_HERE]*/
#ifdef DEFINE_GL_FRAGCOLOR #ifdef DEFINE_GL_FRAGCOLOR
out vec4 frag_color; out vec4 frag_color;
#else #else
...@@ -43,6 +45,9 @@ uniform vec2 rlvEffectParam5; // Blur direction (not used for blend) ...@@ -43,6 +45,9 @@ uniform vec2 rlvEffectParam5; // Blur direction (not used for blend)
#define SPHERE_PARAMS rlvEffectParam4 #define SPHERE_PARAMS rlvEffectParam4
#define BLUR_DIRECTION rlvEffectParam5.xy #define BLUR_DIRECTION rlvEffectParam5.xy
vec4 getPositionWithDepth(vec2 pos_screen, float depth);
float getDepth(vec2 pos_screen);
vec3 blur13(sampler2D source, vec2 tc, vec2 direction) vec3 blur13(sampler2D source, vec2 tc, vec2 direction)
{ {
vec4 color = vec4(0.0); vec4 color = vec4(0.0);
...@@ -120,8 +125,6 @@ void main() ...@@ -120,8 +125,6 @@ void main()
effectStrength = mix(effectStrength, mix(0, SPHERE_VALUEMIN, SPHERE_DISTEXTEND.x), distance < SPHERE_DISTMIN); effectStrength = mix(effectStrength, mix(0, SPHERE_VALUEMIN, SPHERE_DISTEXTEND.x), distance < SPHERE_DISTMIN);
effectStrength = mix(effectStrength, mix(0, SPHERE_VALUEMAX, SPHERE_DISTEXTEND.y), distance > SPHERE_DISTMAX); effectStrength = mix(effectStrength, mix(0, SPHERE_VALUEMAX, SPHERE_DISTEXTEND.y), distance > SPHERE_DISTMAX);
vec3 fragColor ; vec3 fragColor ;
switch (rlvEffectMode) switch (rlvEffectMode)
{ {
...@@ -141,13 +144,10 @@ void main() ...@@ -141,13 +144,10 @@ void main()
break; break;
case 4: // Pixelate case 4: // Pixelate
{ {
if (effectStrength > 0) effectStrength = sign(effectStrength);
{ float pixelWidth = max(1, round(SPHERE_PARAMS.x * effectStrength)) / screen_res.x;
effectStrength = sign(effectStrength); float pixelHeight = max(1, round(SPHERE_PARAMS.y * effectStrength)) / screen_res.y;
vec2 pixelSize = vec2(1.0) / round(SPHERE_PARAMS.xy * vec2(effectStrength)); fragTC = vec2(pixelWidth * floor(fragTC.x / pixelWidth), pixelHeight * floor(fragTC.y / pixelHeight));
fragTC = (floor(fragTC / pixelSize) * pixelSize) + 0.5 / screen_res;
}
fragColor = texture(diffuseRect, fragTC).rgb; fragColor = texture(diffuseRect, fragTC).rgb;
} }
break; break;
......
...@@ -45,6 +45,9 @@ uniform vec2 rlvEffectParam5; // Blur direction (not used for blend) ...@@ -45,6 +45,9 @@ uniform vec2 rlvEffectParam5; // Blur direction (not used for blend)
#define SPHERE_PARAMS rlvEffectParam4 #define SPHERE_PARAMS rlvEffectParam4
#define BLUR_DIRECTION rlvEffectParam5.xy #define BLUR_DIRECTION rlvEffectParam5.xy
vec4 getPositionWithDepth(vec2 pos_screen, float depth);
float getDepth(vec2 pos_screen);
vec3 blur13(sampler2D source, vec2 tc, vec2 direction) vec3 blur13(sampler2D source, vec2 tc, vec2 direction)
{ {
vec4 color = vec4(0.0); vec4 color = vec4(0.0);
...@@ -114,7 +117,6 @@ vec3 chromaticAberration(sampler2D source, vec2 tc, vec2 redDrift, vec2 blueDrif ...@@ -114,7 +117,6 @@ vec3 chromaticAberration(sampler2D source, vec2 tc, vec2 redDrift, vec2 blueDrif
void main() void main()
{ {
vec2 fragTC = vary_fragcoord.xy; vec2 fragTC = vary_fragcoord.xy;
float fragDepth = texture(depthMap, fragTC).x;
vec3 fragPosLocal = getPositionWithDepth(fragTC, getDepth(fragTC)).xyz; vec3 fragPosLocal = getPositionWithDepth(fragTC, getDepth(fragTC)).xyz;
float distance = length(fragPosLocal.xyz - SPHERE_ORIGIN); float distance = length(fragPosLocal.xyz - SPHERE_ORIGIN);
...@@ -153,13 +155,10 @@ void main() ...@@ -153,13 +155,10 @@ void main()
} }
else if (rlvEffectMode == 4) // Pixelate else if (rlvEffectMode == 4) // Pixelate
{ {
if (effectStrength > 0) effectStrength = sign(effectStrength);
{ float pixelWidth = max(1, round(SPHERE_PARAMS.x * effectStrength)) / screen_res.x;
effectStrength = sign(effectStrength); float pixelHeight = max(1, round(SPHERE_PARAMS.y * effectStrength)) / screen_res.y;
vec2 pixelSize = vec2(1.0) / round(SPHERE_PARAMS.xy * vec2(effectStrength)); fragTC = vec2(pixelWidth * floor(fragTC.x / pixelWidth), pixelHeight * floor(fragTC.y / pixelHeight));
fragTC = (floor(fragTC / pixelSize) * pixelSize) + 0.5 / screen_res;
}
fragColor = texture(diffuseRect, fragTC).rgb; fragColor = texture(diffuseRect, fragTC).rgb;
} }
......
...@@ -19,7 +19,6 @@ ATTRIBUTE vec3 position; ...@@ -19,7 +19,6 @@ ATTRIBUTE vec3 position;
uniform vec2 screen_res; uniform vec2 screen_res;
VARYING vec2 vary_fragcoord; VARYING vec2 vary_fragcoord;
VARYING vec3 vary_position;
void main() void main()
{ {
...@@ -27,7 +26,5 @@ void main() ...@@ -27,7 +26,5 @@ void main()
vec4 pos = vec4(position.xyz, 1.0); vec4 pos = vec4(position.xyz, 1.0);
gl_Position = pos; gl_Position = pos;
vary_fragcoord = (pos.xy*0.5+0.5);
vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
vary_position = (vec4(1, 0, 0, 1.0)).xyz;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment