[x3d-public] X3D Working Group meeting minutes, 27 July 2018: LocalFog

Michalis Kamburelis michalis.kambi at gmail.com
Sat Aug 4 16:24:26 PDT 2018


Hi Don!

Sorry for the delay in answering. Busy times:) My answers are inlined below.

2018-07-28 5:40 GMT+02:00 Don Brutzman <brutzman at nps.edu>:
> Feedback much appreciated.  It could certainly be our misunderstanding of
> the specification, interpreting "Local" both as a location-based and as a
> scene-graph-local effect.
>
> Meanwhile no fog effect has any direct impact on a viewpoint per se, it is
> only affected Shape objects whose rendering changes.

As far as I understand, fog works like this:

- Fog effect (indicated by "Fog" and "LocalFog" nodes) means that a
Shape color is mixed with a fog color. The amount (how much it is
mixed) depends on the distance of geometry to the viewer.

- Note: I use the words "viewer", "camera", "viewpoint" to mean the
same thing (and so does the spec, I think).

- The "lighting equations" in X3D specification
http://www.web3d.org/documents/specifications/19775-1/V3.2/Part01/components/lighting.html#Lightingmodel
give the details. In particular see there the definition of

   d_V = distance from point on geometry to viewer's position, in
coordinate system of current fog node

   See also there at the table "Table 17.5 — Calculation of the fog
interpolant" and see how f_0 is used in the final equation.

- Both "Fog" and "LocalFog" nodes produce the same effect, same
equations (mentioned above) apply.

- The difference between "Fog" and "LocalFog" is how we specify fog
parameters (and whether fog exists).

    - "Fog" is a bindable node and follows normal bindable node rules
-- so only one, or none, "Fog" node is active, and it affects
everything.

    - "LocalFog" affects only the shapes in the same group (using a
similar approach as pointing-device sensors or non-global lights to
determine "which shapes are effected"). The specification describes
this exactly at
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#FogSemantics
. It also clarifies that "LocalFog" overrides "Fog", in case they both
affect a given shape.

- Specification of both "Fog" and "LocalFog" says to calculate
distances "... in the coordinate space of the Fog/LocalFog node". In
my understanding, this simply means that scale of the transformation
of "Fog" and "LocalFog" matters, which makes sense. Merely translating
the "Fog" and "LocalFog" node doesn't matter (otherwise the
specification words about "distance from point on geometry to viewer's
position" would be moot, and also fog would have non-standard meaning,
compared to fog in e.g. fixed-function OpenGL).

In my eyes, the specification is clear here.

>
> It is certainly a bit confusing.  Your response makes sense but some issues
> (of understanding at least) remain.  We should work on this concept a bit
> more...
>
> a. Do you agree with the foggy rendering of the left side columns in the
> example (within scope) while the other right-side columns (outside of scope
> but quite close nearby, inside LocalFog boundaries) have no fog effects?

You mean on http://www.web3d.org/x3d/content/examples/ConformanceNist/Miscellaneous/LocalFog/LocalFogEffectsTestIndex.html
?

Yes, I agree with observed results with both X_ITE and view3dscene.

- Right side columns are always greenish (from the green light in
http://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Chapter23Fog/Figure23_1FogTestWorld.x3d
, included using "Inline"). The camera doesn't matter.

- Left side columns are pure white when they are away from the viewer
(as pure white is the default LocalFog color), and greenish when the
are close to the viewer.

- None of them are affected in any way by the LocalFog center position
(either initial, or animated), and they should not be.

>
> b. If LocalFog only changes the effect on objects within it's scene subgraph
> scope, might all views be able to see its effect even if the Viewpoint is
> outside that scene subgraph?  What if the bound Viewpoint is not in the same
> subgraph, is there any difference?  If Viewpoints outside the scene subgraph
> see the LocalFog effects, then Viewpoints are not subject to scene-graph
> scope like shapes are.

Indeed, Viewpoints are bindable nodes.They are not subject to scene-graph scope.

It doesn't matter where (in which children) is the current Viewpoint
in the scene-graph. For "Fog", "LocalFog", or any other rendering
output (shapes, lights...). All that matters is the 3D position of the
viewpoint in world-space.

>
> c.  Based on your understanding, is fog density uniform within the
> visibilityRange sphere centered about LocalFog coordinate frame?

The fog is not uniform --- the fog color is applied following the
equations on http://www.web3d.org/documents/specifications/19775-1/V3.2/Part01/components/lighting.html#Lightingmodel
, table "Table 17.5 — Calculation of the fog interpolant", and see how
f_0 is mixed in the final equation. In short, the fog intensity grows
linearly or exponentially.

Conceptually, there is no "visibilityRange sphere centered about
LocalFog coordinate frame". There is, instead, "visibilityRange sphere
centered about the current camera position", this sphere matters for
"LocalFog" and "Fog".

>
> d. We often get fog in different parts of the Monterey area, and it usually
> tends to be situated with respect to location (for example in a small valley
> or blowing in from sea).  The visibility of objects within that localized
> fog is primarily dependent on x-y-z location, fog density is strongest
> inside and dissipates with lesser density at the boundaries of the fog zone.
> The following images show the location dependency of fog effects.
>
> https://en.wikipedia.org/wiki/Fog
> https://en.wikipedia.org/wiki/Fog#/media/File:High_Desert_Fog.jpg
> https://en.wikipedia.org/wiki/Fog#/media/File:San_francisco_in_fog_with_rays.jpg
> https://en.wikipedia.org/wiki/Fog#/media/File:Seattle_Columbia_Pano2.jpg
>
> d. Consider that last image from Seattle.  If the camera zooms in towards a
> street on the left, I'd expect that the observed fog effects would not
> change while the camera is outside the fog bank.  That is because the same
> number of moisture/fog particles are occluding the view, fogging the target
> shape.  It is only when the camera is within the physical boundaries of the
> fog bank that effects begin to vary based on camera distance.

I understand what you want to achieve in c. and d. But this is not
something that can be expressed with only "Fog" or "LocalFog" nodes,
as far as I can tell.

To get what you want, I think you should:

1. Use "FogCoordinate", see
http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#FogCoordinate
. It can be used together with either "Fog" or "LocalFog". The
"FogCoordinate" allows you to make fog most intense at any chosen XYZ
position, regardless of the current camera position.

2. Or don't use X3D fog nodes, instead use shader nodes or CGE
"compositing shader effect" nodes. They both allow to express a fog
using any equation you wish, and could simulate what you show on the
photos. It is not (easily) cross-browser portable solution,
unfortunately.

    A volumetric fog effect (using 3D noise texture for density) is
one of the demos on https://castle-engine.io/compositing_shaders.php ,
the model is on
https://github.com/castle-engine/demo-models/blob/master/compositing_shaders/volumetric_animated_fog.x3dv
, but it works only in view3dscene and other Castle Game Engine-based
application. It will not work in any other popular X3D browser.

>
> e. LocalFog use within an Inline would seem to have no effect on anything
> else in the overall scene under these definitions.

Yes. "LocalFog" in an "Inline" has only effect within that "Inline".

This is consistent with other nodes that have scope-based behavior.
Pointing device sensors, lights with global=FALSE, also can work only
within an "Inline" in which they exist.

Best regards,
Michalis

>
> We might do well to list some expected use cases, describe expected effects,
> check spec prose for consistency, then craft some simple scenes that
> demonstrate them.
>
> On 7/27/2018 5:56 PM, GPU Group wrote:
>>
>> I'm pretty sure freewill follows the Michalis interpretation.
>> -Doug
>>
>> On Fri, Jul 27, 2018 at 6:28 PM, Michalis Kamburelis
>> <michalis.kambi at gmail.com <mailto:michalis.kambi at gmail.com>> wrote:
>>
>>     2018-07-27 18:49 GMT+02:00 Don Brutzman <brutzman at nps.edu
>> <mailto:brutzman at nps.edu>>:
>>     > 4. LocalFog work.  Sungmin Kwon and I have been considering how to
>> use
>>     > LocalFog for
>>     >
>>     > 24.4.4 LocalFog
>>     >
>> http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#LocalFog
>> <http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#LocalFog>
>>     >
>>     > states:
>>     > "The LocalFog node provides a way to simulate atmospheric effects by
>>     > blending objects with the colour specified by the color field based
>> on the
>>     > distances of the various objects from the viewer."
>>     >
>>     > This is incorrect.  LocalFog intensity doesn't consider the viewer
>> distance.
>>     > Rather the next sentence pertains:
>>     > "The distances are calculated in the coordinate space of the
>> LocalFog node."
>>     >
>>     > Recommended correction: change "from the viewer" to something like
>> "from the
>>     > local center of the LocalFog node's transformation heirarchy".
>>
>>     The change of LocalFog prose, as you propose, would break the way it
>>     is implemented in view3dscene / Castle Game Engine. It would also
>>     break my understanding, and use-cases, of the LocalFog node.
>>
>>     I see in
>> http://www.web3d.org/x3d/content/examples/ConformanceNist/Miscellaneous/LocalFog/LocalFogEffectsPresentation.pdf
>> <http://www.web3d.org/x3d/content/examples/ConformanceNist/Miscellaneous/LocalFog/LocalFogEffectsPresentation.pdf>
>>     that you  made tests (with 2 browsers that support LocalFog). But I
>>     tested X_ITE at
>>
>> http://www.web3d.org/x3d/content/examples/ConformanceNist/Miscellaneous/LocalFog/LocalFogEffectsTestIndex.html
>> <http://www.web3d.org/x3d/content/examples/ConformanceNist/Miscellaneous/LocalFog/LocalFogEffectsTestIndex.html>
>>     now, and I don't see your conclusions. In X_ITE, the visible intensity
>>     of fog produced by "LocalFog" depends on the distance from the viewer.
>>     X_ITE (at least on my browser, Firefox 60.0.1) behaves exactly like
>>     X3D specification currently says, and exactly like view3dscene/CGE
>>     already do. The fog amount depends on the distance from the viewer,
>>     i.e. moving the camera makes the fog appear at objects closer to you.
>>
>>     For me (and for my implementation of view3dscene / Castle Game
>>     Engine), LocalFog means that the fog is applied based on the distance
>>     *from the viewer*, not from the "local center of the LocalFog node's
>>     transformation hierarchy" as you propose to change. Various prose in
>> the
>>     specification makes it clear IMHO that it's the distance from the
>>     viewer:
>>
>>     - "...based on the distances of the various objects from the viewer"
>>
>>     - "Objects located outside the visibilityRange from the viewer are
>>     drawn with a constant colour..."
>>
>>      From
>> http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#LocalFog
>> <http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#LocalFog>
>>     .
>>
>>     The LocalFog calculation is much like global Fog calculation in this
>> regard.
>>
>>     The only difference (and the reason for "Local" prefix) betwen
>>     LocalFog and Fog is that LocalFog only affects a subset of the scene
>>     (following "24.2.2.3 Local fog semantics",
>>
>> http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#LocalFogSemantics
>> <http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#LocalFogSemantics>
>>     ). Only the things within the same parent as LocalFog are affected. In
>>     contrast, global Fog affects everything, and is a "bindable" node.
>>
>>     While the X3D spec talks about the "local coordinate system" of
>>     LocalFog, I always understood it to mean that one should apply the
>>     scaling (from LocalFog parent transformations) to visibilityRange.
>>     Nothing more. Exactly the same as the global Fog node is also in
>>     "local coordinate system" (
>>
>> http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#Fog
>> <http://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#Fog>
>>     ).
>>
>>     My use-case for LocalFog is when you want to cover only specific nodes
>>     with fog, while leaving the rest of the world un-fogged (or with
>>     different fog settings). Like this (in classic encoding):
>>
>>     ```
>>        Group { ... stuff that is unaffected by red fog ... }
>>        Group {
>>          children [
>>            LocalFog { color 1 0 0 }
>>            Group { ... stuff that is affected by red fog ... }
>>          ]
>>        }
>>     ```
>>
>>     That being said, I support the idea of testing this on various X3D
>>     browsers. If all the other X3D browsers interpret LocalFog as you
>>     describe (calculating distance from local center, not viewer), then of
>>     course we should adjust the specification, and I will adjust my
>>     implementation:)
>>
>>     Maybe I misinterpret something in your mail and PDF, since your own
>>     test (on X_ITE) contradicts your conclusions, as far as I can see.
>>     X_ITE seems to measure the distance from the viewer, just like X3D
>>     spec already says, and as view3dscene/CGE do.
>>
>>     Apologies in advance if this is just a big misunderstanding on my
>> part:)
>>
>>     Best regards,
>>     Michalis
>>
>>     _______________________________________________
>>     x3d-public mailing list
>>     x3d-public at web3d.org <mailto:x3d-public at web3d.org>
>>     http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>> <http://web3d.org/mailman/listinfo/x3d-public_web3d.org>
>>
>>
>>
>>
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>
>
>
> 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
>



More information about the x3d-public mailing list