[x3d-public] data URLs for shaders.

Michalis Kamburelis michalis.kambi at gmail.com
Sat Aug 4 16:35:11 PDT 2018


2018-08-04 22:36 GMT+02:00 John Carlson <yottzumm at gmail.com>:
> Is there anything in the standard stating that embedded shaders should begin
> with a URL like:
>
>
>
> data:text/plain;charset=utf-8,
>
>
>
> Ala X_ITE?
>

The X3D standard doesn't have a concept of "embedded shaders", so it
doesn't say anything how do they look like.

The X3D only says that "The shader source is read from the URL
specified by the url field." ,
http://www.web3d.org/documents/specifications/19775-1/V3.2/Part01/components/shaders.html
.

However, many X3D browsers support "data URI scheme",
https://en.wikipedia.org/wiki/Data_URI_scheme . The wiki page is quite
good, it's a simple specification how you can essentially embed
anything when an URL is supported, using the "data URI scheme".

It says that you have to start with "data:". You can follow it by
"text/plain;charset=utf-8," or various other things. If you don't (if
you use only "data:"), then "text/plain;charset=US-ASCII" should be
assumed.

IOW, in short:

- you need to use "data:" for embedded shader code (or anything else,
if you want to use "data URI scheme" for embedding),

- you usually do not need to use "text/plain;charset=utf-8," for
shader code (as shader code usually doesn't use any special characters
and can be treated as simple ASCII).

Regards,
Michalis



More information about the x3d-public mailing list