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

discussion: set renderer settings using javascript at instantiation? #872

Open
kfarr opened this issue Sep 18, 2024 · 3 comments
Open

discussion: set renderer settings using javascript at instantiation? #872

kfarr opened this issue Sep 18, 2024 · 3 comments
Assignees

Comments

@kfarr
Copy link
Collaborator

kfarr commented Sep 18, 2024

@vincentfretin for discussion, curious to get your thoughts -- both logdepthbuffer and preservedrawbuffer are settings that we want to set in some cases, but maybe not in others.

For example logdepth doesn't work with gaussian splat scenes at the moment, and in theory preserveddrawbuffer may result in undesirable performance on lower power devices (not proven).

One approach is to be able to set these renderer settings when it is instantiated but instead of as attributes on the a-scene, instead to use javascript logic -- either from a querystring, hash, or a database lookup.

@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in 3DStreet Dev Tracking Sep 18, 2024
@kfarr kfarr moved this from Backlog (Not Ready) to To Do - High Prio in 3DStreet Dev Tracking Sep 18, 2024
@vincentfretin
Copy link
Collaborator

With the current aframe code, logarithmicDepthBuffer can only be set initially in the html, see
https://github.com/aframevr/aframe/blob/daf507ec1022380787f218bc71bc96d4a7d6a9d0/src/core/scene/a-scene.js#L636

In my project I'm generating the a-scene from solidjs

<a-scene
        attr:renderer={`anisotropy:4;stencil:true;physicallyCorrectLights:true;colorManagement:true;logarithmicDepthBuffer:${
          searchParams.logarithmicDepthBuffer === "true"
        }`}
>

so I can use ?logarithmicDepthBuffer=true in the url.

The aframe code doesn't really allow to recreate the WebGLRenderer with a different config, and I don't think you can change logarithmicDepthBuffer after it's created.
You would need to change the aframe code to check for a query string in the url, that would be the simpler change.

@kfarr
Copy link
Collaborator Author

kfarr commented Sep 18, 2024

The aframe code doesn't really allow to recreate the WebGLRenderer with a different config, and I don't think you can change logarithmicDepthBuffer after it's created.

@vincentfretin thanks yes that's the point of my question here. It does seems like you are doing exactly what I'm suggesting via solidjs -- is that not possible with 3dstreet because of index.html structure hardcoding the values -- and the only way to do that is to inject the a-scene dynamically such that we can control the attribute values of renderer like you are doing with solidjs? Or is it possible to set the attribute value of renderer prior to the scene being instantiated?

Here's a not good, crazy idea but just brainstorming another way:

  • a-frame scene somehow takes an optional promise that returns a renderer configuration
  • the promise is controlled by our app to give it time to fetch querystring, database or other logic to determine renderer settings
  • only after the promise is resolved will the configuration object allow the scene to start

@vincentfretin
Copy link
Collaborator

Oh actually it should now be possible to wait before initializing aframe in aframe 1.6.0/master with
aframevr/aframe#5481

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To Do - High Prio
Development

No branches or pull requests

2 participants