mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
internal/graphics: optimize imageSrcNUnsafeAt
This commit is contained in:
parent
b27b7ec483
commit
b8367da7e2
@ -93,11 +93,9 @@ func imageSrc%[1]dUnsafeAt(pos vec2) vec4 {
|
|||||||
|
|
||||||
func imageSrc%[1]dAt(pos vec2) vec4 {
|
func imageSrc%[1]dAt(pos vec2) vec4 {
|
||||||
// pos is the position in texels of the source texture (= 0th image's texture).
|
// pos is the position in texels of the source texture (= 0th image's texture).
|
||||||
return texture2D(__t%[1]d, %[2]s) *
|
// If pos is in the region, the result is (1, 1). Otherwise, either element is 0.
|
||||||
step(__textureSourceRegionOrigin.x, pos.x) *
|
in := step(__textureSourceRegionOrigin, pos) - step(__textureSourceRegionOrigin + __textureSourceRegionSize, pos)
|
||||||
(1 - step(__textureSourceRegionOrigin.x + __textureSourceRegionSize.x, pos.x)) *
|
return texture2D(__t%[1]d, %[2]s) * in.x * in.y
|
||||||
step(__textureSourceRegionOrigin.y, pos.y) *
|
|
||||||
(1 - step(__textureSourceRegionOrigin.y + __textureSourceRegionSize.y, pos.y))
|
|
||||||
}
|
}
|
||||||
`, i, pos)
|
`, i, pos)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user