Parcourir la source

nacl: workaround for ANGLE issue #258 where GLSL mod() is badly translated

in HLSL.
legacy
Sam Hocevar sam il y a 13 ans
Parent
révision
07520f26f2
1 fichiers modifiés avec 18 ajouts et 18 suppressions
  1. +18
    -18
      test/tutorial/tut03.cpp

+ 18
- 18
test/tutorial/tut03.cpp Voir le fichier

@@ -393,8 +393,8 @@ public:
""
"float mylen(vec2 p) {"
//" return abs(p.x) + abs(p.y);"
//" return p.x * p.x + p.y * p.y;"
" return length(p);"
" return 0.001 + p.x * p.x + p.y * p.y;"
//" return 0.001 + length(p);"
"}"
""
/* Get the coordinate of the nearest point in slice 0 in xy,
@@ -407,10 +407,11 @@ public:
" p += vec2(in_ZoomSettings[0][0], -in_ZoomSettings[0][1]);"
" p += vec2(0.5, 0.5);"
" vec2 q = p + 0.5 * in_TexelSize.xy;"
" q -= mod(q, 2.0 * in_TexelSize.xy);"
" q += 0.5 * in_TexelSize.xy;"
" q = in_TexelSize.xy"
" * (1.0 + 2.0 * floor(q * 0.5 * in_TexelSize.zw));"
" vec2 r = q - 0.5 * in_TexelSize.xy;"
" float l = (abs(q.x - 0.5) < 0.5 && abs(q.y - 0.5) < 0.5)"
" ? 1.0 / mylen(q - p) : 0.0;"
" ? 1.0 / mylen(r - p) : 0.0;"
" return vec3(q * vec2(1.0, 0.25), l);"
"}"
""
@@ -420,10 +421,11 @@ public:
" p += vec2(in_ZoomSettings[1][0], -in_ZoomSettings[1][1]);"
" p += vec2(0.5, 0.5);"
" vec2 q = p + -0.5 * in_TexelSize.xy;"
" q -= mod(q, 2.0 * in_TexelSize.xy);"
" q += 1.5 * in_TexelSize.xy;"
" q = in_TexelSize.xy"
" * (1.0 + 2.0 * floor(q * 0.5 * in_TexelSize.zw));"
" vec2 r = q - -0.5 * in_TexelSize.xy;"
" float l = (abs(q.x - 0.5) < 0.5 && abs(q.y - 0.5) < 0.5)"
" ? 1.0 / mylen(q - p) : 0.0;"
" ? 1.0 / mylen(r - p) : 0.0;"
" return vec3(q * vec2(1.0, 0.25) + vec2(0.0, 0.25), l);"
"}"
""
@@ -433,10 +435,11 @@ public:
" p += vec2(in_ZoomSettings[2][0], -in_ZoomSettings[2][1]);"
" p += vec2(0.5, 0.5);"
" vec2 q = p + vec2(0.5, -0.5) * in_TexelSize.xy;"
" q -= mod(q, 2.0 * in_TexelSize.xy);"
" q += vec2(0.5, 1.5) * in_TexelSize.xy;"
" q = in_TexelSize.xy"
" * (1.0 + 2.0 * floor(q * 0.5 * in_TexelSize.zw));"
" vec2 r = q - vec2(0.5, -0.5) * in_TexelSize.xy;"
" float l = (abs(q.x - 0.5) < 0.5 && abs(q.y - 0.5) < 0.5)"
" ? 1.0 / mylen(q - p) : 0.0;"
" ? 1.0 / mylen(r - p) : 0.0;"
" return vec3(q * vec2(1.0, 0.25) + vec2(0.0, 0.50), l);"
"}"
""
@@ -446,10 +449,11 @@ public:
" p += vec2(in_ZoomSettings[3][0], -in_ZoomSettings[3][1]);"
" p += vec2(0.5, 0.5);"
" vec2 q = p + vec2(-0.5, 0.5) * in_TexelSize.xy;"
" q -= mod(q, 2.0 * in_TexelSize.xy);"
" q += vec2(1.5, 0.5) * in_TexelSize.xy;"
" q = in_TexelSize.xy"
" * (1.0 + 2.0 * floor(q * 0.5 * in_TexelSize.zw));"
" vec2 r = q - vec2(-0.5, 0.5) * in_TexelSize.xy;"
" float l = (abs(q.x - 0.5) < 0.5 && abs(q.y - 0.5) < 0.5)"
" ? 1.0 / mylen(q - p) : 0.0;"
" ? 1.0 / mylen(r - p) : 0.0;"
" return vec3(q * vec2(1.0, 0.25) + vec2(0.0, 0.75), l);"
"}"
""
@@ -459,10 +463,6 @@ public:
#else
" vec2 coord = gl_TexCoord[0].xy;"
#endif
/* Slightly shift our pixel so that it does not lie at
* an exact texel boundary. This would lead to visual
* artifacts. */
" coord -= 0.1 * in_TexelSize.xy;"
/* Get a pixel from each slice */
" vec3 k0 = nearest0(coord);"
" vec3 k1 = nearest1(coord);"


Chargement…
Annuler
Enregistrer