<div dir="ltr">I'm realizing the number of floats could go off the end of the array in the shader. Hmm!<div><br></div><div><br><div><br></div><div>John</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 23, 2024 at 3:12 AM John Carlson <<a href="mailto:yottzumm@gmail.com">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Here are my ideas for VariationPhysicsModel implementation:<div><br></div><div>Particle Physics Model XML:</div><div><br></div><div><VariationPhysicsModel values="2 2 5 5 0 0" varations="2 1 3 3 0.1 0.1" lastFrame='0' updateRate='0.1'><br></div><div>=====================</div><div>X3D Script version. Does not do instance animation</div><div>=====</div><div><br></div><div><div> <Script DEF='Animate'></div><div> <field name="set_fraction" accessType="inputOnly" type="SFFloat"></field></div><div> <field name='values' type='MFFloat' accessType='inputOutput' value='2 2 5 5 0 0'></field></div><div> <field name='variations' type='MFFloat' accessType='inputOutput' value='2 1 3 3 0.1 0.1'></field></div><div> <field name='lastframe' type='SFFloat' accessType='inputOutput' value='0'></field></div><div> <field name='updaterate' type='SFFloat' accessType='inputOutput' value='0.1'></field> <![CDATA[</div><div>ecmascript: function set_fraction(f, tm) {</div><div> if (lastframe + updaterate < tm) { lastframe = tm;</div><div> for (let v in values) {</div><div> values[v] = values[v] + (Math.random() - 0.5) * 2 * variations[v] * 0.1;</div><div> }</div><div> }</div><div> }</div><div>]]></div><div></Script></div></div><div>======</div><div>Shader implementation:</div><div>======</div><div>uniform float [6] values; // change to x3d_ParticleValues<br></div><div><br></div><div><div>vec3 rose(vec3 p, float[6] values) {</div><div> float a = values[0];</div><div> float b = values[1];</div><div> float c = values[2];</div><div> float d = values[3];</div><div> float tdelta = values[4];</div><div> float pdelta = values[5];</div></div><div>[snip]</div><div>=======</div><div>ComposedShader I realize I could pass all floats in one field, but the first 3 SFFloats don't change.</div><div>=======</div><div><div> <ComposedShader DEF="x_ite" language='GLSL'></div><div> <field name='chromaticDispertion' accessType='initializeOnly' type='SFVec3f' value='0.98 1 1.033'></field></div><div> <field name='cube' type='SFNode' accessType="initializeOnly"></div><div> <ComposedCubeMapTexture USE="texture"></ComposedCubeMapTexture></div><div> </field></div><div> <field name='bias' accessType='initializeOnly' type='SFFloat' value='0.5'></field></div><div> <field name='scale' accessType='initializeOnly' type='SFFloat' value='0.5'></field></div><div> <field name='power' accessType='initializeOnly' type='SFFloat' value='2'></field></div><div> <field name='values' type='MFFloat' accessType='inputOutput' value='2 1 4 4 0 0'></field></div><div> <ShaderPart url='"../shaders/x_ite_variations.vs" "<a href="https://coderextreme.net/X3DJSONLD/src/main/shaders/x_ite_variations.vs" target="_blank">https://coderextreme.net/X3DJSONLD/src/main/shaders/x_ite_variations.vs</a>"' type="VERTEX" containerField='parts'></ShaderPart></div><div> <ShaderPart url='"../shaders/commonnew.fs" "<a href="https://coderextreme.net/X3DJSONLD/src/main/shaders/commonnew.fs" target="_blank">https://coderextreme.net/X3DJSONLD/src/main/shaders/commonnew.fs</a>"' containerField='parts' type='FRAGMENT'></ShaderPart></div><div> </ComposedShader></div></div><div>===============================</div><div>Normally I would use separate variables, but I want this to be widely applicable. There should probably be a max array size for performance reasons.</div><div>==================================</div><div>You can see most of my current changes on my <a href="https://github/coderextreme/x_ite" target="_blank">https://github/coderextreme/x_ite</a> repo.</div><div><br></div><div>Here's my current demo:</div><div><br></div><div><a href="https://coderextreme.net/X3DJSONLD/src/main/html/particles.html" target="_blank">https://coderextreme.net/X3DJSONLD/src/main/html/particles.html</a><br></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 22, 2024 at 8:21 PM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">My thought is to add a new input variable in to shader,</div><div dir="auto"><br></div><div dir="auto">in float[] myVariable;</div><div dir="auto"><br></div><div dir="auto">Then provide </div><div dir="auto"><br></div><div dir="auto"><field name=“myVariable” type=“MFFloat” accessType=“inputOnly” value=“…”/></div><div dir="auto"><br></div><div dir="auto">In the ComposedShader.</div><div dir="auto"><br></div><div dir="auto">But I don’t know currently how to tie a particle physics model to a composed shader, nor how to address instances of geometry. The work I’ve done so far addresses all instances, and uses scripts, not wind.</div><div dir="auto"><br></div><div dir="auto">So I need to look into source code a bit.</div><div dir="auto"><br></div><div dir="auto">It would seem that naming individual floats might provide better documentation. I guess an MFFloat is less wordy, and a single float MFFloat can serve as an SFFloat.</div><div dir="auto"><br></div><div dir="auto">John </div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 22, 2024 at 7:53 PM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div dir="auto">Also, one could provide Variational Physics Models that apply to all particles or one particle.</div><div dir="auto"><br></div><div dir="auto">WindPhysicsModel already does this, but the 6 variational physics models I’m imagining affects each particle.</div><div dir="auto"><br></div><div dir="auto">I’ll probably start coding this up tonight, if no one else volunteers.</div><div dir="auto"><br></div><div dir="auto">I don’t know if I need a Script per particle or not. I’m thinking I need to provide toNode and toField (ROUTEs), but on a particle level, so perhaps I need a specialized ROUTE.</div><div dir="auto"><br></div><div dir="auto">How might we combine this with InstancedShape? Can we add ParticleSystems’ PhysicsModels to InstancedShape?</div></div><div dir="auto"><br></div><div dir="auto">I’m looking for more collaboration on reducing the number of Scripts I use.</div><div dir="auto"><br></div><div dir="auto">I’m now seeing that float arrays are a thing in custom shaders, so perhaps for my 6 shader parameters, a single variational physics model is all that is required, with 2 MFFloats, one for values, and one for variation of values.</div><div dir="auto"><br></div><div dir="auto">Thanks!</div><div dir="auto"><br></div><div dir="auto">John</div><div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 22, 2024 at 7:24 PM John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Holger, I would like to provide 2 sets of (SFVec3f of values as well as an SFVec3f of variation corresponding to the values). My thought is to use PhysicsModels in the ParticleSystems. These are not emitters, but something more like a WindPhysicsModel, they parametrically alter the shape of geometry over time in a ComposedShader. There are actually 6 individual SFFloats of values, so technically, I might use 6 WindPhysicsModels, sending speed into the programmable shader, and providing gustiness for variation. But this is not wind, and AFAIK, X_ITE and Sunrize does wind with the WindPhysicsModel. Is there another PhysicsModel available, or should I write my own?<div dir="auto"><br></div><div dir="auto">Would it be better to use 2 MFFloats, and how do I send an MFFloat to the ComposedShader?</div><div dir="auto"><br></div><div dir="auto">Thanks!</div><div dir="auto"><br></div><div dir="auto">John </div>
</blockquote></div></div>
</div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div>