Geeks3D recently posted a couple of posts on billboards rendering using vertex shader or geometry shader, and particle rendering performance when using point sprites or geometry shader.
Tag Archives: GLSL
A GLSL version of smallpt
smallpt is a bare minimum path tracer written under 100 lines of C++, featuring diffuse, and specular reflection, and refraction. Using the detailed explanation slides by David Cline, I experimented porting it to GLSL on Shadertoy.
This proved to be an interesting experiment that brought a few lessons.
- Path tracing is fun, easy to implement, and good looking.
- It is also slow to converge, so trying to get your rays toward the light source is a big win.
- GLSL support in WebGL is still nowhere near robust: valid code will or will not work depending on the platform, the browser, and whether the OpenGL layer is native or not. The statements “break” and “continue” in particular seem often to break everything.
You can see the shader and tweak it here. By default it uses 6 samples per pixel, and 3 bounces, which allows it to run smoothly on average hardware. I found 40 samples per pixel and 5 bounces to give nice results while maintaining interactive framerate.
Update: since GLSL Sandbox has a feature, reading from the previous frame buffer, that Shadertoy is missing at the moment, I thought it’d be interesting try it to have the image converging over time. A little hacking later, a minute or so worth of rendering got me this kind of result: Given the effort, I am really pleased by the result.
Yet another GLSL live editor
I mentioned already the current trend of writing live coding tools. During the Tokyo Demo Fest, which was taking place last weekend in Akihabara, Hole performed a live coding with his own tool, thus VJ-ing while the DJ was on stage. Interestingly, this led to collaborative coding when someone joined him. This could be a very interesting direction to explore.
The tool, LiveCoder, looks pretty clean on big screen and may be worth trying out.
Live coding and apples
There is a recent trend of coding with an overlay editor on top of the live result, changing as the code gets written and modified. I suspect it originates on one hand from the work of the folks at Sexy Visuals and some of the videos Iñigo Quilez has been publishing demonstrating some concepts, including a basic raytracer in less than half an hour. And on the other hand, on Shader Toy (made by the same usual suspect), a web page using WebGL to allow fast GLSL shader prototyping in a browser.
It was only a question of time before someone would merge both concepts. Thus Ricardo Cabello (often known as Mr Doob) sparked off a lot of effervescence when he published his GLSL Sandbox. People would try many things, give feedback and advices, someone would quickly come up with a gallery… But after various toy experiments by various people, IQ would come back and make waves with his procedural apple. He also published another live coding video, showing how it was made.