Graphics Programming Workshop


Published on

For this workshop hosted my Stella Tran (@stella) and myself:

Published in: Software
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Graphics Programming Workshop

  1. 1. Graphics Programming Workshop Stephanie Hurlburt
  2. 2. Before I start talking…  Download Cinder   Windows users: download Visual Studio   Mac users: download XCode 
  3. 3. What is graphics programming?  SIGGRAPH 2015 Technical Papers
  4. 4. What is graphics programming?  Cinder Creative Coding
  5. 5. What is graphics programming?  Oculus Medium
  6. 6. Get into a good headspace  These concepts will feel confusing and new  Some of them still feel confusing to me, and I get paid to do this!  Get used to not knowing a lot, but taking advantage of small pieces you do know to build something great now  Be patient, relax, be nice to yourself, have fun!
  7. 7. Get into a good headspace  This workshop was meant to give you a taste of what it’s like to do low-level graphics  I purposefully will not dive too deep into any subjects. We’re aiming to understand high level concepts, and enough to build something beautiful fast while still coding in C++/OpenGL  It’s how I learned graphics– just diving into a big low-level codebase, and figuring things out as I go
  8. 8. What is graphics programming?  Graphics programmers ask:  How are graphics processed on my computer?  How do GPUs work?  What else can we use the GPU for?  What isn’t possible now in graphics, and how can we make it possible?
  9. 9. What’s a Graphics Processor Unit (GPU)?  It’s hardware made with drawing images in mind!  The CPU sends it data needed for drawing  Much, much more parallelized than the CPU  This does come with downsides!  It’s good for things other than graphics, too!
  10. 10. What is OpenGL?  It allows you to tell your GPU what to do, in C  Clear the screen, set up the camera, start drawing, go!  OpenGL is just a standard. It tells the world what should be possible on GPUs.  It’s up to the GPU manufacturers to implement the standard.  You may have heard of GLSL  Part of the OpenGL ecosystem  Gives us control over shading, a particular part of graphics processing
  11. 11. What’s my job description?  I’m a Graphics Engineer  I build a graphics engine with C++/OpenGL  Part coding and making things work, part research and constantly learning
  12. 12. Why do I love graphics programming?  Graphics programming is a vastly unexplored new medium for art.  The more you know about graphics programming, the more possibilities you can unleash  In digital art  In computing!  It’s like solving math puzzles and getting rewarded by doing something never before possible in art.  It’s like one big, really complicated, mind-blowingly powerful paintbrush!  I can collaborate with a lot of fields– GPUs are used for lots of things!  Mathematics can be an important part of innovating in graphics, and I love math. I can get paid to do math.
  13. 13. Let’s do a sample together, to get started.
  14. 14. About Cinder  We’re not using direct C++/OpenGL, we’re using C++/Cinder.  Cinder is built on top of OpenGL– all Cinder calls turn into OpenGL calls.  It’s a great way to learn OpenGL while building things quickly
  15. 15. Particle Sphere  Go to the directory Cinder is installed in, then Samples -> _openGL -> ParticleSphereGPU. Open your project in your desired IDE.  Build and run the project.  You should see a beautiful rainbow particle system.  Try clicking it and moving your mouse.  Let’s talk about how to modify this.
  16. 16. Particle Sphere: Control the movement of your particles  Open up GPUSphereParticles -> Assets -> particleUpdate.vs  This little piece of code controls all of those seemingly complex movements in the particle system, and is processed completely on the GPU.  This code runs on every particle in your particle system, calculating its position (That’s a lot of particles!)  This particle system is a perfect candidate for GPU processing– none of the particles need to know about each others’ existence, so each particle’s simulation can be safely processed in parallel.  Try to understand what the math is doing by changing the values and seeing what happens.  Save the file, then close and rerun your app to see how it’s changed  Try changing dt2 to 0.0f, for example! Oh no!
  17. 17. Particle Sphere: Create the initial particle layout  Open ParticleSphereGPUApp.cpp  We first create an array of Particles  Each particle contains the properties we modified our vertex shader  They’re initially created on the CPU (in the Particle struct at the top of this file), and that’s where their initial positions are set.  Then set the initial positions of all our particles.  That for loop’s math makes our particles start as a sphere! Try modifying values to see how it works.  Be sure to rebuild and rerun your project each time you make a change.
  18. 18. Particle Sphere: Future Work  That’s really it when it comes to modifying this project’s core functionality.  Notice the comments around fragment shaders: we’re only using a special vertex shader– the fragment shader only sets each particle to Cinder’s default rainbow palette.  Try simply modifying the values discussed in the previous slides. You can make a completely different visual just by doing that.  Try adding a custom fragment shader.  Try adding more physics properties like gravity to the particles, and think about what you’d need to do to enable collision.  Try out the ParticleSphereCPU samples, and the other particle samples.
  19. 19. Now try some other samples!  I’m here to help, and we can go through a few more together too.  I want you to feel comfortable playing around with this unknown code so you can see that you can make interesting visualizations, and then learn more and figure out what you need to be learning to do more!  Remember that there are lots of great resources online too that can help. It’s common to frequently look up references to figure out how things are working.  Have fun!!!
  20. 20. Great graphics programming resources  Graphics Codex   Real Time Rendering   Learn OpenGL   Making WebGL Dance  frontal/webglmath/online.html  3D Graphics Tutorial  m/3D-tutorial  Modern OpenGL Tutorials   Interactive 3D Graphics  eractive-3d-graphics--cs291  A Trip Through the Graphics Pipeline  /07/09/a-trip-through-the-graphics- pipeline-2011-index/  The Book of Shaders  5/thebookofshaders/
  21. 21. Great graphics programming resources  GLSL Sandbox   Shadertoy   Getting Started with Cinder  engl/index.html  Processing Tutorials   OpenFrameworks Tutorials   SIGGRAPH Papers   Immersive Linear Algebra  .html  Render Hell 2.0  ell/  OpenGL SuperBible 