Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LayerSet/Layer seem **not** to work! #18

Closed
elmkni opened this issue Aug 26, 2019 · 11 comments
Closed

LayerSet/Layer seem **not** to work! #18

elmkni opened this issue Aug 26, 2019 · 11 comments

Comments

@elmkni
Copy link

elmkni commented Aug 26, 2019

Hi Michalis,

I have been trying to establish a kind of static background image for one of my models.

In X3DOM there is the <Background backUrl='test.jpg'></Background>-trick (non-standard of course).

In Instant Reality Player there is PolygonBackground and ImageBackground (both non-standard too),

and then there are at least two ways to do it in standard-X3D:
<ScreenGroup> with <Billboard> and <LayerSet> with <Layer>

but all my attempts to make these two work in View3DScene failed!

The most interesting one for me is the LayerSet/Layer-approach, because this works in x_ite 4.5.11:

test_LayerSet_X_ITE_snapshot

Is there any other standard-X3D possibility to set a static background I have overlooked?

Please help!

Either give me a hint, how to do it, or fix the LayerSet/Layer-nodes, because they are very usefull for a lot of things, like HUDs, Copyrights, Backdrops etc.

With best regards,

Elmar

P.S.: here are my test files: view3dscene_issue_18.zip

@michaliskambi
Copy link
Member

The Layer / LayerSet are not implemented now, indeed. You can consult https://castle-engine.io/x3d_implementation_status.php to see which X3D components are implemented now.

My preferred approach to address this feature is to implement ImageBackground node you mentioned, compatible with InstantReality, http://doc.instantreality.org/documentation/nodetype/ImageBackground/ . Even though it's not a standard node. Reasons:

  • It is a "clean" way to express "a background is defined by a single image". (Does not feel like a "hack" in X3DOM that specially treats the case of Background with a single backUrl filled.)

  • It offers more possible future features: one could use cube map texture for a background using this node (using ImageCubeMapTexture or ComposedCubeMapTextue in ImageBackground.texture field), and this way ImageBackground node could be more powerful than both existing Background and TextureBackground .

  • And it would allow a simple case of static 2D image background.

  • And it is very simple to both use and implement :)

We recently had a discussion about it on x3d-public mailing list, it seems everyone likes ImageBackground :)

There is no (easy) alternative to this yet in view3dscene.

@elmkni
Copy link
Author

elmkni commented Aug 26, 2019

Hi Michalis,

I've read the X3D-public-mailing-list with great interest, especially when I noticed that Andreas Plesch referenced my test model ;)

You wrote: There is no (easy) alternative to this yet in view3dscene.

but actually I just found a non-standard way of doing it in View3DScene!

Although the X3D-standard says:

The X3DBackgroundNode node is subject to the accumulated rotations of its
ancestors' transformations. Scaling and translation transformations are ignored.

this is possible within View3DScene:
backdrop_view3dscene

It is achieved by this:

<X3D profile="Full" version="3.3">
  <Scene>

    <Viewpoint fieldOfView=".4"/>

    <!-- 2368 = imgageHeight/tan(fieldOfView/2) -->
    <Transform scale="640 480 2368" DEF='BACKDROP'>
      <Background frontUrl='"backdrop.jpg"'/>
    </Transform>

    <ProximitySensor DEF="SENSOR" size="1e5 1e5 1e5"/>
    <ROUTE fromNode="SENSOR" fromField="orientation_changed"
             toNode="BACKDROP" toField="set_rotation"/>
    <Shape>
      <Appearance>
        <Material diffuseColor="1 0 0" transparency=".3"/>
      </Appearance>
      <Box/>
    </Shape>

  </Scene>
</X3D>

What do you think of it? (I know, it's a terrible hack and only works with View3DScene)

Clearly it is not perfect (you have to start View3DScene with --geometry 640x480) and a copyright tag would have to be inserted as a Text node that is held in its place close to the zNear clipping plane by the ProximitySensor (rotation and translation), but do-able!

Of course, a solution like Instant Reality Player's ImageBackground would be cool, although I have to imagine that, because InstantReality-Windows-vs2013-x64-2.11.0.45996 can be installed but does not run on Windows 10! -- Why do they support out-dated win7/8 but not win10?

InstantReality_on_Windows_10

If your preferred approach to address this feature is to implement ImageBackground node and it is very simple to both use and implement, then please go ahead and implement it -- I would appreciate it!

(LayerSet/Layer are still a good idea for copyright tags and HUDs!)

With best regards,

Elmar

P.S.: here are the test files: view3dscene_issue_18-1.zip

michaliskambi added a commit to castle-engine/castle-engine that referenced this issue Aug 26, 2019
Reorganize TBackground, TAbstractBackgroundNode to allow non-3D
backgrounds.

Also rename CastleBackground unit to CastleInternalBackground.

See castle-engine/castle-model-viewer#18
michaliskambi added a commit to castle-engine/castle-engine that referenced this issue Aug 26, 2019
@michaliskambi
Copy link
Member

  1. As for the solution with scaled Background node:

    <Transform scale="640 480 2368" DEF='BACKDROP'>
      <Background frontUrl='"backdrop.jpg"'/>
    </Transform>
    

    I'm afraid this hack worked only temporarily because of a bug in our Background transformation treatment, we were not removing the scale correctly.

    I just fixed it, and it means that this hacky solution no longer works.

  2. I looked into ImageBackground, and implemented it :) It was quite easy.

    I tested it on 2 testcases in demo-models, https://github.com/castle-engine/demo-models/blob/master/background/background_image.x3dv and https://github.com/castle-engine/demo-models/blob/master/background/background_image_partial.x3dv , to make sure it's compatible with InstantReality.

    It is not yet nicely documented on CGE webpage, but you can read draft docs on https://github.com/castle-engine/cge-www/blob/master/htdocs/x3d_implementation_environmentaleffects_extensions.php . It is compatible with InstantReality http://doc.instantreality.org/documentation/nodetype/ImageBackground/ as far as I tested. (Note that InstantReality docs of ImageBackground.color are invalid. CGE docs correctly describe both CGE and InstantReality behaviour.)

    BTW latest InstantPlayer works OK for me on Windows 10 (Professional), I just used it to test compatibility.

  3. I agree that Layer / LayerSet are still a good idea. But they are lower priority for me now.

    (The reason is that inside Castle Game Engine, which is a basis of view3dscene, there's a more flexible approach to layers, outside of X3D. So implementing Layer / LayerSet is somewhat less necessary in case of CGE, although view3dscene would use it.)

@michaliskambi
Copy link
Member

P.S. As always, a new build of view3dscene, that you can use to test ImageBackground, should be ready on http://michalis.ii.uni.wroc.pl/view3dscene-snapshots/ in about 15 minutes. Enjoy :)

@elmkni
Copy link
Author

elmkni commented Aug 27, 2019

Hi Michalis,

you took such great effort to implement ImageBackground!

I have tested both files with:
view3dscene-3.18.0-win64-x86_64.zip | 2019-08-27 06:31 | 4.0M | Latest Windows version (64-bit),

but sadly nothing worked!

The cube is visible, but the background turns pitch-black (from the default greyish black),
no squirrel-texture shows up and no errors are reported. -- am I doing something wrong?

Please help!

With best regards,

Elmar

P.S.: InstantReality-Windows-vs2013-x64-2.11.0.45996 seems to be the latest (11.09.2018), and my Windows 10 installation (64 bit) is also latest (10.0.18362.295) -- but they don't cooperate! -- weird!

@michaliskambi
Copy link
Member

Thanks for testing, I think I know what was the cause -- your GPU is detected as unoptimal and we use "enable fixed function" pipeline, and I made a bug when implementing ImageBackground rendering for this case.

I pushed a fix, please try a new view3dscene from http://michalis.ii.uni.wroc.pl/view3dscene-snapshots/ in 15 minutes :)

@elmkni
Copy link
Author

elmkni commented Aug 27, 2019

Hi Michalis,

thanks for the fast fix!

I have tested with:
view3dscene-3.18.0-win64-x86_64.zip | 2019-08-27 12:28 | 4.0M | Latest Windows version (64-bit),

and with this partially transparent (slightly altered) test_image.png from the InstantReality-testset-2.8.0:
background_image

and with this (all-feature test) background_image.x3d:

<X3D profile="Interchange" version="3.2">
<Scene>

  <ImageBackground texCoords="0 0 2 0 2 2 0 2" color="0 1 0 .5">
    <ImageTexture repeatS='false' repeatT='false' url='"background_image.png"'>
      <TextureProperties magnificationFilter='NEAREST_PIXEL'/>
    </ImageTexture>
  </ImageBackground>

  <Shape>
    <Appearance>
      <Material/>
      <ImageTexture url='"background_image.png"'>
        <TextureProperties magnificationFilter='NEAREST_PIXEL'/>
      </ImageTexture>
    </Appearance>
    <Box/>
  </Shape>

</Scene>
</X3D>

and got this result:
background_image_snapshot

As you can see, the <TextureProperties> are not respected by <ImageBackground> but everything else just works fine! -- finally! ;)

Thank you so much -- this is really cool!

If you like (and if it's not to cumbersome), you can implement the TextureProperties node for ImageBackdrop as well for the next version of View3DScene!

With best regards,

Elmar

P.S.: here are my test files: view3dscene_issue_18-2.zip

@michaliskambi
Copy link
Member

Good point about TextureProperties, thank you very much for testing and catching it.

I fixed it, <TextureProperties magnificationFilter='NEAREST_PIXEL'/> will work OK now.

Note that the ImageBackground rendering is a little special, some other TextureProperties features will not work (minificationFilter, anisotropicDegree...). But magnificationFilter has sense of course, so it now works :)

@elmkni
Copy link
Author

elmkni commented Aug 27, 2019

Hi Michalis,

that sounds very good! Could you please trigger a new build, so that I can test it?

Elmar

@michaliskambi
Copy link
Member

Sure, I kicked Jenkins to do it now. Should be ready in ~15 minutes on http://michalis.ii.uni.wroc.pl/view3dscene-snapshots/ .

@elmkni
Copy link
Author

elmkni commented Aug 27, 2019

Hi Michalis,

this time I have tested ImageBackground with a tiny 2x2 PixelTexture (NEAREST_PIXEL) and
view3dscene-3.18.0-win64-x86_64.zip | 2019-08-27 18:04 | 4.0M | Latest Windows version (64-bit).

I used this approach:

<X3D profile="Interchange" version="3.2">
 <Scene>

  <ImageBackground texCoords="0 0 2 0 2 2 0 2" color="1 0 1 .5">
    <PixelTexture DEF='TEST' image='2 2 2 0xFFFF 0xFF80 0xFF80 0xFFFF'>
      <TextureProperties magnificationFilter='NEAREST_PIXEL'/>
    </PixelTexture>
  </ImageBackground>

  <Shape>
    <Appearance><Material/><ImageTexture USE='TEST'/></Appearance><Box/>
  </Shape>

 </Scene>
</X3D>

The result is just what I had hoped for!
test_PixelTexture

Awesome! -- Now you have to get ImageTexture into the next X3D-v4.0-standard! ;)

ImageTexture is certainly also very useful for CGE, like for tiled backgrounds or one could even think of animated texture coordinates, to make the background do funny stuff!

I am really enthusiastic about this achievment of yours!

Thank you very much, again!

With best regards,

Elmar

P.S.: here are my new test files: view3dscene_issue_18-3.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants