Author Topic: Inserting a delay before "CRT glow" effect happens  (Read 1255 times)

steelepdx

  • Newbie
  • *
  • Posts: 2
    • View Profile
Inserting a delay before "CRT glow" effect happens
« on: February 26, 2025, 08:23:56 PM »
I am using Yaron's most excellent "MS-DOS Vintage" (10.4) layout for my classic PC games. I am very inexperienced with Squirrel and how to achieve this. I want the CRT glow effect to basically wait until the game selection screen fades before the glow effect happens. As it stands now, the glow effect happens immediately in the game select screen, before it fades to the snap of the game (currently set to 1000ms). I'd like the CRT glow effect to fade in right as the snap is fading in. I have tried a couple of different things to no avail. Is there someone who can help me out? A minor detail, for sure, but I just thought I would ask. Here is the pertinent code for the glow effect in the layout.nut:

//////////////////////////////////////////////////////////////////////////////////////////////////
// Screen glow

if( my_config["enable_crt_glow"] == "Yes" && ShadersAvailable == 1 )
{
   local shadow_radius = 1600
   local shadow_xoffset = -75
   local shadow_yoffset = -50
   local shadow_alpha = 255
   local shadow_downsample = 0.018

   // creation of first surface with safeguards area
   local xsurf1 = fe.add_surface( shadow_downsample * (video.width + 2*shadow_radius), shadow_downsample * (video.height + 2*shadow_radius) )

   // add a clone of the picture to topmost surface
   local pic1 = xsurf1.add_clone(video)
   pic1.set_pos( shadow_radius*shadow_downsample, shadow_radius*shadow_downsample, video.width*shadow_downsample, video.height*shadow_downsample )

   // creation of second surface
   local xsurf2 = fe.add_surface( xsurf1.width, xsurf1.height )

   // nesting of surfaces
   xsurf1.visible = false
   xsurf1 = xsurf2.add_clone( xsurf1 )
   xsurf1.visible = true

   // deifine and apply blur shaders
   local blursizex = 1.0/xsurf2.width
   local blursizey = 1.0/xsurf2.height
   local kernelsize = shadow_downsample * (shadow_radius * 2) + 1
   local kernelsigma = shadow_downsample * shadow_radius * 0.3

   local shaderH1 = fe.add_shader( Shader.Fragment, fe.script_dir + "gauss_kernsigma_o.glsl" )
   shaderH1.set_texture_param("texture")
   shaderH1.set_param("kernelData", kernelsize, kernelsigma)
   shaderH1.set_param("offsetFactor", blursizex, 0.0)
   xsurf1.shader = shaderH1

   local shaderV1 = fe.add_shader( Shader.Fragment, fe.script_dir + "gauss_kernsigma_o.glsl" )
   shaderV1.set_texture_param("texture")
   shaderV1.set_param("kernelData", kernelsize, kernelsigma)
   shaderV1.set_param("offsetFactor", 0.0, blursizey)
   xsurf2.shader = shaderV1

   // apply black color and alpha channel to shadow
   pic1.alpha = shadow_alpha
   pic1.width = 21
   pic1.height = 16

   // reposition and upsample shadow surface stack
   xsurf2.set_pos( video.x-shadow_radius+shadow_xoffset, video.y-shadow_radius+shadow_yoffset, video.width + 2 * shadow_radius, video.height + 2 * shadow_radius )
}