assignment 3
play

Assignment #3 Which is something you may wish to do since it is - PDF document

Assignment #3 Which is something you may wish to do since it is Assignment #3 So You Want to Write some Procedural Shaders In fact Assignment #3 Assignments Goal is to be able to produce something nicer than Some advice:


  1. Assignment #3 • Which is something you may wish to do since it is Assignment #3 So You Want to Write some Procedural Shaders • In fact… Assignment #3 Assignments • Goal is to be able to produce something nicer than • Some advice: this: – Choose either #1 (Ray tracing) or #2 (radioisity) – #3 will be real time shading… • Challenge will be getting environment set up – #4 – Tone Reproduction • Modification of #1 or #2 • In fact – If you choose to do assignments 1 & 2, you need not do any other. • so…pleasant dreams! Assignment #3 Assignment #3 • Experimentation with procedural shaders • 1. Download: – Cg – Real time shading language (Nvidia) • Three goals: • Support for DirectX 8, 9 and OpenGL1.4 – Download and install a procedural shading • Supposedly graphics card independent system. • Download: – Learn the logistics of assigning a shader to an – http://developer.nvidia.com object – Programming environment for Windows only using Visual – Create/use 3 simple shaders Studio.

  2. Assignment #3 Assignment #3 • 1. Download • If you do not have Visual Studio or if your graphics card is not up to par. – RenderMonkey • For ATI Cards – Renderman shaders • DirectX 8.1+ Support only • Blue Moon Rendering Tools – no longer distributed • http://www.ati.com/developer/sdk/radeonSDK/html/Tools/RenderMonkey.html but… – I can get last version for Windows and Linux/Intel • Aqsis – Open Source Renderman renderer – Win32 and MacOS X – http://www.aqsis.com Assignment #3 Assignment #3 • 2. Attach shaders to objects • 3. Create / use simple shaders – Run the tutorial supplied with the system. – Three required: – For Cg users • Phong • Brick Shader • http://graphics3d.com/guides/cg/index.html • Grab-bag (one of your choice) – For Renderman users • BMRT docs • Renderman for Poets: – http://www.cs.utexas.edu/users/amenta/eog/poets.pdf Assignment #3 Assignment #3 • Image Deliverable • A note on “borrowing” shaders Your – Shaders are like Makefiles choice • Best to take one that works and modify – Not only allow but encourage use of others shaders phong • cgshaders.org • Renderman repository – http://www.renderman.org/RMR/RMRShaders.html brick

  3. Assignment #3 Assignment #3 • Deliverables • A note on “borrowing” shaders – This laptop has a Gforce 4 graphics card. – If you do use other’s shaders, you must – If Cg • Attribute the source • Shader code • Allow or show results of changing shader • Executable arguments. • Instructions on using – If non-Cg • Shader code • Multiple Screen dumps w/varying shader arguments or • Personal demo on your own PC – If Renderman • Shader code • Multiple renderings w/varying shader arguments Assignments Bells and Whistles • 15 points • Grading – Produce single image – Each assignment is worth 20 points: • 20 points • 5 points – for something that compiles – Produce multiple or interactive image with • 10 points – for something that runs incorrectly changing shading argument values • 15 points – for something that runs correctly • Note • 20 points – something that runs + extras – Well structured and documented code – Please, please, please submit readable and – Additional bells and whistles documented code! Due dates Questions so far • If doing both assn 1 & 2 – Are you still sleeping? • If doing assn 1 OR assn 2 – Due Feb 6 th

  4. Real time shading – Cg Cg – vertex and fragment programs Framebuffer Rasterization Assembly & Framebuffer Operations Vertex Fragment Application Processor Processor Textures Program Program Cg – Cg Runtime Another brick in the wall • Just in Time (JIT) compiler for Cg shaders • Building a brick shader – Shaders are compiled and loaded at run-time – Brick shader will actually be a procedural rather than linked with executable texture that is mapped onto a surface – Flexibility – Texture coordinates s, t • instant support for variety of graphics platforms • Questions on Cg? Building a brick shader Building a brick shader #define BRICKWIDTH 0.25 #define BRICKHEIGHT 0.08 1 MORTARTHICKNESS #define MORTARTHICKNESS 0.01 #define BMHEIGHT (BRICKHEIGHT + MORTARTHICKNESS) BRICKHEIGHT #define BMWIDTH (BRICKWIDTH + MORTARTHICKNESS) BRICKWIDTH 1 0

  5. Building a brick shader Building a brick shader // wrap texture coords to see where on given brick surface brick ( // you are uniform Color Cbrick = color (0.5, 0.15, 0.1); s = s % width; uniform Color Cmortar = color (0.5, 0.5, 0.5) t = t % height; ) { // Set the color based on where you are Color Ct = Cbrick; // What row is the point in question on if (s < MORTARTHICKNESS || t < MORTARTTHICKNESS) float row = t / BMHEIGHT; Ct = Cmortar // If even, offset length by a half // Return correct color if ( row % 2 == 0) s += (BMWIDTH/2); Cs = Ct; } Building a better brick shader Building a better brick shader // Set the color based on where you are • Let’s use noise to discolor individual bricks // Let the brick color change based on noise float noiseChange = 0.1; float row = s / BMWIDTH; Color Ct = Cbrick + (noise (row,col) * noiseChange); if (s < MORTARTHICKNESS || t < MORTARTTHICKNESS) Ct = Cmortar // Return correct color Cs = Ct; } Questions? Building an even better brick shader • Other possible additions – Bump mapping to have normal dip in mortar and rise on side of brick – Add noise to individual points on each brick – Add graininess – See brick shader for your given system

Recommend


More recommend