Dynamic Code Generation for Realtime Shaders

Niklas Folkegård
Högskolan i Gävle, Sweden

Daniel Wesslén
Högskolan i Gävle, Sweden

Ladda ner artikelhttp://www.ep.liu.se/ecp_article/index.en.aspx?issue=013;article=005

Ingår i: The Annual SIGRAD Conference. Special Theme - Environmental Visualization

Linköping Electronic Conference Proceedings 13:5, s. 11-15

Visa mer +

Publicerad: 2004-11-24


ISSN: 1650-3686 (tryckt), 1650-3740 (online)


Programming real time graphics has been made more efficient by introducing high level shading languages such as Cg and GLSL. Writing shader programs can be redundant since the same functions appear in many shaders. This article suggests a method to combine single functions and create compound shaders in runtime. Redundancy is avoided by dividing programs into smaller; reusable parts. An algorithm is presented for joining these parts into working shaders based on just a few parameters.

CR Categories: I.3.0 [Computer Graphics]: General— [I.4.8]: IMAGE PROCESSING—Shading D.1.2 [Software]: Programming Techniques—Automatic Programming.


Graphics hardware; GLSL; GPU programming; programming efficiency; real time shaders; dynamic code generation; meta programming; computer graphics


BLEIWEISS; A.; AND PREETHAM; A.; 2003. Ashli – Advanced Shading Language Interface. http://www.ati.com/developer/eurographics2003/ AshliViewerNotes.pdf.

CHAN; E.; NG; R.; SEN; PRADEEP; S.; PROUDFOOT; K.; AND HANRAHAN; P. 2002. Efficient Partitioning of Fragment Shaders for Multipass Rendering on Programmable Graphics Hardware. In Graphics Hardware(2002); 69 – 78.

FERNANDO; R.; AND KILGARD; M. J. 2003. The Cg Tutorial. Addison–Wesley.

FOLKEGARD; N.; 03/06/2004. Shadercombiner implementation. http://sourceforge.net/projects/shadercombiner/.

FOLKEGARD; N.; 30/09/2004. Hardware Shader Combiner for Maya. available through Creative Media Lab; G¨avle.

HAST; A. 2004. Improved Algorithms for Fast Shading and Lighting. PhD thesis; Uppsala Universitet.

KESSENICH; J.; BALDWIN; D.; AND ROST; R. The OpenGL Shading Language.

LIGHTWORKS; 20/05/2004. Programmable Hardware Shading In Applications – Challenges and Solutions. http://www.lightworkdesign.com/news/media/ ProgrammableShadingInApplications.pdf.

MARK; W. R.; GLANVILLE; S. R.; AKELEY; K.; AND KILGARD; M. J. 2003. Cg: A system for programming graphics hardware in a C-like language. In ACM Transactions on Graphics; ACM; 896 – 907.

MCCOOL; M. D.; DU TOIT; S.; POPA; T.; CHAN; B.; AND MOULE; K. 2004. Shader Algebra. In ACM Transactions on Graphics; ACM; 787 – 795.

ROST; R. J. 2004. OpenGL Shading Language. Addison–Wesley.

RTZEN INC. RT/shader.

Citeringar i Crossref