FoxMcCloud
Newcomer
I've been running into issues with using Cg on non-NVIDIA platforms and often frustrated by some bugs and slow turnaround on cgc's GLSL output target. I've been working on writing a front-end for a Cg-like shading language (named LtiteGraph Shader Language since it came out of a toy project called LiteGraph) as a side project for a while, and it's beginning to get to the point where it can perform basic translation to GLSL using a bunch of simple pre-order / post-order passes on the generated parse tree.
Here's what a basic vertex program looks like:
http://www.flickr.com/photos/59098813@N06/6648763241/
And here's its parse graph inside a simple OS X app I wrote to visualize it:
http://www.flickr.com/photos/59098813@N06/6648763251/
The parser is in standards-compliant C++ code, currently runs on Windows and OS X, doesn't share global state (so you can parse more than one shader in parallel inside the same process) and I plan to release it under the BSD license if anyone's interested. The code isn't optimized and currently it takes an average of ~250ms to parse every shader in the corpus I have of shaders from The Cg Book (~40).
The parser can also serialize the parse graph to readable YAML, and I've been using the serialized parse graphs to experiment with writing passes quickly in Python, so I have serialization / deserialization code for C++ (using yaml-cpp) and Python (using PyYAML). I plan to move the code I write in Python to C++ eventually - I merely use Python for the fast iteration speed.
Currently a half-dozen passes (200 LOC total) in Python can do basic conversion to GLSL, and I think that writing a complete translator should be doable in six to twelve man-months (but don't hold me to that). Here's what the input / output look like for a simple shader:
http://pastebin.com/VxQn5tcT
A corpus of shaders in Cg and their LiteGraph equivalents with serialized parse graphs can be found here: https://bitbucket.org/sherief/cg-lgsl-shaders/overview
Is anyone else interested in this? I'm thinking of releasing the code under a BSD license since I think other people might find an embeddable, open shader language front-end might make their targeting of multiple platforms easier, but I'd love to hear what you guys have to say first.
Here's what a basic vertex program looks like:
http://www.flickr.com/photos/59098813@N06/6648763241/
And here's its parse graph inside a simple OS X app I wrote to visualize it:
http://www.flickr.com/photos/59098813@N06/6648763251/
The parser is in standards-compliant C++ code, currently runs on Windows and OS X, doesn't share global state (so you can parse more than one shader in parallel inside the same process) and I plan to release it under the BSD license if anyone's interested. The code isn't optimized and currently it takes an average of ~250ms to parse every shader in the corpus I have of shaders from The Cg Book (~40).
The parser can also serialize the parse graph to readable YAML, and I've been using the serialized parse graphs to experiment with writing passes quickly in Python, so I have serialization / deserialization code for C++ (using yaml-cpp) and Python (using PyYAML). I plan to move the code I write in Python to C++ eventually - I merely use Python for the fast iteration speed.
Currently a half-dozen passes (200 LOC total) in Python can do basic conversion to GLSL, and I think that writing a complete translator should be doable in six to twelve man-months (but don't hold me to that). Here's what the input / output look like for a simple shader:
http://pastebin.com/VxQn5tcT
A corpus of shaders in Cg and their LiteGraph equivalents with serialized parse graphs can be found here: https://bitbucket.org/sherief/cg-lgsl-shaders/overview
Is anyone else interested in this? I'm thinking of releasing the code under a BSD license since I think other people might find an embeddable, open shader language front-end might make their targeting of multiple platforms easier, but I'd love to hear what you guys have to say first.