<div dir="ltr"><div><a href="https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-WD1/">https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-WD1/</a><br></div><div>- v4 > draft 1 > Shape Component > PointProperties<br><br></div><div>I implemented draft PointProperties in freewrl.</div><div>-Doug Sanden</div><div><div><br></div><div>my experience implementing v4 Draft PointProperties in freewrl:</div><div></div></div><div>Results:<br><div></div><a href="http://dug9.users.sourceforge.net/web3d/tests/points/screenshot_pointproperties_polypoint2d.jpg">http://dug9.users.sourceforge.net/web3d/tests/points/screenshot_pointproperties_polypoint2d.jpg</a><br><a href="http://dug9.users.sourceforge.net/web3d/tests/points/pp_polypoint2D.x3d">http://dug9.users.sourceforge.net/web3d/tests/points/pp_polypoint2D.x3d</a><br><br><a href="http://dug9.users.sourceforge.net/web3d/tests/points/screenshot_paintproperties_pointset.jpg">http://dug9.users.sourceforge.net/web3d/tests/points/screenshot_paintproperties_pointset.jpg</a><br><a href="http://dug9.users.sourceforge.net/web3d/tests/points/pp_pointset.x3d">http://dug9.users.sourceforge.net/web3d/tests/points/pp_pointset.x3d</a><br><br>Implementation<br>It was a lot like ParticleSystems sprites, which freewrl implemented a few years ago, and basically:<br>- instead of GL_POINTS you send a little quad -2 triangles GL_TRIANGLES- with normals and texture coords<br>- then go into a loop over vertices and update the vertex shader with the vertex position via a uniform and draw()</div><div>And when there's a color node, or fogCoords node, I treat it like I do the vertices - send one at a time in the loop via uniform, to the vertex shader.</div><div> <br></div><div>But that loop seems a little inefficient if someone has a massive amount of points to render and all they want is something simple. so I put some effort into thunking to GL_POINTS when no PointProperties node.<br><br></div><div>SPEC COMMENT >>>>></div><div>I found it an easier transition (from LineProperties linewidthScaleFactor to PointProperties pointSizeScaleFactor) if colorMode default was POINT_COLOR instead of TEXTURE_AND_POINT_COLOR</div><div>- then the other defaults can be ignored except pointsizeScaleFactor </div><div>- otherwise if there's no way/trigger/signal to ignore pointSizeMinValue pointSizeMaxValue then you may have to change those 2 from defaults 1,1 every time you change your pointSizeScaleFactor </div><div><<< SPEC COMMENT<br></div><div><br></div><div><div>Internally I have 4 methods for drawing points:<br></div><div>0 - default GL_POINTS method</div><div>1 - SCREEN SCALE - simplified, ignores pointsizeMinValue,pointSizeMaxValue (no clamping) and ignores attenuations</div><div>2. OBJECT SCALE - interprets pointSizeScaleFactor in object space, so points look smaller in the perspective distance</div><div>3. ATTENUATION SCALE - uses attenuations and min/max clamping in screen scale</div><div><br></div><div>methods 1,2,3 use the particle system sprite method</div><div>if we have a PointProperties node, then it does one of method 1,2,3 else method 0.</div><div></div></div><div>I work out which method based on some logic with min,max and attenuation settings</div><div><a href="https://sourceforge.net/p/freewrl/git/ci/develop/tree/freex3d/src/lib/scenegraph/Component_Shape.c">https://sourceforge.net/p/freewrl/git/ci/develop/tree/freex3d/src/lib/scenegraph/Component_Shape.c</a> </div><div>L.1182 in compile_PointProperties</div><div>ScreenScale: attenuation == 1 0 0 and minScale == maxScale</div><div>ObjectScale attanuation == 0 1 0 and minScale << maxScale</div><div>AttenuationScale - everything else</div><div>Then in the vertex shader I do if else on this to get slightly different scaling formula</div><div><a href="https://sourceforge.net/p/freewrl/git/ci/develop/tree/freex3d/src/lib/opengl/Compositing_Shaders.c">https://sourceforge.net/p/freewrl/git/ci/develop/tree/freex3d/src/lib/opengl/Compositing_Shaders.c</a>  </div><div>L.884 in POINTP block</div><div><br></div><div>The frag shader needed a bit of work to get the logic the specs wanted.  L1560 in POINTP block<br></div><div> <br></div><div><br></div><div>It took me 4 days to implement PointProperties in freewrl.</div><div><br></div><div>- that doesn't count 13 days to improve FillProperties and LineProperties which were under-developed </div><div><a href="https://sourceforge.net/p/freewrl/mailman/message/36970701/">https://sourceforge.net/p/freewrl/mailman/message/36970701/</a> </div><div>- fillproperties notes</div><div><a href="https://sourceforge.net/p/freewrl/mailman/message/36980373/">https://sourceforge.net/p/freewrl/mailman/message/36980373/</a></div><div> - lineProperties notes<br></div><div><br></div><div></div><div><br></div></div>