Hello to everyone of the vvvv community:
I am a Jitter user but I have had the chance to play with vvvv for some months now. Really nice program indeed!
I have been particularly amazed by the shaders posted in this forum. Some of them are just awesome. I have come to this idea to convert some of them into glsl so they can be used with openGL.
However, being as ignorant as i am on the HLSL language, I have decided to post a couple of questions about the best way to achieve such goal.
1-What would be the best book to read in order to get an idea of what HLSL is about(something equivalent to the orange book in openGL)
2-Is it true that Cg language is quite similar to HLSL. Cg is implemented in jitter despite the fact that the documentation is quite poor.
3-Has anyone here ever attempted to do something similar?
Wow!, thanks for the fast answers screamers and catweasel. I am really envious how many people are doing nice shaders within this community. For sure, something that we need to imitate on the other side of the river!
If anyone else can give me more hints i would be really grateful!
it’s a|x, of machinesdontcare.
I’ve done quite a lot of work converting HLSL shaders from here and other places to GLSL, to use in Quartz composer. I didn’t find I needed to do any particular research on the HLSL language in order to be able to convert most shaders to GLSL. You might need to lookup specific HLSL functions that exist in HLSL but have different names in GLSL. The only HLSL builtin function I’ve come across that has no direct GLSL equivalent is lit() (used for lighting calculations), but it can be fairly easily emulated in GLSL.
My advice would be to start with pixel-shader-based effects. If you have a good idea about the 3D rendering-pipeline in OpenGL (which I didn’t, when I started), then you’ll find HLSL familiar in a lot of ways, though the terminology differs slightly, especially with regard to transformation matrices. Also, you’ll find that the method for passing variables between Vertex and Pixel/Fragment shaders is different in HLSL, but once you’ve got your head around it’s method, it’s pretty easy to emulate using varyings.
Another thing to look out for is that many HLSL shaders are multipass. I’m not sure how easy this is to do in Jitter, but in Quartz Composer, it isn’t possible to setup multi-pass GLSL shaders in the same way (though it is possible to chain 2D shaders written in a subset of GLSL that’s specific to Apple’s Quartz graphics system).
Hope this helps.
You might find some useful bits and pieces on my blog. There’s a lot of stuff that’s specific to Quartz Composer, but there’s also some snippets of GLSL code on there that you might find useful. Feel free to drop me a message via the blog if there’s anything else you need to know.
Incidentally, as I understand it, Cg is very similar to HLSL. I don;t know enough about either language to know what the subtle differences are between them though.
Re. HLSL2GLSL, I’ve never managed to get anything useful out of this, to be honest. It seems to produce completely unreadable code, so I decided a long time ago that it would be much easier just to do the translation myself.
babelshader seems to be a converter for HLSL > ARB shader language, rather than GLSL. ARB is more like GPU assembly language, and I don’t know if it’s supported by Jitter.
Many thanks for all the answers!, very useful and clarifying.
I have seen your blog before, it is really really nice. Very inspiring indeed.
The multipass shading can be somehow tricky with jitter. The best method is to do a ‘chain’ shading using an object called jit.gl.slab. You can use the final image both as a texture(which eventually can be used with more textures) or as a videoplane. This is mostly used for transforming video inputs(somehow jitter has a deep video integration on it).
Jitter only supports Cg and GLSL. Documentation for GLSL is very basic so most of the learning comes from reading the Orange book and tryout over and over again. Cg is not documented at all. However, more and more users inside the community are using shaders to generate visual effects. It seems even possible to implement GPU calculations for audio inside Max/Msp which would be, to say the less, really amazing.
Maybe, as you mention, the best way is to learn HLSL and try to figure out by trial and error how conversions can be made.
One final thing, would you mind if i contact you off the list?
Thank you again for the help!