Pyramid Panic - Feature - Fog of War, Lights & Ghost Vision

in #utopian-io6 years ago (edited)

PyramidPanic.png

Overview

Three visual effects that have been missing from PyramidPanic are:

  • A unique post processing effect for a FogOfWar style feel
  • The ability to add lights to the game
  • Having a separate post processing effect for ghosts once a player dies

These features were added in a PostProcessing feature pull request, allowing all three to be taken advantage of efficiently.


Fog Of War

Fog of war was added to the game, allowing alive players to have a restricted view and knowledge of the world. This effect was accomplished by subclassing the Camera class and creating a FogOfWarCamera which renders the game with fog of war when active.

The style of the FogOfWar was desired to be a pixelated appearance to match the general art style of the videogame.


FogOfWar.png

FogOfWarCamera

The camera used for the fog of war effect is FogOfWarCamera.h. This subclassed camera plugs into the SpriteRendererManager to take advantage of FrameBufferObjects and post processing effects to create the effect.


FogOfWar2.png

The effect can be broken up into three stages. First, all lights visible on the screen are located via the quad tree. Each light has a position, light strength and light colour which determines how it penetrates the fog of war. A black texture is generated which represents fog, with coloured circles representing the lights. The general game screen is rendered into a frame buffer, and then both the fog of war preprocessing texture and the rendered frame buffer texture are fed into a fog of war post processing effect.

FogOfWarCamera.cpp
SpriteRendererManager.cpp

Post Processing Effect

The two textures generated from the FogOfWarCamera are fed into the FogOfWar Shader. This shader takes the FogOfWar preprocessed texture, applies a gaussian blur to it, and then multiplies the preprocessed textured with the standard game rendering.

This effect allows for coloured lights in the preprocessed texture to let the rendered game seep through, being visible despite the fog. Places without lights do not have colour, and are instead rendered near black.

fogOfWar.vs
fogOfWar.fs

Light

'Light' can pierce the fog of war, allowing for not only breaks in the fog to appear, but these breaks to be colourized based on light colour and strength. The intention was for lights to be built in an efficient way for programmers to easily turn on and off lights for any object.

Light Component

The Light.cpp component subclasses Component for integration in the games component entity system. All gameobjects have multiple components. Lights have a setSize and setColor methods for customizing the strength and colour of any particular light. Lights have an OnStart, OnUpdate and OnEnd methods that get called automatically, allowing them to have unique effects such as changing colours over time or flickering.

Light.cpp

Ghost Vision

Once a player dies, they become a ghost. Ghosts can fly through walls and possess various objects around the world. Ghosts do not see fog of war, and instead have the world rendered in a semi-grayscale blue-tinged hue.


GhostVision.png

GhostCamera

GhostCamera subclasses Camera and plugs into SpriteRendererManager to acquire the desired effect. It renders the game into a frame buffer object, then passes the rendered game as a texture into the ghost camera shaders.

GhostCamera.cpp

Post Processing Effect

The effect is found in the shaders. It takes the color that should be rendered, averages it in order to get the grayscale, and then applies a grayscaled texture with a lerped blue value between the grayscaled blue and the rendered blue.

grayscale.fs



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @carsonroscoe I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Utopian Witness!

Participate on Discord. Lets GROW TOGETHER!

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by carsonroscoe from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Thank you for the contribution. It has been approved.

  • Did you mean to merge and include out.txt?
  • Beautiful pull request notes and post.
  • Are you a markdown guru?

Need help? Write a ticket on https://support.utopian.io.
Chat with us on Discord.

[utopian-moderator]

Thank you @helo.

No, I did not mean to merge and include out.txt. I forgot to gitignore it.

Thank you for the kind words on my notes/post/markdown :)

Coin Marketplace

STEEM 0.19
TRX 0.14
JST 0.030
BTC 59715.05
ETH 3186.24
USDT 1.00
SBD 2.42