1 / 37

Presentation Title

Presentation Title. Demos and Real-time Computer Graphics. First and Last Name Presenters Title. Ng Chu Ming Alumni, Computer Graphics Research Lab. Overview of Talk. Introduction to Demos Origins of the Demoscene Demoparties Classic works Different type of demos Tricks and Techniques

leane
Télécharger la présentation

Presentation Title

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Presentation Title Demos and Real-time Computer Graphics First and Last Name Presenters Title Ng Chu Ming Alumni, Computer Graphics Research Lab

  2. Overview of Talk • Introduction to Demos • Origins of the Demoscene • Demoparties • Classic works • Different type of demos • Tricks and Techniques • Conclusion

  3. Introduction to DemosceneDemos : What are they? • Not Commercial or Game Demos! • Demos are… “the last bastion of passionate, crazed, enthusiast-only programming, crafted purely for the hell of it by inspired teenagers working entirely in their spare time. The teens create jaw-dropping audiovisual effects beyond the dreams of most multimedia designers. “ – Wired Magazine • New digital artform • Demos are a fusion of… • Art • Music • Design • Great Coding

  4. What are Demos?... Lets see…..

  5. Origins of the DemosceneDemos : How it all started… • Started in early 1980s due to software crackers • Cracker signature • Originated from ‘crack screens’… • From text… • To splash screens… • 2D animation… • … finally 3D animated effects and music • Eventually, many cracker groups started to release intro-like programs separately

  6. Origins of the DemosceneDemos : Today, in the state of the art… • 3D realtime ray tracing • Procedural Textures • Multiple Effects and transitions • Executable compression • Design and storyboarding

  7. Demo PartiesDemos : the now worldwide phenomenon… • Assembly ’06 (Helsinki, Finland) • Mother of all demo parties • The very first and longest running for 15 years • Sponsored by big names like • EA, Microsoft, AMD • Creative, ATI, Nokia, ASUS • Now a worldwide phenomenen • A Demoparty in almost every continent/country • The Party (Denmark), Breakpoint (Germany), The Gathering (Norway)… • 33 demo competitions over 23 Countries… • Even Singapore had one, The Scene in 1996

  8. Demo Show case: Classic and defining works … in DemoScene history.

  9. Classic and Defining works 2nd Reality by Future Crew • Produced and presented at Assembly 1993 • But… What is it like in 1993? • 386 PCs running DOS • 16bit. 64k limit. • NO OpenGL/Direct3D etc!

  10. Classic and Defining works 2nd Reality by Future Crew • Till today, it is still considered the greatest demo ever produced • Listed by Slashdot.org as Top 10 hacks of all time, alongside • Mars Pathfinder • Ken Thompson's "cc hack“ • Perl • The Apollo 13 Mission Rescue • 2nd Reality facts • Coded in FULL Assembly language • Dolby Surround • And group members were just 18-20 years old!

  11. 2nd Reality. Play DVD here

  12. Types of Demos… 4kb, 64kb, Full fledged demos…

  13. Types of Demos4 Kilobyte Intros • Yes, 4096 bytes. • Equivalent to… • 512 chars of text… • What it means… • No APIs to call • Code _EVERYTHING_ yourself, down to the last plotpixel • Alright… Just how small is 4Kb!?

  14. Types of Demos4 Kilobyte Intros • Okay… Lets take a look at…

  15. Types of Demos4 Kilobyte Intros • Yes, 4096 bytes. • Equivalent to… • 512 chars of text… • Alright… Just how small is 4Kb!? • Ok… Fine. So, What can you do in 4Kb?

  16. Types of Demos64 Kilobyte Intros • What can be done in 64Kb? • Well, this is what all of us do.....

  17. Types of Demos64 Kilobyte Intros • What can be done in 64Kb? • But you can really have, • Procedural geometry • Music • Textures • And even realtime raytracing with adaptive subsampling…

  18. Types of DemosFull fledged demo (> 1MB in size) • Well, anything goes here. • Lets check out one of the winning entries in Assembly 2006

  19. Types of DemosOther weird, strange, crazy, but cool stuff. • 256 bytes competition • Raytracer in 256 bytes • Text Mode demo competition • Textmode? You must be kidding me… • Hugi Size Coding competition • How small can nibbles get? • Ans : 48 bytes!

  20. Tricks and Techniques Assembly… fixed point math… speed hacks… taylor series approximations

  21. Tricks and TechniquesSize optimization… • Assembly language • There’s no running from it • Know the instruction set sizes • Be aware of processor arch. • 3 Levels in which the size problem is approached • Algorithmic tweaks • Compiler tweaks • OS tweaks

  22. Tricks and TechniquesSize optimization : Algorithmics… • Basically, think of ways to generate things on the fly • Procedural textures, procedural music, code, etc… • Simple example : • The texture on the right is 256x256, with 0-255 in colour [grey scale]. • Even as a .jpg [with compression] it takes a total of 6KB to store. This is larger than many intro’s! • An un-optimized procedural algo:for(y=0;y < 256;y++) for(x=0;x < 256; x++) height_value=(1-(sqrt(((x-128)*(x-128))+((y- 128)*(y-128)))/128))*255; • Note – even without code size optimizations, its <200 bytes in a basic C compiler – a 15 times improvement! • This is only a small example – you need to think algorithmically about, textures, geometry, music, and code!

  23. Tricks and TechniquesSize optimization : Compiler tools • Going one level down to language tools and selection • The principle is… • Don’t take what’s thrown to you out of the box • Assembly • Offers the most flexibility and options to push limits • Use of features in ways they weren’t first designed (more on that later) • C++ • Know everything about your compiler • Linker options, pragmas, etc…

  24. Tricks and TechniquesSize optimization : Compiler tools • C++ example • #include <windows.h> __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {MessageBox(0,“Silly example",“test!",MB_OK); return 0; } • This example, when compiled with “default” VC++ options results in a 24 KB EXE! 

  25. Tricks and TechniquesSize optimization : Compiler tools • Lets tweak it! • The same program, altered just a little bit…. #pragma comment(linker,"/ENTRY:main")#pragma comment(linker,"/MERGE:.rdata=.data")#pragma comment(linker,"/MERGE:.text=.data")#pragma comment(linker,"/IGNORE:4078")#pragma comment(linker,"/OPT:NOWIN98")#include <windows.h>void main(){MessageBox(0,"test","test",MB_OK);} • Becomes 1KB in size!

  26. Tricks and TechniquesSize optimization : Compiler tools • Err… So what the hell did you do? • Cut out the “fluff” that the compiler includes by default: • Microsoft Visual C++ Runtime Library • 4kb section alignment [not required] • Merged sections in the exe: • .text (default code section), • .rdata (default read-only data section) • .data (initial data section)

  27. Tricks and TechniquesSize optimization : OS Tweaks… • Going another level deeper… OS limitations! • This deals with OS limitations, or what a “executable” file is on that Operating system • Win32 programs have a lot of extra “fluff” in them, that you don’t need • Now…. MS-DOS had a light program. It supports 2 types of programs: • .COM files - limited to 64kb, but no headers! • .EXE files - for large exe • Coders started using executable packers. • Basically, compressing the exes • Still not enough! • Pack Exe files in COM files • Pack .CAB files • A lot of details here… (Omitted)

  28. Tricks and TechniquesOptimizing for speed : Processor level… • Again a wide spectrum art • How optimized your code is influence what you can put on your screen. • Knowledge of processor instruction sets and arch. Eg, • Use of lea instruction to do muls faster • xor eax, eax is faster than mov eax, 0 • Address generation interlocks (AGI) • It takes one clock cycle to calculate the address needed by an instruction which accesses memory • But if the address depends on result of an instruction in the preceding clock cycle, you have to wait an extra clock cycle => AGI • Eg. • ADD EBX,4 • MOV EAX,[EBX] ; AGI pipeline stall • Solution? Interleave instructions in between… • ADD EBX,4 • XOR ECX, ECX • MOV EAX,[EBX] ; No AGI stall

  29. Tricks and TechniquesOptimizing for speed : Algorithms… • Going one level up… Algorithms. • Numerical methods • Better algorithms to approximate calculations • Clever hacks • From the very simple, • Avoid multiplications/divisions • Use look up tables • To the more involved… • Using Taylor series to approx sqrt() • John Carmack’s famous Inverse Sqrt hack

  30. Tricks and TechniquesOptimizing for speed : Effect Hacks • Find more clever ways to suspend your disbelief! • Simple Example… Simulating Fire! • Wow!… physically based simulation! But…. • It takes FOREVER!

  31. Tricks and TechniquesOptimizing for speed : Effects Hacks • Take a look at this demo • Nice, simple and Realtime! • And it was already possible 10 years ago! • How it was done… • Use Indexed Color Mode • Set up a nice palette • Plot new pixels and just smooth the image • Evolve image using flow field

  32. Tricks and TechniquesOptimizing for speed : Effects Hacks • Take Heaven Seven by Exceed • Nobody thought realtime raytracing is possible in the year 2000 • But they made it possible with adaptive subsampling • And use heavily hand optimized assembly

  33. ConclusionWhat the scene has to offer… • For educators/academics : • Undergrads in today's Universities mostly don’t know the demo scene exists • The scene is an environment to foster students CG knowledge thru competition • Demo making is a good avenue to learn broad spectrum CS techniques • For example, creating a 64KB intro requires, • Cramming all code, models, textures, sound and all other data in a total of 64KB • This combines skills of, real-time performance, compression programming and content generation • For Commercial/Development : • Demo competitions are excellent place to recruit • Many game industry ppl used to be sceners

  34. Presentation Title Thank you First and Last Name Presenters Title

  35. Tricks and TechniquesOptimizing for speed : Algorithms… • Going one level up… Algorithms. • Numerical methods • Better algorithms to approximate calculations • Clever hacks • From the very simple, • Avoid multiplications/divisions • Use shift and add, eg in framebuffer look up. • Since framebuffers are contiguous block of memory, • pixel(x, y)=fb[y * x_res + x] // say x_res = 800 x 600 • Use shift and add! • pixel(x, y)=fb[y << 9 + y << 8 + y << 5 + x] • Even better… Lookup tables => pixel(x, y)=fb[ytable[y]+ x] • To the more involved… • Using Taylor series to approx sqrt(), John Carmack’s famous Inverse Sqrt hack

  36. Tricks and TechniquesSpeed hacks… • Fixed point math • Use Approximations! • Don’t Calculate what you don’t need to! • Use look up tables!

More Related