230 likes | 371 Views
CSC 4356 FINAL PROJECT. KEVIN CHERRY. Objective. Class Techniques Shadow Normal Map Point Sprite Water / Mirror Spot / Point Light Common Techniques Skycube HUD Joystick Camera Bob When Walking Sound Collision Detection Custom Techniques Water Fade Off. DEMO. Shadow.
E N D
CSC 4356 FINAL PROJECT KEVIN CHERRY
Objective • Class Techniques • Shadow • Normal Map • Point Sprite • Water / Mirror • Spot / Point Light • Common Techniques • Skycube • HUD • Joystick • Camera Bob When Walking • Sound • Collision Detection • Custom Techniques • Water Fade Off
Shadow • Uses code from notes • Able to render for multiple objects • Stores reversed view matrix in texture so I can get just model matrix in shader
Normal Map • Uses function that copies image file to GL texture index • Diffuse and normal textures are handled in shader • Easy to implement and looks great!
Point Sprite • Got starting code online • Structs • Sprite: GL texture unit, position, color, scale, texture coordinates • ASprite: Same but GL texture unit is array and texture count, texture index, swap delay, and swap counter added
Point Sprite • Render • Creates x,y positions for four vertices • Binds sprite’s texture • Uses triangle strip and texture coordinates • Rendered last so texture’s alpha is blended with scene
Point Sprite • ASprite for animation • 3 images swapped every 80 milliseconds
Water • Same as in project 3 • Not as good looking though? • Perhaps needs more for it to refract?
Mirror • Uses water reflection code • Tricky at first • Must flip over the clipping plane axis • This and reflection in water is the only time you can see player
Spot / Point Light • Couldn’t get spotlight working • Instead objects lit by multiplying white vector based on camera distance in fragment shader • Light flickers with time to simulate fire from match • Light gradually takes effect as match comes up/down
Skycube • Easy to add to scene, hard to get texture mapped right • Most sky cube textures online have small problems • Mapped in Wings and carefully touched up • Moves with player so player never escapes
HUD • Had a lot of problems at first, but then realized a simple solution: • Pop any model tranformations • Reverse view transformations in opposite order • Perform HUD translations • Render
Joystick • Uses glutJoystickFunc with poll interval of 15 • Uses unsigned int as bit mask for buttons • Works for any joystick (buttons will be different)
Joystick • Problem: Glut only recognizes 3 axis • Solution: Glfw • In joystick mapped function, glfw used for 4 axis values • Axis values alter same code as mouse movement • Axis values [-1, 1] • Deadzone set to 0.2
Joystick • Can switch from joystick to keyboard and mouse while game is running • Each switch resets movement values • Switches automatically to keyboard and mouse if joystick is disconnected
Camera Bobbing • Common technique used in majority of games • Running increases bobbing rate • Increases a value as you walk • Uses sin of value converted to radians for y displacement
Sound • Uses FMOD Ex • Used for footsteps • Triggered when y deviation is less than threshold
Collision Detection • Checks camera’s position relative to custom 2D squares • Squares are expressed as center XZ position along with width and depth • If camera is within square • Check distance to all edges • Move to outside of that edge
Water Fade Off • Without this, can see where water is cut by skycube • With it, water fades off and seems to continue off into the distance • Accomplished in shader
What’s Left • More realistic water • More sounds • Background music? • Lens flare? • Recursive mirror rendering • More scenary