mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-06-02 20:18:20 -04:00
added flicker CRT effect, including preferences
This commit is contained in:
parent
0f7293a2d5
commit
8d768b131f
|
@ -33,6 +33,7 @@ type Preferences struct {
|
|||
Scanlines prefs.Bool
|
||||
Interference prefs.Bool
|
||||
Noise prefs.Bool
|
||||
Flicker prefs.Bool
|
||||
Fringing prefs.Bool
|
||||
Ghosting prefs.Bool
|
||||
Phosphor prefs.Bool
|
||||
|
@ -45,6 +46,7 @@ type Preferences struct {
|
|||
ScanlinesFine prefs.Float
|
||||
InterferenceLevel prefs.Float
|
||||
NoiseLevel prefs.Float
|
||||
FlickerLevel prefs.Float
|
||||
FringingAmount prefs.Float
|
||||
GhostingAmount prefs.Float
|
||||
PhosphorLatency prefs.Float
|
||||
|
@ -75,6 +77,7 @@ const (
|
|||
scanlines = true
|
||||
interference = true
|
||||
noise = true
|
||||
flicker = false
|
||||
fringing = true
|
||||
ghosting = true
|
||||
phosphor = true
|
||||
|
@ -86,6 +89,7 @@ const (
|
|||
scanlinesFine = 1.80
|
||||
interferenceLevel = 0.15
|
||||
noiseLevel = 0.19
|
||||
flickerLevel = 0.025
|
||||
fringingAmount = 0.15
|
||||
ghostingAmount = 2.9
|
||||
phosphorLatency = 0.5
|
||||
|
@ -150,6 +154,10 @@ func NewPreferences() (*Preferences, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = p.dsk.Add("crt.flicker", &p.Flicker)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = p.dsk.Add("crt.fringing", &p.Fringing)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -194,6 +202,10 @@ func NewPreferences() (*Preferences, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = p.dsk.Add("crt.flickerLevel", &p.FlickerLevel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = p.dsk.Add("crt.fringingAmount", &p.FringingAmount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -258,6 +270,7 @@ func (p *Preferences) SetDefaults() {
|
|||
p.Scanlines.Set(scanlines)
|
||||
p.Interference.Set(interference)
|
||||
p.Noise.Set(noise)
|
||||
p.Flicker.Set(flicker)
|
||||
p.Fringing.Set(fringing)
|
||||
p.Ghosting.Set(ghosting)
|
||||
p.Phosphor.Set(phosphor)
|
||||
|
@ -269,6 +282,7 @@ func (p *Preferences) SetDefaults() {
|
|||
p.ScanlinesFine.Set(scanlinesFine)
|
||||
p.InterferenceLevel.Set(interferenceLevel)
|
||||
p.NoiseLevel.Set(noiseLevel)
|
||||
p.FlickerLevel.Set(flickerLevel)
|
||||
p.FringingAmount.Set(fringingAmount)
|
||||
p.GhostingAmount.Set(ghostingAmount)
|
||||
p.PhosphorLatency.Set(phosphorLatency)
|
||||
|
|
|
@ -33,6 +33,7 @@ type crtSeqPrefs struct {
|
|||
Scanlines bool
|
||||
Interference bool
|
||||
Noise bool
|
||||
Flicker bool
|
||||
Fringing bool
|
||||
Ghosting bool
|
||||
Phosphor bool
|
||||
|
@ -45,6 +46,7 @@ type crtSeqPrefs struct {
|
|||
ScanlinesFine float64
|
||||
InterferenceLevel float64
|
||||
NoiseLevel float64
|
||||
FlickerLevel float64
|
||||
FringingAmount float64
|
||||
GhostingAmount float64
|
||||
PhosphorLatency float64
|
||||
|
@ -65,6 +67,7 @@ func newCrtSeqPrefs(prefs *crt.Preferences) crtSeqPrefs {
|
|||
Scanlines: prefs.Scanlines.Get().(bool),
|
||||
Interference: prefs.Interference.Get().(bool),
|
||||
Noise: prefs.Noise.Get().(bool),
|
||||
Flicker: prefs.Flicker.Get().(bool),
|
||||
Fringing: prefs.Fringing.Get().(bool),
|
||||
Ghosting: prefs.Ghosting.Get().(bool),
|
||||
Phosphor: prefs.Phosphor.Get().(bool),
|
||||
|
@ -76,6 +79,7 @@ func newCrtSeqPrefs(prefs *crt.Preferences) crtSeqPrefs {
|
|||
ScanlinesFine: prefs.ScanlinesFine.Get().(float64),
|
||||
InterferenceLevel: prefs.InterferenceLevel.Get().(float64),
|
||||
NoiseLevel: prefs.NoiseLevel.Get().(float64),
|
||||
FlickerLevel: prefs.FlickerLevel.Get().(float64),
|
||||
FringingAmount: prefs.FringingAmount.Get().(float64),
|
||||
GhostingAmount: prefs.GhostingAmount.Get().(float64),
|
||||
PhosphorLatency: prefs.PhosphorLatency.Get().(float64),
|
||||
|
|
|
@ -37,6 +37,7 @@ type crtSeqEffectsShader struct {
|
|||
scanlines int32
|
||||
interference int32
|
||||
noise int32
|
||||
flicker int32
|
||||
fringing int32
|
||||
curveAmount int32
|
||||
roundedCornersAmount int32
|
||||
|
@ -46,6 +47,7 @@ type crtSeqEffectsShader struct {
|
|||
scanlinesFine int32
|
||||
interferenceLevel int32
|
||||
noiseLevel int32
|
||||
flickerLevel int32
|
||||
fringingAmount int32
|
||||
time int32
|
||||
rotation int32
|
||||
|
@ -70,6 +72,7 @@ func newCrtSeqEffectsShader(yflip bool) shaderProgram {
|
|||
sh.scanlines = gl.GetUniformLocation(sh.handle, gl.Str("Scanlines"+"\x00"))
|
||||
sh.interference = gl.GetUniformLocation(sh.handle, gl.Str("Interference"+"\x00"))
|
||||
sh.noise = gl.GetUniformLocation(sh.handle, gl.Str("Noise"+"\x00"))
|
||||
sh.flicker = gl.GetUniformLocation(sh.handle, gl.Str("Flicker"+"\x00"))
|
||||
sh.fringing = gl.GetUniformLocation(sh.handle, gl.Str("Fringing"+"\x00"))
|
||||
sh.curveAmount = gl.GetUniformLocation(sh.handle, gl.Str("CurveAmount"+"\x00"))
|
||||
sh.roundedCornersAmount = gl.GetUniformLocation(sh.handle, gl.Str("RoundedCornersAmount"+"\x00"))
|
||||
|
@ -79,6 +82,7 @@ func newCrtSeqEffectsShader(yflip bool) shaderProgram {
|
|||
sh.scanlinesFine = gl.GetUniformLocation(sh.handle, gl.Str("ScanlinesFine"+"\x00"))
|
||||
sh.interferenceLevel = gl.GetUniformLocation(sh.handle, gl.Str("InterferenceLevel"+"\x00"))
|
||||
sh.noiseLevel = gl.GetUniformLocation(sh.handle, gl.Str("NoiseLevel"+"\x00"))
|
||||
sh.flickerLevel = gl.GetUniformLocation(sh.handle, gl.Str("FlickerLevel"+"\x00"))
|
||||
sh.fringingAmount = gl.GetUniformLocation(sh.handle, gl.Str("FringingAmount"+"\x00"))
|
||||
sh.time = gl.GetUniformLocation(sh.handle, gl.Str("Time"+"\x00"))
|
||||
sh.rotation = gl.GetUniformLocation(sh.handle, gl.Str("Rotation"+"\x00"))
|
||||
|
@ -104,6 +108,7 @@ func (sh *crtSeqEffectsShader) setAttributesArgs(env shaderEnvironment,
|
|||
gl.Uniform1i(sh.scanlines, boolToInt32(prefs.Scanlines))
|
||||
gl.Uniform1i(sh.interference, boolToInt32(prefs.Interference))
|
||||
gl.Uniform1i(sh.noise, boolToInt32(prefs.Noise))
|
||||
gl.Uniform1i(sh.flicker, boolToInt32(prefs.Flicker))
|
||||
gl.Uniform1i(sh.fringing, boolToInt32(prefs.Fringing))
|
||||
gl.Uniform1f(sh.curveAmount, float32(prefs.CurveAmount))
|
||||
gl.Uniform1f(sh.roundedCornersAmount, float32(prefs.RoundedCornersAmount))
|
||||
|
@ -113,6 +118,7 @@ func (sh *crtSeqEffectsShader) setAttributesArgs(env shaderEnvironment,
|
|||
gl.Uniform1f(sh.scanlinesFine, float32(prefs.ScanlinesFine))
|
||||
gl.Uniform1f(sh.interferenceLevel, float32(prefs.InterferenceLevel))
|
||||
gl.Uniform1f(sh.noiseLevel, float32(prefs.NoiseLevel))
|
||||
gl.Uniform1f(sh.flickerLevel, float32(prefs.FlickerLevel))
|
||||
gl.Uniform1f(sh.fringingAmount, float32(prefs.FringingAmount))
|
||||
gl.Uniform1f(sh.time, float32(time.Now().Nanosecond())/100000000.0)
|
||||
gl.Uniform1i(sh.rotation, int32(rotation))
|
||||
|
|
|
@ -24,6 +24,7 @@ uniform int ShadowMask;
|
|||
uniform int Scanlines;
|
||||
uniform int Interference;
|
||||
uniform int Noise;
|
||||
uniform int Flicker;
|
||||
uniform int Fringing;
|
||||
uniform float CurveAmount;
|
||||
uniform float RoundedCornersAmount;
|
||||
|
@ -33,6 +34,7 @@ uniform float ScanlinesIntensity;
|
|||
uniform float ScanlinesFine;
|
||||
uniform float InterferenceLevel;
|
||||
uniform float NoiseLevel;
|
||||
uniform float FlickerLevel;
|
||||
uniform float FringingAmount;
|
||||
uniform float Time;
|
||||
|
||||
|
@ -191,9 +193,11 @@ void main() {
|
|||
Crt_Color.b *= max(1.0-NoiseLevel, n);
|
||||
}
|
||||
|
||||
// flicker
|
||||
float level = 0.025;
|
||||
Crt_Color *= (1.0-level*(sin(50.0*Time+uv.y*2.0)*0.5+0.5));
|
||||
}
|
||||
|
||||
// flicker
|
||||
if (Flicker == 1) {
|
||||
Crt_Color *= (1.0-FlickerLevel*(sin(50.0*Time+uv.y*2.0)*0.5+0.5));
|
||||
}
|
||||
|
||||
// fringing (chromatic aberration)
|
||||
|
|
|
@ -64,6 +64,8 @@ func (win *winPrefs) drawCRT() {
|
|||
imgui.Spacing()
|
||||
win.drawNoise()
|
||||
imgui.Spacing()
|
||||
win.drawFlicker()
|
||||
imgui.Spacing()
|
||||
win.drawFringing()
|
||||
imgui.Spacing()
|
||||
win.drawGhosting()
|
||||
|
@ -251,6 +253,31 @@ func (win *winPrefs) drawNoise() {
|
|||
}
|
||||
}
|
||||
|
||||
func (win *winPrefs) drawFlicker() {
|
||||
b := win.img.crtPrefs.Flicker.Get().(bool)
|
||||
if imgui.Checkbox("Flicker##flicker", &b) {
|
||||
win.img.crtPrefs.Flicker.Set(b)
|
||||
}
|
||||
|
||||
f := float32(win.img.crtPrefs.FlickerLevel.Get().(float64))
|
||||
|
||||
var label string
|
||||
|
||||
if f >= 0.06 {
|
||||
label = "very high"
|
||||
} else if f >= 0.04 {
|
||||
label = "high"
|
||||
} else if f >= 0.03 {
|
||||
label = "low"
|
||||
} else {
|
||||
label = "very low"
|
||||
}
|
||||
|
||||
if imgui.SliderFloatV("##flickerlevel", &f, 0.01, 0.06, label, 1.0) {
|
||||
win.img.crtPrefs.FlickerLevel.Set(f)
|
||||
}
|
||||
}
|
||||
|
||||
func (win *winPrefs) drawFringing() {
|
||||
b := win.img.crtPrefs.Fringing.Get().(bool)
|
||||
if imgui.Checkbox("Colour Fringing##fringing", &b) {
|
||||
|
|
Loading…
Reference in a new issue