forked from SCP-CB-CPP/scpcb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEffects.bb
More file actions
72 lines (55 loc) · 1.94 KB
/
Copy pathEffects.bb
File metadata and controls
72 lines (55 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Global GammaEffect%, FXAAEffect%
Global PostEffectQuad%, QuadCamera%, PostEffect%
Global ScreenTexture%
Global PixelWidth# = 0, PixelHeight# = 0
If GetGraphicsLevel() < 100
PixelWidth# = 0.5 / GraphicWidth
PixelHeight# = 0.5 / GraphicHeight
EndIf
Function InitPostProcess()
ScreenTexture = CreateTexture(GraphicWidth, GraphicHeight, 1 + 1024)
GammaEffect = LoadEffect_Strict("GFX\shaders\Gamma.fx")
FXAAEffect = LoadEffect_Strict("GFX\shaders\FXAA.fx")
PostEffectQuad = CreateFullscreenQuad()
EntityTexture(PostEffectQuad, ScreenTexture, 0, 0)
EntityOrder(PostEffectQuad, 10000000)
EntityFX(PostEffectQuad, 8)
HideEntity(PostEffectQuad)
QuadCamera = CreateCamera()
CameraClsMode(QuadCamera, 0, 0)
HideEntity(QuadCamera)
PostEffect = 0
End Function
Function UpdatePostProcess()
ProcessGammaEffect(ScreenGamma)
If Opt_AntiAlias Then ProcessFXAAEffect()
End Function
Function ProcessGammaEffect(gamma#)
EffectFloat(GammaEffect, "Gamma", lerp(gamma, 1.0, 0.3)) ; Limit gamma
RenderEffectQuad(GammaEffect, BackBuffer(), "Main")
End Function
Function ProcessFXAAEffect()
RenderEffectQuad(FXAAEffect, BackBuffer(), "Main")
End Function
Function RenderEffectQuad(effect%, buffer%, technique$, blend% = 0)
CopyRect(0, 0, GraphicWidth, GraphicHeight, 0, 0, BackBuffer(), TextureBuffer(ScreenTexture))
SetQuadEffect(effect)
ShowEntity(PostEffectQuad)
EntityBlend(PostEffectQuad, blend)
SetBuffer(buffer)
EffectTechnique(effect, technique)
CameraViewport(QuadCamera, 0, 0, GraphicWidth, GraphicHeight)
RenderEntity(QuadCamera, PostEffectQuad)
HideEntity(PostEffectQuad)
End Function
Function CreateFullscreenQuad%(Parent% = 0)
Quad = CreateSprite(Parent)
ScaleSprite(Quad, 1.0, (Float(GraphicHeight) / Float(GraphicWidth)))
MoveEntity(Quad, -PixelWidth, PixelHeight, 1.0001)
Return(Quad)
End Function
Function SetQuadEffect(effect%)
if PostEffect = effect Then Return
EntityEffect PostEffectQuad, effect
PostEffect = effect
End Function