create3000 / x_ite

X_ITE X3D Browser, view and manipulate X3D and VRML scenes in HTML.
https://create3000.github.io/x_ite/
Other
67 stars 15 forks source link

Shaders nearly working #149

Closed coderextreme closed 1 year ago

coderextreme commented 1 year ago

See:

https://coderextreme.net/X3DJSONLD/src/main/html/indexts.html

I believe the stars should be glass-like, not white.

Thanks for any help.

John

image

Your example HTML:

image

coderextreme commented 1 year ago

Here's how I'd like to use shaders. Please let me know if it is NOT possible. It's nearly working now! Thanks!

                            <ComposedShader DEF="shader" language="GLSL">
                  <field name='cube' type='SFInt32' accessType='inputOutput' value='0'></field>

                  <field name='chromaticDispertion' accessType='initializeOnly' type='SFVec3f' value='0.98 1.0 1.033'></field>
                  <field name='bias' type='SFFloat' accessType='inputOutput' value='0.5'></field>
                  <field name='scale' type='SFFloat' accessType='inputOutput' value='0.5'></field>
                  <field name='power' type='SFFloat' accessType='inputOutput' value='2'></field>
                  <field name='a' type='SFFloat' accessType='inputOutput' value='10'></field>
                  <field name='b' type='SFFloat' accessType='inputOutput' value='1'></field>
                  <field name='c' type='SFFloat' accessType='inputOutput' value='20'></field>
                  <field name='d' type='SFFloat' accessType='inputOutput' value='20'></field>
                  <field name='tdelta' type='SFFloat' accessType='inputOutput' value='0'></field>
                  <field name='pdelta' type='SFFloat' accessType='inputOutput' value='0'></field>
                                <ShaderPart type="VERTEX">
                                        <IS>
                                        <connect nodeField="url" protoField="vertex"/>
                                        </IS>
                                </ShaderPart>
                                <ShaderPart type='FRAGMENT'>
                                        <IS>
                                        <connect nodeField="url" protoField="fragment"/>
                                        </IS>
                                </ShaderPart>
                            </ComposedShader>

Here's the dependent code:

                <ExternProtoDeclare name="FlowerProto" url='"../personal/flowerproto.json#FlowerProto" "https://coderextreme.net/X3DJSONLD/src/main/personal/flowerproto.json#FlowerProto"'>
                        <field accessType='inputOutput' name='vertex' type='MFString'/>
                        <field accessType='inputOutput' name='fragment' type='MFString'/>
                </ExternProtoDeclare>
                <ProtoDeclare name="flower">
                        <ProtoBody>
                                <Group>
                                        <ProtoInstance name="FlowerProto">
                                                <fieldValue name="vertex" value='"../shaders/x_ite_flowers_chromatic.vs"'></fieldValue>
                                                <fieldValue name="fragment" value='"../shaders/x_ite.fs"'></fieldValue>
                                        </ProtoInstance>
                                </Group>
                        </ProtoBody>
                </ProtoDeclare>
                <ProtoInstance name="flower"/>
                <ProtoInstance name="flower"/>
                <ProtoInstance name="flower"/>
                <ProtoInstance name="flower"/>
                <ProtoInstance name="flower"/>
                <ProtoInstance name="flower"/>
coderextreme commented 1 year ago

I am working on stripping out JQuery. It seems to want to stick it's nose into things.

create3000 commented 1 year ago

As it turn out you have set X3D version of FlowerProto file, to 4.0, but the file contains a ComposedCubeMapTexture. In X3D4.0 there are changes in the field names to this texture, see:

https://www.web3d.org/documents/specifications/19775-1/V4.0/Part01/components/environmentalTexturing.html#ComposedCubeMapTexture

Either go back to 3.3 or do changes the field names.

coderextreme commented 1 year ago

That fixed it! Thanks!