[X3D-Public] Shader programming and URLs in X3D
michalis.kambi at gmail.com
Thu May 14 03:49:55 PDT 2009
John A. Stewart wrote:
> Hi All;
> I'm verifying the Shader support code in FreeWRL, and I have a question.
> The url field, can it contain the source, or does it always have to
> designate a file? eg, with scripting, one can have a url starting with
As far as I know, url fields of shader nodes (like ShaderPart) must
always point to some external resource. So, yes, url field of shaders is
indeed more limited in this regard that e.g. Script.url.
One exception is that in XML encoding, you can use CDATA to put actual
shader source in the file. That is, you can write
gl_Position = ftransform();
This is unfortunately specific to XML encoding, there's no way to do
this in classic encoding.
At least that's what I know, based on reading X3D spec, and that's how
it's implemented in view3dscene.
Now, I'm all after improving this part of spec. Maybe we can all agree
that e.g. special protocol name "shader:" or "source:" could be used to
for Script nodes; protocol names like "glsl:" or "cg:" seem more
logical, but that would be redundant, as "type" field already specifies
the language). I can implement such protocol in 5 mins in view3dscene,
if everyone thinks it's a good idea and other browsers will follow :)
The spec could be adjusted for this in the next version.
More information about the X3D-Public