Giter VIP home page Giter VIP logo

Comments (13)

KurtGokhan avatar KurtGokhan commented on June 7, 2024

Yes, world space rendering is supported. I haven't tested VR/XR yet but it should also be working. Don't forget to set the event camera.

You need to setup GameObject like this:

image

This is because ReactUnity takes width directly from the element it is attached to. So you need to set Canvas to a high width/height like 1000 then scale it down with something like 1/1000. After that you need to add another GameObject under the canvas and attach ReactUnityUGUI component to that.

When you set width to 6 and height to 3 as in your example, all calculations go wrong. For example if you add 6px margin to an element, it means entire width of the canvas.

from core.

ahoys avatar ahoys commented on June 7, 2024

Ok, I got it otherwise working but for some reason the react content is only rendered for the left eye. I'm using a single pass instanced render mode (URP). Does ReactUnity perhaps use some shader that isn't single pass compatible?

Edit. I just noticed that an h1 element is visible for both eyes. Investigating further...
Edit2. It's the backgroundColor that seems to be only for the left eye. Text seems fine.

from core.

KurtGokhan avatar KurtGokhan commented on June 7, 2024

I am not sure. I will check it asap. I guess the custom shaders I wrote aren't compatible. If text is visible but graphics (background/border etc.) aren't visible, then that is the case.

from core.

ahoys avatar ahoys commented on June 7, 2024

Ok I found a small workaround. Adding a separate black RawImage to act as a background seems to work to some degree.
Text (inside a header element at least) seems to render just fine for both eyes.

So there's something going on with the "backgroundColor" style-attribute.

from core.

KurtGokhan avatar KurtGokhan commented on June 7, 2024

Seems like the culprit is Unity's Mask. Apparently, Mask does not work in stereo rendering. I will write a custom mask shader and component to solve this issue.

Setting background-color also creates a mask so that explains it. Other properties like overflow, border and box-shadow will also have this issue.

from core.

KurtGokhan avatar KurtGokhan commented on June 7, 2024

Fixed in 0.4.3. Let me know if you have other issues.

from core.

ahoys avatar ahoys commented on June 7, 2024

That was fast, thank you! The one-eye rendering bug seems to be solved now. However, I stumbled upon a few new ones now:

(The following are from 0.4.3)

(1)
This may be a bit (really) hard to see, but the screen (background) has a strange banding effect going on. Like some lines that seem to be mirroring the HMD rotation. Difficult to see in the pic, but quite noticeable in VR, especially as they're constantly rotating.

(2) Another thing are the white borders. Didn't have those with the RawImage approach.
image

And one more is that the base "page" beneath the app seems to stay white, even though the root component (App) is set to be background: black in css. This causes two issues: 1) as the screen appears, the UI is initially white and then rapidly switches to black. 2) As in the picture below, any opacity to the canvas group is displayed as white, instead of as the actual background color. This is unfortunate if the UI canvas is animated to appear/disappear like in this case.
image

import './app.css';

const App = () => <view id={'app'}>Home</view>;

Renderer.render(<App />);
#app {
  position: absolute;
  top: 48px;
  right: 48px;
  bottom: 48px;
  left: 48px;
  overflow: hidden;
  color: #ffffff;
  background: #000000;
}

And here's a vid just to be safe:
https://youtu.be/Chblb7nqGQk

from core.

KurtGokhan avatar KurtGokhan commented on June 7, 2024

About 2:

There is a root element above the #app element. It is the GameObject which you assign ReactUnityUGUI. I guess white color comes from that. You should remove image components from that element if they exist. You can then style root element like:

:root {
  background-color: #000000;
}

Also, use background-color instead of background. background sets the background-image, and that is a bit different. This is my bad. It was a temporary solution until I implement full background spec.

any opacity to the canvas group is displayed as white

I don't understand this part. Can you try the solution above and see if that fixes it?

I will check why the border appears. I guess there are some floating point errors.

from core.

ahoys avatar ahoys commented on June 7, 2024

The :root didn't solve the mystery, but it did perhaps reveal a clue; the black "border" caused by the root's black background doesn't seem to have the same fade to white issue as the background of the App. As the menu fades away, the root background fades properly but the App container switches to white.

:root {
  background-color: #000000;
}

image

I don't understand this part. Can you try the solution above and see if that fixes it?

I'm altering the alpha of the parent canvas to programmatically fade-in/out the menu as seen in the video. This should fade out the menu on close, but the issue is that the App component turns white if the parent canvas has alpha applied that != 1.0.

image

And this is App if it has no background color set. The proper behavior should probably be transparent and therefore a black background (of :root).
image

from core.

ahoys avatar ahoys commented on June 7, 2024

And here's a pic of the strange line artifacts with some Photoshop enhancement:
image

These lines rotate and move (probably because the canvas is locked to HMD orientation and the lines seem like some kind of reflection perhaps?).

from core.

KurtGokhan avatar KurtGokhan commented on June 7, 2024

I found the white background. Seems like I introduced this bug in the last version. It was a bit rushed. Should be fixed now but I don't know if it is the source of your issue.

About the diagonal lines, I don't think they are caused by reflection. The UI shaders are unlit. In any case, I explicitly disabled reflection and specular. Issue may be fixed in 0.4.4. I haven't noticed any issue in my Rift S.

To me, it seems like sun flare is clipping through UI. Can you try with a regular Unity Canvas and see if the same problem happens?

from core.

ahoys avatar ahoys commented on June 7, 2024

The 0.4.4 fixed all the issues stated above, even the lines! Bravo 👏🏻

from core.

KurtGokhan avatar KurtGokhan commented on June 7, 2024

Thank you for your help. Testing ReactUnity in all platforms can be hard for me alone so I appreciate when users report bugs. Sorry for the trouble.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.