Graphics Programming Workshop

of 21/21
Graphics Programming Workshop Stephanie Hurlburt
  • date post

  • Category


  • view

  • download


Embed Size (px)

Transcript of Graphics Programming Workshop

Graphics Programming Workshop

Graphics Programming WorkshopStephanie Hurlburt

Before I start talkingDownload Cinder users: download Visual Studio users: download XCode

What is graphics programming?

SIGGRAPH 2015 Technical Papers

What is graphics programming?

Cinder Creative Coding

What is graphics programming?

Oculus Medium

Get into a good headspaceThese concepts will feel confusing and newSome 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 nowBe patient, relax, be nice to yourself, have fun!

Get into a good headspaceThis workshop was meant to give you a taste of what its like to do low-level graphicsI purposefully will not dive too deep into any subjects. Were aiming to understand high level concepts, and enough to build something beautiful fast while still coding in C++/OpenGLIts how I learned graphics just diving into a big low-level codebase, and figuring things out as I go

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 isnt possible now in graphics, and how can we make it possible?

Whats a Graphics Processor Unit (GPU)?Its hardware made with drawing images in mind!The CPU sends it data needed for drawingMuch, much more parallelized than the CPUThis does come with downsides!Its good for things other than graphics, too!

What is OpenGL?It allows you to tell your GPU what to do, in CClear the screen, set up the camera, start drawing, go!OpenGL is just a standard. It tells the world what should be possible on GPUs.Its up to the GPU manufacturers to implement the standard.You may have heard of GLSLPart of the OpenGL ecosystemGives us control over shading, a particular part of graphics processing

Whats my job description?Im a Graphics EngineerI build a graphics engine with C++/OpenGLPart coding and making things work, part research and constantly learning

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 unleashIn digital artIn computing!Its like solving math puzzles and getting rewarded by doing something never before possible in art.Its 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.

Lets do a sample together, to get started.

About CinderWere not using direct C++/OpenGL, were using C++/Cinder.Cinder is built on top of OpenGL all Cinder calls turn into OpenGL calls.Its a great way to learn OpenGL while building things quickly

Particle SphereGo 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.Lets talk about how to modify this.

Particle Sphere:Control the movement of your particles

Open up GPUSphereParticles -> Assets -> particleUpdate.vsThis 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 (Thats 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 particles 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 its changedTry changing dt2 to 0.0f, for example! Oh no!

Particle Sphere:Create the initial particle layoutOpen ParticleSphereGPUApp.cppWe first create an array of ParticlesEach particle contains the properties we modified our vertex shaderTheyre initially created on the CPU (in the Particle struct at the top of this file), and thats where their initial positions are set.Then set the initial positions of all our particles.That for loops 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.

Particle Sphere: Future WorkThats really it when it comes to modifying this projects core functionality.Notice the comments around fragment shaders: were only using a special vertex shader the fragment shader only sets each particle to Cinders 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 youd need to do to enable collision.Try out the ParticleSphereCPU samples, and the other particle samples.

Now try some other samples!Im 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. Its common to frequently look up references to figure out how things are working.Have fun!!!

Great graphics programming resourcesGraphics Codex Real Time Rendering OpenGL Making WebGL Dance 3D Graphics Tutorial

Modern OpenGL Tutorials Interactive 3D Graphics A Trip Through the Graphics Pipeline The Book of Shaders

Great graphics programming resourcesGLSL Sandbox Shadertoy Getting Started with Cinder Processing Tutorials OpenFrameworks Tutorials SIGGRAPH Papers Immersive Linear Algebra Hell 2.0 OpenGL SuperBible