mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Replace if statements in hybridFilter
if statements are bad for performance in GLSL
This commit is contained in:
parent
2b42e02e69
commit
d62a653e83
|
@ -400,21 +400,17 @@ namespace glsl {
|
|||
" // But we divide it by 2, since fwidth() is adding abs(dx) + abs(dy). \n"
|
||||
" mediump vec2 fragment_size = fwidth(denorm_uv) / 2.0; \n"
|
||||
" \n"
|
||||
" // Only do this if fragment is smaller than 1 texel. \n"
|
||||
" if (fragment_size.s < 1.0) { \n"
|
||||
" // don't make the transition more than one fragment (+/- 0.5 fragment) \n"
|
||||
" mediump float radius = min(fragment_size.s, 0.5); \n"
|
||||
" ratio.s = smoothstep(0.5 - radius, \n"
|
||||
" 0.5 + radius, \n"
|
||||
" ratio.s); \n"
|
||||
" } \n"
|
||||
" if (fragment_size.t < 1.0) { \n"
|
||||
" // don't make the transition more than one fragment (+/- 0.5 fragment) \n"
|
||||
" mediump float radius = min(fragment_size.t, 0.5); \n"
|
||||
" ratio.t = smoothstep(0.5 - radius, \n"
|
||||
" 0.5 + radius, \n"
|
||||
" ratio.t); \n"
|
||||
" } \n"
|
||||
" mediump float is_frag_gt1, radius; \n"
|
||||
" // Do nothing if fragment is greater than 1 texel \n"
|
||||
" // Don't make the transition more than one fragment (+/- 0.5 fragment) \n"
|
||||
" is_frag_gt1 = step(1.0, fragment_size.s); \n"
|
||||
" radius = min(fragment_size.s, 0.5); \n"
|
||||
" ratio.s = ratio.s * is_frag_gt1 + smoothstep(0.5 - radius, \n"
|
||||
" 0.5 + radius, ratio.s) * (1.0 - is_frag_gt1); \n"
|
||||
" is_frag_gt1 = step(1.0, fragment_size.t); \n"
|
||||
" radius = min(fragment_size.t, 0.5); \n"
|
||||
" ratio.t = ratio.t * is_frag_gt1 + smoothstep(0.5 - radius, \n"
|
||||
" 0.5 + radius, ratio.t) * (1.0 - is_frag_gt1); \n"
|
||||
" \n"
|
||||
" // now bump the coord to the texel using ratio \n"
|
||||
" mediump vec2 new_denorm_uv = low_corner + ratio; \n"
|
||||
|
|
Loading…
Reference in New Issue
Block a user