Download - Graphics Programming Workshop

Transcript

Graphics Programming Workshop

Graphics Programming WorkshopStephanie Hurlburt

Before I start talkingDownload Cinderhttps://libcinder.org/downloadWindows users: download Visual Studiohttps://www.visualstudio.com/products/visual-studio-community-vsMac users: download XCodehttps://developer.apple.com/xcode/download/

What is graphics programming?

SIGGRAPH 2015 Technical Papers https://www.youtube.com/watch?v=XrYkEhs2FdA

What is graphics programming?

Cinder Creative Coding https://www.youtube.com/watch?v=uq1HetZMdfc

What is graphics programming?

Oculus Medium https://www.youtube.com/watch?v=IreEK-abHio

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 Codexhttp://graphicscodex.com/ Real Time Renderinghttp://www.realtimerendering.com/Learn OpenGLhttp://learnopengl.com/ Making WebGL Dancehttp://acko.net/files/fullfrontal/fullfrontal/webglmath/online.html 3D Graphics Tutorialhttp://petercollingridge.appspot.com/3D-tutorial

Modern OpenGL Tutorialshttp://ogldev.atspace.co.uk Interactive 3D Graphicshttps://www.udacity.com/course/interactive-3d-graphics--cs291 A Trip Through the Graphics Pipelinehttps://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-graphics-pipeline-2011-index/ The Book of Shadershttp://patriciogonzalezvivo.com/2015/thebookofshaders/

Great graphics programming resourcesGLSL Sandboxhttp://glslsandbox.com/ Shadertoyhttps://www.shadertoy.com/ Getting Started with Cinderhttps://libcinder.org/docs/guides/opengl/index.html Processing Tutorialshttps://processing.org/tutorials/ OpenFrameworks Tutorialshttp://openframeworks.cc/tutorials/ SIGGRAPH Papershttp://kesen.realtimerendering.com/ Immersive Linear Algebrahttp://immersivemath.com/ila/index.htmlRender Hell 2.0http://simonschreibt.de/gat/renderhell/ OpenGL SuperBiblehttp://www.openglsuperbible.com/