Cytopia icon indicating copy to clipboard operation
Cytopia copied to clipboard

Day/Night cycle shader

Open ghost opened this issue 3 years ago • 0 comments

Requirements

  • You must implement a simple shader that will overlay a color using the multiply blending mode over our MapView
  • This shader must take a rgba color as input parameter, and multiply-blend it over the view
  • This parameter must come for now from settings.json under the Graphics section
  • You must add parsing capabilities from std::string & json in RGBAColor
  • You must modify MapView to create the shader program in the constructor
  • You must modify MapView to run the shader in ::draw
  • You must create a GameTime model which models the time of the game
  • You must create a RepeatedTask with a 1 gamehour interval which dispatches an update to the GameTime model
  • You must create a HourElapsed event which is dispatched by the GameTime model
  • The MapView view must observe the GameTime model and implement a handler for HourElapsed
  • On each gamehour, the MapView must redraw with a different alpha value for the uniform RGBAColor
  • The alpha depends on the current game hour. It must follow the following equation where BASE is the alpha of the RGBAColor configured in settings.json:
alpha = BASE * (1 - clamp((hour - 1)/7, 0, 1) + clamp((hour - 17) / 7, 0 , 1))

ghost avatar Jan 02 '21 20:01 ghost