mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +01:00
graphicsutil: Avoid passing NaN to shaders experimentally (#696)
This commit is contained in:
parent
1807a3f530
commit
bd1fc4439a
@ -56,13 +56,9 @@ varying vec2 varying_tex_coord_min;
|
||||
varying vec2 varying_tex_coord_max;
|
||||
varying vec4 varying_color_scale;
|
||||
|
||||
bool isNaN(float x) {
|
||||
return x != x;
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
varying_tex_coord = vec2(tex_coord[0], tex_coord[1]);
|
||||
if (!isNaN(tex_coord[2]) && !isNaN(tex_coord[3])) {
|
||||
if (tex_coord[2] >= 0.0 && tex_coord[3] >= 0.0) {
|
||||
varying_tex_coord_min = vec2(min(tex_coord[0], tex_coord[2]), min(tex_coord[1], tex_coord[3]));
|
||||
varying_tex_coord_max = vec2(max(tex_coord[0], tex_coord[2]), max(tex_coord[1], tex_coord[3]));
|
||||
} else {
|
||||
|
@ -15,8 +15,6 @@
|
||||
package graphicsutil
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics"
|
||||
"github.com/hajimehoshi/ebiten/internal/opengl"
|
||||
)
|
||||
@ -138,10 +136,6 @@ func QuadIndices() []uint16 {
|
||||
return quadIndices
|
||||
}
|
||||
|
||||
var (
|
||||
nan32 = float32(math.NaN())
|
||||
)
|
||||
|
||||
func Vertex(width, height int, dx, dy, sx, sy float32, cr, cg, cb, ca float32) []float32 {
|
||||
if !isPowerOf2(width) {
|
||||
panic("not reached")
|
||||
@ -160,8 +154,8 @@ func Vertex(width, height int, dx, dy, sx, sy float32, cr, cg, cb, ca float32) [
|
||||
vs[1] = dy
|
||||
vs[2] = sx / wf
|
||||
vs[3] = sy / hf
|
||||
vs[4] = nan32
|
||||
vs[5] = nan32
|
||||
vs[4] = -1
|
||||
vs[5] = -1
|
||||
vs[6] = cr
|
||||
vs[7] = cg
|
||||
vs[8] = cb
|
||||
|
Loading…
Reference in New Issue
Block a user