[x3d-public] ShaderPart fails schema validation. Why?

Roy Walmsley roy.walmsley at ntlworld.com
Mon Feb 1 14:23:46 PST 2016


John,

 

I’m not sure whether there is a problem with your file, the Schema, or both.

 

I have a modified Schema, which is ahead of the publicly available one because Don is still working through my very long list of changes. ShaderPart was one of those changes. Against my local version of the Schema your file validates.

 

I don’t know if you are adding the text in the correct way. I’ve no reason to think not. But I haven’t seen any other example to compare against. And I haven’t played with shaders myself.

 

Can  talk tomorrow evening (my time, e.g. after about 1800 GMT) if that helps.

 

Roy

 

From: x3d-public [mailto:x3d-public-bounces at web3d.org] On Behalf Of John Carlson
Sent: 01 February 2016 21:29
To: Don Brutzman; X3D Graphics public mailing list
Subject: Re: [x3d-public] ShaderPart fails schema validation. Why?

 

 

Here’s a video https://www.youtube.com/watch?v=BumWtNDTidY (it’s slow, yes)😊

Sent from Mail <http://go.microsoft.com/fwlink/?LinkId=550986>  for Windows 10

 


From: John Carlson <mailto:yottzumm at gmail.com> 
Sent: Monday, February 1, 2016 4:02 PM
To: Don Brutzman <mailto:brutzman at nps.edu> 
Subject: ShaderPart fails schema validation. Why?

 

Don, this file fails DTD and Schema validation in X3D-Edit.  I am not quite sure why.  Perhaps there is a bug, or I don’t understand shader syntax?  Help! It displays fine in FreeWRL. Thanks,

 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "http://www.web3d.org/specifications/x3d-3.3.dtd">

<X3D profile="Immersive" version="3.3" xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.3.xsd' xmlns:xsd='http://www.web3d.org/specifications/x3d-namespace'>

  <Scene>

    <NavigationInfo type=""EXAMINE" "ANY""/>

       <Background backUrl='"cubemap/BK.png"' bottomUrl='"cubemap/BT.png"'

                                frontUrl='"cubemap/FR.png"' leftUrl='"cubemap/LF.png"' 

                                rightUrl='"cubemap/RT.png"' topUrl='"cubemap/TP.png"' />

                <Viewpoint position='0 0 40' description="Transparent rose"/>

                <Transform DEF='Rose01' >

                <Shape>

                <Appearance DEF='_01_-_Default' >

        <Material diffuseColor=".7 .7 .7" specularColor=".5 .5 .5" />

                <ComposedCubeMapTexture>

                <ImageTexture url='"cubemap/BK.png" "http://coderextreme.net/cubemap/BK.png"' containerField="back"/>

                <ImageTexture url='"cubemap/BT.png" "http://coderextreme.net/cubemap/BT.png"' containerField="bottom"/>

                <ImageTexture url='"cubemap/FR.png" "http://coderextreme.net/cubemap/FR.png"' containerField="front"/>

                <ImageTexture url='"cubemap/LF.png" "http://coderextreme.net/cubemap/LF.png"' containerField="left"/>

                <ImageTexture url='"cubemap/RT.png" "http://coderextreme.net/cubemap/RT.png"' containerField="right"/>

                <ImageTexture url='"cubemap/TP.png" "http://coderextreme.net/cubemap/TP.png"' containerField="top"/>

                </ComposedCubeMapTexture>

        <ComposedShader DEF='ComposedShader' language="GLSL">

                  <field name='cube' type='SFInt32' accessType='inputOutput' value='0'/>

 

                  <field name='chromaticDispertion' accessType='inputOutput' type='SFVec3f' value='0.98 1.0 1.033'/>

                  <field name='bias' type='SFFloat' accessType='inputOutput' value='0.5'/>

                  <field name='scale' type='SFFloat' accessType='inputOutput' value='0.5'/>

                  <field name='power' type='SFFloat' accessType='inputOutput' value='2'/>

                  

                  <ShaderPart type='VERTEX'>

/*

The MIT License (MIT)

Copyright (c) 2011 Authors of J3D. All rights reserved.

 

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

 

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

 

THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/

attribute vec3 position;

attribute vec3 normal;

attribute vec2 texcoord;

 

uniform mat4 modelViewProjectionMatrix;

uniform mat4 modelViewMatrix;

uniform mat4 modelViewMatrixInverse;

uniform mat4 normalMatrix;

 

uniform vec3 chromaticDispertion;

uniform float bias;

uniform float scale;

uniform float power;

 

varying vec3 t;

varying vec3 tr;

varying vec3 tg;

varying vec3 tb;

varying float rfac;

 

void main()

{

    mat3 mvm3=mat3(

                modelViewMatrix[0].x,

                modelViewMatrix[0].y,

                modelViewMatrix[0].z,

                modelViewMatrix[1].x,

                modelViewMatrix[1].y,

                modelViewMatrix[1].z,

                modelViewMatrix[2].x,

                modelViewMatrix[2].y,

                modelViewMatrix[2].z

    );

    vec3 fragNormal = mvm3*normal;

    gl_Position = modelViewProjectionMatrix*vec4(position, 1.0);

    vec3 incident = normalize((modelViewMatrix * vec4(position, 1.0)).xyz);

 

    t = reflect(incident, fragNormal)*mvm3;

    tr = refract(incident, fragNormal, chromaticDispertion.x)*mvm3;

    tg = refract(incident, fragNormal, chromaticDispertion.y)*mvm3;

    tb = refract(incident, fragNormal, chromaticDispertion.z)*mvm3;

 

    rfac = bias + scale * pow(0.5+0.5*dot(incident, fragNormal), power);

}

                  </ShaderPart>

                  <ShaderPart type='FRAGMENT'>

/*

The MIT License (MIT)

Copyright (c) 2011 Authors of J3D. All rights reserved.

 

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

 

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

 

THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/

#ifdef GL_ES

  precision highp float;

#endif

 

uniform samplerCube cube;

 

varying vec3 t;

varying vec3 tr;

varying vec3 tg;

varying vec3 tb;

varying float rfac;

 

void main()

{

    vec4 ref = textureCube(cube, t);

    vec4 ret = vec4(1.0);

 

    ret.r = textureCube(cube, tr).r;

    ret.g = textureCube(cube, tg).g;

    ret.b = textureCube(cube, tb).b;

 

    gl_FragColor = ret * rfac + ref * (1.0 - rfac);

}

       

                  </ShaderPart>

                </ComposedShader>

                                </Appearance>

                                <!--Sphere/-->

                <IndexedFaceSet DEF="Orbit" creaseAngle="1.57">

                  <Coordinate DEF="OrbitCoordinates"/>

                </IndexedFaceSet>

                </Shape>

      </Transform>

    <Script DEF="OrbitScript">

                <field accessType="inputOnly" name="set_fraction" type="SFFloat"/>

                <field accessType="inputOutput" name="coordinates" type="MFVec3f"/>

                <field accessType="inputOutput" name="coordIndexes" type="MFInt32"/>

<![CDATA[

 

ecmascript:

 

var e = 5;

var f = 5;

var g = 5;

var h = 5;

 

function initialize() {

     resolution = 100;

    updateCoordinates(resolution);

     if (typeof coordIndexes == 'undefined' || coordIndexes == null) {

               coordIndexes = new MFInt32();

     }

     ci = 0;

     for ( i = 0; i < resolution-1; i++) {

               for ( j = 0; j < resolution-1; j++) {

                     coordIndexes[ci] = i*resolution+j;

                     coordIndexes[ci+1] = i*resolution+j+1;

                     coordIndexes[ci+2] = (i+1)*resolution+j+1;

                     coordIndexes[ci+3] = (i+1)*resolution+j;

                     coordIndexes[ci+4] = -1;

                     ci += 5;

                }

    }

}

 

function updateCoordinates(resolution) {

     theta = 0.0;

     phi = 0.0;

     delta = (2 * 3.141592653) / (resolution-1);

     if (typeof coordinates == 'undefined' || coordinates == null) {

               coordinates = new MFVec3f();

     }

     for ( i = 0; i < resolution; i++) {

               for ( j = 0; j < resolution; j++) {

                                rho = e + f * Math.cos(g * theta) * Math.cos(h * phi);

                                coordinates[i*resolution+j][0] = rho * Math.cos(phi) * Math.cos(theta);

                                coordinates[i*resolution+j][1] = rho * Math.cos(phi) * Math.sin(theta);

                                coordinates[i*resolution+j][2] = rho * Math.sin(phi);

                                theta += delta;

                }

                phi += delta;

     }

}

 

function set_fraction(fraction, eventTime) {

                choice = Math.floor(Math.random() * 4);

                switch (choice) {

                case 0:

                                e += Math.floor(Math.random() * 2) * 2 - 1;

                                break;

                case 1:

                                f += Math.floor(Math.random() * 2) * 2 - 1;

                                break;

                case 2:

                                g += Math.floor(Math.random() * 2) * 2 - 1;

                                break;

                case 3:

                                h += Math.floor(Math.random() * 2) * 2 - 1;

                                break;

                }

                if (f < 1) {

                                f = 10;

                }

                if (g < 1) {

                                g = 4;

                }

                if (h < 1) {

                                h = 4;

                }

                resolution = 100;

                updateCoordinates(resolution);

}

      ]]></Script>

    <TimeSensor DEF="Clock" cycleInterval="16" loop="true"/>

    <ROUTE fromField="coordIndexes" fromNode="OrbitScript"

      toField="set_coordIndex" toNode="Orbit"/>

    <ROUTE fromField="coordinates" fromNode="OrbitScript"

      toField="set_point" toNode="OrbitCoordinates"/>

    <ROUTE fromField="fraction_changed" fromNode="Clock"

      toField="set_fraction" toNode="OrbitScript"/>

    </Scene>   

</X3D>

 

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


More information about the x3d-public mailing list