mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
examples/shader: bug fix: wrong function usages
The tex-coord should have been modified by the source texture region/size, rather than the destination texture's.
This commit is contained in:
parent
4395d91c6b
commit
93c09633ee
@ -23,37 +23,37 @@ var ScreenSize vec2
|
|||||||
|
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
const (
|
const (
|
||||||
BLURSCALEX = 0.45
|
blurScaleX = 0.45
|
||||||
LOWLUMSCAN = 5.0
|
lowLumScan = 5.0
|
||||||
HILUMSCAN = 10.0
|
hiLumScan = 10.0
|
||||||
BRIGHTBOOST = 1.25
|
BrightBoost = 1.25
|
||||||
MASK_DARK = 0.25
|
maskDark = 0.25
|
||||||
MASK_FADE = 0.8
|
maskFade = 0.8
|
||||||
)
|
)
|
||||||
|
|
||||||
pos := texCoord
|
pos := texCoord
|
||||||
origin, size := imageDstRegionOnTexture()
|
origin, size := imageSrcRegionOnTexture()
|
||||||
pos -= origin
|
pos -= origin
|
||||||
pos /= size
|
pos /= size
|
||||||
|
|
||||||
maskFade := 0.3333 * MASK_FADE
|
maskFade := 0.3333 * maskFade
|
||||||
invDims := 1.0 / imageDstTextureSize().xy
|
invDims := 1.0 / imageSrcTextureSize().xy
|
||||||
p := pos * imageDstTextureSize()
|
p := pos * imageSrcTextureSize()
|
||||||
i := floor(p) + 0.50
|
i := floor(p) + 0.50
|
||||||
f := p - i
|
f := p - i
|
||||||
p = (i + 4.0*f*f*f) * invDims
|
p = (i + 4.0*f*f*f) * invDims
|
||||||
p.x = mix(p.x, pos.x, BLURSCALEX)
|
p.x = mix(p.x, pos.x, blurScaleX)
|
||||||
Y := f.y * f.y
|
Y := f.y * f.y
|
||||||
YY := Y * Y
|
YY := Y * Y
|
||||||
whichmask := fract(pos.x * -0.4999)
|
whichmask := fract(pos.x * -0.4999)
|
||||||
mask := 1.0
|
mask := 1.0
|
||||||
if whichmask < 0.5 {
|
if whichmask < 0.5 {
|
||||||
mask -= MASK_DARK
|
mask -= maskDark
|
||||||
}
|
}
|
||||||
|
|
||||||
clr := imageSrc2At(p*size + origin).rgb
|
clr := imageSrc2At(p*size + origin).rgb
|
||||||
scanLineWeight := (BRIGHTBOOST - LOWLUMSCAN*(Y-2.05*YY))
|
scanLineWeight := (BrightBoost - lowLumScan*(Y-2.05*YY))
|
||||||
scanLineWeightB := 1.0 - HILUMSCAN*(YY-2.8*YY*Y)
|
scanLineWeightB := 1.0 - hiLumScan*(YY-2.8*YY*Y)
|
||||||
|
|
||||||
return vec4(clr.rgb*mix(scanLineWeight*mask, scanLineWeightB, dot(clr.rgb, vec3(maskFade))), 1.0)
|
return vec4(clr.rgb*mix(scanLineWeight*mask, scanLineWeightB, dot(clr.rgb, vec3(maskFade))), 1.0)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user