Procedural Shading Assignment

Procedural Shading Assignment

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: • Three goals: – Cg – Real time shading language (Nvidia) – Download and install a procedural shading • Support for DirectX 8, 9 and OpenGL1.4 system. • Supposedly graphics card independent • 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. 1 Assignment #3 Assignment #3 • 1. Download • If you do not have Visual Studio or if your – RenderMonkey graphics card is not up to par. • 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 • http://graphics3d.com/guides/cg/index.html • Brick Shader – For Renderman users • Grab-bag (one of your choice) • 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 2 Assignment #3 Assignment #3 • A note on “borrowing” shaders • Deliverables – 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 • Grading • 15 points – Each assignment is worth 20 points: – Produce single image • 5 points – for something that compiles • 20 points • 10 points – for something that runs incorrectly – Produce multiple or interactive image with • 15 points – for something that runs correctly changing shading argument values • 20 points – something that runs + extras • Note – 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 6th 3 Real time shading – Cg Cg – vertex and fragment programs Framebuffer Rasterization Framebuffer Assembly & Assembly Operations Vertex Application Fragment 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) BRICKWIDTH BRICKHEIGHT #define BMWIDTH (BRICKWIDTH + MORTARTHICKNESS) 0 1 4 Building a brick shader Building a brick shader surface brick ( // wrap texture coords to see where on given brick uniform Color Cbrick = color (0.5, 0.15, 0.1); // you are s = s % width; uniform Color Cmortar = color (0.5, 0.5, 0.5) t = t % height; ) { // Set the color based on where you are // What row is the point in question on Color Ct = Cbrick; 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; } Building an even better brick shader Questions? • 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 5.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us