[X3D-Public] Shader programming and URLs in X3D

Peter Eschler peschler at googlemail.com
Thu May 14 08:21:25 PDT 2009


On Thu, May 14, 2009 at 4:53 PM, John A. Stewart <alex.stewart at crc.ca> wrote:
> Michalis;
> I'm going to suggest that "shader:" be placed in the front of any text
> string for shader source.

I would suggest to stick to existing standards like the data url protocol:

That is:
<ShaderPart type='VERTEX'><![CDATA[data:text/plain,

  void main(void)
   gl_Position = ftransform();

The MIME-type is already given by the spec:
"Shader source files shall be plain text encoded as specified for MIME
type text/plain and interpreted according to the containing node's
language definition."

There's an optional encoding after the mimetype of a data url, but
that's not used in the example above.

Best regards,
Peter Eschler

> It is ambiguous to have a url that can be either a file name, or text; and
> the precedent for this action is already there with scripting text.
> I understand from talking to Alan Hudson that Xj3D does not support the
> Shader Component; I think Octaga does (this is cc'd to Espen at Octaga), as
> does BitManagement.  Espen, Peter; any comment?
> On 14-May-09, at 6:49 AM, Michalis Kamburelis wrote:
>> 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
>>> "javascript ..." and it will be treated as source, not as a url.
>> 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
>> <ShaderPart type='VERTEX'><![CDATA[
>>  void main(void)
>>  {
>>   gl_Position = ftransform();
>>  }
>>  ]]>
>> </ShaderPart>
>> 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
>> indicate that actual shader source code follows (just like "javascript:"
>> 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.
> -----------------------------------------------------------
> John A. Stewart
> Team Leader: Networked Virtual Reality
> alex.stewart at crc.ca
> Network Systems and Technologies -
>        Systemes et technologies des reseaux
> Communications Research Centre Canada  |
>         Centre de recherches sur les communications Canada
> 3701 Carling Ave.  |  3701, avenue Carling
> PO Box 11490, Station H  |  CP 11490, succursale H
>         Ottawa ON K2H 8S2   |  Ottawa (Ontario) K2H 8S2
> http://www.crc.ca

Dipl.-Inform. (FH) Peter Eschler
NewMediaYuppies GmbH
Kreativagentur für Neue Kommunikation
Hochstrasse 17, 60313 Frankfurt am Main
E-Mail: p.eschler at newmediayuppies.com
T  +49 (0) 69 - 150 44 88 60
F  +49 (0) 69 - 150 44 88 61
M +49 (0) 173 - 326 45 34

More information about the X3D-Public mailing list