Archive for June, 2010

Shader Interrogation in VIM

Wednesday, June 2nd, 2010

I decided to take a quick break from my demo reel and write a small app using PRMan's sloargs library. My intention is to quickly turn any shader in my VIM buffer into a bit of RIB that I can render tests with. If you've ever used Cutter then you're familiar with it's capabilities for fast prototyping RenderMan shaders.

slo2rib is a tiny C++ application built against prman 15.1. I've included two versions. One is 64 bit Linux, built with GCC 4.3.4 on Gentoo, and the other is Windows XP 32bit. I'll have a Win 7 64 build shortly.

Try slo2rib -h for usage info.

Making it work

You will need to export an environment variable named $SHADERPATH with a list of your compiled shader locations. Linux users will also need to add $RMANTREE/lib to their LD_LIBRARY_PATH. It's also helpful if you place slo2rib somewhere on your $PATH, but not necessary if you point to it's location inside of your vimrc.

The following setup is required in your vimrc. I've added notes for windows users where necessary


 1 "Call prman on Windows for the RIB in your buffer
 2 map prm :!start cmd /c "prman -t" %
 3 map ,n prm
 4
 5 "For Linux i use a function to call prman
 6 function! Render()
 7 set makeprg=prman\ -t:0\ %:p
 8 make
 9 set makeprg=make
10 endfunction
11
12 map slr :call MakeRIB()
13 map ,m slr
14
15 let s:myrib = "$VIMRUNTIME/plugin/test.rib"
16 let s:myslo = "%:t:r"
17
18 function! MakeRIB()
19 exec ":!slo2rib " . s:myslo . "\ > " . s:myrib
20 exec ":e $VIMRUNTIME/plugin/test.rib"
21 endfunction
22

Download HERE. (my vimrc included)