[x3d-public] ShaderPart, ShaderProgram type: why accessType initializeOnly?

Michalis Kamburelis michalis.kambi at gmail.com
Sun Jun 7 12:32:57 PDT 2020


Changing the "ShaderPart.type" at runtime doesn't have much use (and cannot be realistically optimized by the renderer, the only thing that can be done would be to recompile the shader). This implies it should be initializeOnly, this is the rule followed by the spec for initializeOnly as far as know.

The issue """Seems like an author/programmer might want to set the value if constructing a such a node at run time.""" could be raised for any field that is initializeOnly :) So we would not have any initializeOnly then. I don't have much experience with JavaScript SAI in X3D, but for Castle Game Engine engine the practical differences between initializeOnly and inputOutput are:
browser promises to optimize, as much as possible, changing at runtime stuff marked inputOutput. For stuff marked as initializeOnly it is sometimes not possible to optimize (and sometimes would be cumbersome to implement), so it may result in slowdown if you try to change it at runtime.
And of course you can animate inputOutput by ROUTEing things to it, or observe it changing by ROUTEing from it.

But you are practically allowed to change both initializeOnly and inputOutput fields, at any moment.

Indeed the allowed values for "type" could be extended to allow others than VERTEX/FRAGMENT. CGE allows there "GEOMETRY" ( https://castle-engine.io/x3d_implementation_shaders.php#section_geometry (https://link.getmailspring.com/link/0D5DC89B-7F25-4541-8DBB-A608C2198C18@getmailspring.com/0?redirect=https%3A%2F%2Fcastle-engine.io%2Fx3d_implementation_shaders.php%23section_geometry&recipient=eDNkLXB1YmxpY0B3ZWIzZC5vcmc%3D) ). Graphic APIs offer other shader types ( https://www.khronos.org/opengl/wiki/Shader (https://link.getmailspring.com/link/0D5DC89B-7F25-4541-8DBB-A608C2198C18@getmailspring.com/1?redirect=https%3A%2F%2Fwww.khronos.org%2Fopengl%2Fwiki%2FShader&recipient=eDNkLXB1YmxpY0B3ZWIzZC5vcmc%3D) ) that can be supported by browsers.
Regards,
Michalis

On cze 7 2020, at 3:20 am, Don Brutzman <brutzman at nps.edu> wrote:
> For the following node signatures, wondering why the type field has accessType initializeOnly [] instead of inputOutput [in out] ?? Seems like an author/programmer might want to set the value if constructing a such a node at run time.
>
> Related: allowed values should be changed from
> ["VERTEX"|"FRAGMENT"]
> to
> ["VERTEX"|"FRAGMENT",...]
>
> Recorded as Mantis 1306, https://www.web3d.org/member-only/mantis/view.php?id=1306
> ================================================
> https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/shaders.html
>
> 31.4.7 ShaderPart
> ShaderPart : X3DNode, X3DUrlObject {
> SFNode [in,out] metadata NULL [X3DMetadataObject]
> MFString [in,out] url [] [URI]
> SFString [] type "VERTEX" ["VERTEX"|"FRAGMENT"]
> }
>
> "The type field indicates whether this object shall be compiled as a vertex shader, fragment shader, or other future-defined shader type."
> ================================================
> https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/shaders.html#ShaderProgram
>
> 31.4.8 ShaderProgram
> ShaderProgram : X3DNode, X3DUrlObject, X3DProgrammableShaderObject {
> SFNode [in,out] metadata NULL [X3DMetadataObject]
> MFString [in,out] url [] [URI]
> SFString [] type "VERTEX" ["VERTEX"|"FRAGMENT"]
>
> # And any number of:
> fieldType [in] fieldName
> fieldType [in,out] fieldName initialValue
> fieldType [out] fieldName
> fieldType [] fieldName initialValue
> }
> ================================================
>
> ShaderProgram also needs same sentence appended:
> "The type field indicates whether this object shall be compiled as a vertex shader, fragment shader, or other future-defined shader type."
> all the best, Don
> --
> Don Brutzman Naval Postgraduate School, Code USW/Br brutzman at nps.edu
> Watkins 270, MOVES Institute, Monterey CA 93943-5000 USA +1.831.656.2149
> X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200607/1fba3bf2/attachment.html>


More information about the x3d-public mailing list