1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Fix shader compilation errors in GLSL 3.0

This commit is contained in:
fzurita 2019-11-28 11:26:57 -05:00 committed by Sergey Lipskiy
parent 2b5e8786d1
commit 0abaad4aee

View File

@ -370,47 +370,47 @@ namespace glsl {
" return textureSize(tex, 0); \n"
"#endif \n"
"} \n"
"vec2 norm2denorm(in vec2 uv, in ivec2 texture_size) \n"
"mediump vec2 norm2denorm(in mediump vec2 uv, in ivec2 texture_size) \n"
"{ \n"
" return uv * texture_size - 0.5f; \n"
" return uv * vec2(texture_size) - 0.5f; \n"
"} \n"
"ivec2 denorm2idx(in vec2 d_uv) \n"
"ivec2 denorm2idx(in mediump vec2 d_uv) \n"
"{ \n"
" return ivec2(floor(d_uv)); \n"
"} \n"
"ivec2 norm2idx(in vec2 uv, in ivec2 texture_size) \n"
"ivec2 norm2idx(in mediump vec2 uv, in ivec2 texture_size) \n"
"{ \n"
" return denorm2idx(norm2denorm(uv, texture_size)); \n"
"} \n"
"vec2 idx2norm(in ivec2 idx, in ivec2 texture_size) \n"
"mediump vec2 idx2norm(in ivec2 idx, in ivec2 texture_size) \n"
"{ \n"
" vec2 denorm_uv = vec2(idx) + 0.5f; \n"
" return denorm_uv / texture_size; \n"
" mediump vec2 denorm_uv = vec2(idx) + 0.5f; \n"
" return denorm_uv / vec2(texture_size); \n"
"} \n"
"vec4 texel_fetch(in sampler2D tex, in ivec2 idx, in ivec2 texture_size) \n"
"mediump vec4 texel_fetch(in sampler2D tex, in ivec2 idx, in ivec2 texture_size) \n"
"{ \n"
" vec2 uv = idx2norm(idx, texture_size); \n"
" mediump vec2 uv = idx2norm(idx, texture_size); \n"
" return texture2D(tex, uv); \n"
"} \n"
"vec4 hybridFilter(in sampler2D tex, in vec2 uv) \n"
"mediump vec4 hybridFilter(in sampler2D tex, in mediump vec2 uv) \n"
"{ \n"
" ivec2 texSize = getTextureSize(tex); \n"
" vec2 denorm_uv = norm2denorm(uv,texSize); \n"
" mediump vec2 denorm_uv = norm2denorm(uv,texSize); \n"
" ivec2 idx_low = denorm2idx(denorm_uv); \n"
" vec2 ratio = denorm_uv - idx_low; \n"
" mediump vec2 ratio = denorm_uv - vec2(idx_low); \n"
" ivec2 rounded_idx = idx_low + ivec2(step(0.5f, ratio)); \n"
" \n"
" ivec2 idx00 = idx_low; \n"
" vec4 t00 = texel_fetch(tex, idx00, texSize); \n"
" mediump vec4 t00 = texel_fetch(tex, idx00, texSize); \n"
" \n"
" ivec2 idx01 = idx00 + ivec2(0, 1); \n"
" vec4 t01 = texel_fetch(tex, idx01, texSize); \n"
" mediump vec4 t01 = texel_fetch(tex, idx01, texSize); \n"
" \n"
" ivec2 idx10 = idx00 + ivec2(1, 0); \n"
" vec4 t10 = texel_fetch(tex, idx10, texSize); \n"
" mediump vec4 t10 = texel_fetch(tex, idx10, texSize); \n"
" \n"
" ivec2 idx11 = idx00 + ivec2(1, 1); \n"
" vec4 t11 = texel_fetch(tex, idx11, texSize); \n"
" mediump vec4 t11 = texel_fetch(tex, idx11, texSize); \n"
" \n"
" /* \n"
" * radius is the distance from the edge where interpolation happens. \n"
@ -428,9 +428,9 @@ namespace glsl {
" \n"
" // Here, fwidth() is used to estimte how much denorm_uv changes per fragment. \n"
" // But we divide it by 2, since fwidth() is adding abs(dx) + abs(dy). \n"
" vec2 fragment_size = fwidth(denorm_uv) / 2.0f; \n"
" mediump vec2 fragment_size = fwidth(denorm_uv) / 2.0f; \n"
" \n"
" float is_frag_gt1, radius; \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.0f, fragment_size.s); \n"
@ -443,8 +443,8 @@ namespace glsl {
" 0.5f + radius, ratio.t) * (1.0 - is_frag_gt1); \n"
" \n"
" // interpolate first on S direction then on T. \n"
" vec4 top = mix(t00, t10, ratio.s); \n"
" vec4 bottom = mix(t01, t11, ratio.s); \n"
" mediump vec4 top = mix(t00, t10, ratio.s); \n"
" mediump vec4 bottom = mix(t01, t11, ratio.s); \n"
" return mix(top, bottom, ratio.t); \n"
"} \n"
;