[X3D-Public] FreeX3D Android updated.

Michalis Kamburelis michalis.kambi at gmail.com
Mon Aug 19 06:15:14 PDT 2013

John Alexander Stewart wrote:
> See the "Prog Shaders" tab at http://freex3d.org

I checked the models on 
http://freewrl.sourceforge.net/FreeX3D/Component_ProgrammableShaders.html with 
view3dscene. Some notes about portability of these files follow. In 
short, only a few cosmetic fixes are necessary (and they are generally 
needed to make the models conform to specification, I think) an then 
view3dscene can handle the linked 4 models using ComposedShader too :)

If you're interested in view3dscene shader support, it's documented on 
http://castle-engine.sourceforge.net/x3d_implementation_shaders.php . 
And a different beast, which allows to write GLSL in more comfortable 
manner, is on http://castle-engine.sourceforge.net/compositing_shaders.php .

Notes about models 
http://freewrl.sourceforge.net/FreeX3D/Component_ProgrammableShaders.html :

1. You're using backslash + newline inside VRML/X3D strings, which is 
not correct as far as I know and makes view3dscene spit warnings

   view3dscene: X3D warning: Invalid sequence in a string: "\
". Backslash must be followed by another backslash or double quote, for 
SFString and MFString (in X3D classic (VRML) encoding) and for MFString 
(in X3D XML encoding).

As far as I know, view3dscene is right here. For VRML, see 

   Any characters (including linefeeds and '#') may appear within the 
quotes. A double quote character within the string is preceded with a 
backslash. A backslash character within the string is also preceded with 
a backslash forming two backslashes.

So, if you want to have a newline inside the string, just write a 
newline, without any backslash.

2. I notice you define a magic symbol HEADLIGHT_LIGHT. Hm, that's a good 
idea, I may adopt it for view3dscene too (where HEADLIGHT_LIGHT would be 
always 0 --- in contrast to FreeWRL, in view3dscene headlight is always 
the first, not the last). It may be a good idea to add it to spec, as 
recommended behavior for GLSL shaders?

After fixing this (removing backslashes and replacing HEADLIGHT_LIGHT 
with 0) view3dscene can render just fine teapot-Toon.wrl and 
TwoCylinders.wrl .

3. sobel-ComposedShader.wrl uses fw_ variables, not gl_. After fixing 
(removing backslashes and replacing fw_ with gl_) it works fine under 
view3dscene as well :)

4. flutter2-ComposedShader.x3d works fine under view3dscene as well, but 
there are warnings, and I think they are correct:

   view3dscene: VRML/X3D warning: Error when reading MFString field 
"url" value, probably missing double quotes (treating as a single 
string): VRML/X3D parse error at position 4: Expected string, got "data"
   (2x times)
   view3dscene: VRML/X3D warning: SFRotation field 
(Viewpoint.orientation) specifies rotation around zero vector
   (2x times)

So these bits of flutter2-ComposedShader.x3d should be fixed to make it 
really 100% correct.

So, after a few cosmetic fixes (which I think are generally good to make 
your models conforming to spec) view3dscene happily handles 4 test 
models using ComposedShader node :)

As for 5th test model, flutter2-ProgramShader.x3d: view3dscene does not 
(and will not, probably) support using ProgramShader for GLSL. Like you 
write on 
http://freewrl.sourceforge.net/FreeX3D/Component_ProgrammableShaders.html , 
ProgramShader just doesn't fit GLSL. We require to use ComposedShader to 
use GLSL, nobody complained so far :)

5. Nitpicking: You may consider declaring your models as X3D, not VRML, 
and with .x3dv extension (for classic encoding) :) Programmable shaders 
are part of X3D, not VRML 2 (even if both view3dscene and FreeWRL and 
possibly others allow to use these nodes in VRML 2 too).


More information about the X3D-Public mailing list