shawn0326 / zen-3d

JavaScript 3D library.
MIT License
196 stars 24 forks source link

Possibility of envmap rotation #32

Closed VanderSP closed 1 year ago

VanderSP commented 1 year ago

Hi... as nativescript are going to release canvas 2 soon, i would like to say that im using zen3d in my project, also actually i can´t grab the six cube envmap thing, it only gets one of the sides... i dunno if it will be solved in v2

Since i would use the envmap just for capturing another position of envmap, to give variations and tune visually, i tried by myself look into super three code, but im not smart enough to try to do the same in zen3d

i really appreciate if you give me even some hack or patch to enable it on zen!

Thanks by now...

shawn0326 commented 1 year ago

Sorry for the late reply. I was working on another new rendering engine in the last year, so zen3d temporarily stopped maintenance. The new engine is an upgraded version of zen3d, which will be uploaded to github in the next week or two. The new engine has been improved in many ways. In the new engine, we added an anchorMatrix attribute for scene. The rotation of envmap can be achieved by setting the anchorMatrix. So if time permits, we highly recommend that you consider using a new engine later. I will add the GitHub address of the new engine to the readme description after open source.

VanderSP commented 1 year ago

wooo really? and it´s the zen3d dna inside it? im very fan of it because it´s less cluttered than threejs, got the important stuff, is compatible with threejs, and lighter and more compatible with mobiles... and honestly threejs after 12x started to make a lot of mess with everything and they don´t see it!

thanks for the reply... if it´s a zen better, it will come in a nice moment, as ns canvas will be finishing the 2.0 soon maybe in one month... anyway the v1.1 is very cool already, just slower, and some context2d bug with adrenos, but mali ok.. maybe in v2 fixed...

shawn0326 commented 1 year ago

Since i would use the envmap just for capturing another position of envmap, to give variations and tune visually

I'm not sure. Are you trying to switch between panoramic balls?

VanderSP commented 1 year ago

i mean, web works... it´s a problem when using with ns canvas... the six cube gl capture... but it´s not priority, since he´s releasing v2 soon... and you are doing the anchor thing

shawn0326 commented 1 year ago

Okay, I am currently preparing for the new engine before open source. The new engine will try to retain the advantages and features of zen3d, and will provide some supporting extension libraries, such as post-processing libraries. In the future, we will add WebGPU support. Welcome to continue using

VanderSP commented 1 year ago

very nice!, ns canvas 3 in the future, also will have vulkan / metal support... the developer is awesome, you can reach us on discord nativescript server if you want

VanderSP commented 1 year ago

Hi im pretty anxious and curious about the new zen3d... while im testing illumination in blender, i found that i only can really nice illuminate my object if i do something like, location z 2.27m and rotation z -5.4 (i used one called tropical beach.hdr)

so i found that location z is also too important, (for example making the sun at zenith top goes down to face the object) the anchor scene thing u did is both rotation and location? yes location distorts hdr, but im using it for illumination only

Thanks.

shawn0326 commented 1 year ago

Currently we just implement the rotation of the envMap, by setting scene.anchorMatrix (rotation matrix), and the position movement will not affect the reflection effect of envMap. However, the effect of Blender is very interesting to me, and I will see how to achieve it later. BTW, I just uploaded the code of the new engine to github, you can check it out if you are interested: https://github.com/UINOSOFT/t3d.js

VanderSP commented 1 year ago

wow i will check it... to be honest rotation is already nice.. because i was fooled probably that blender is too darkish... remember when tested in js engine it was nice illuminated, also always there´s a possibility of ambient/dir lights... but i think that rotation is enough.... location would be just an extra bonus!

Thanks, i will look into the new engine now!

VanderSP commented 1 year ago

Nice, i was looking the project source and examples, also from post processing! watta lot of work u did!!!!

in the scene anchor example, idk if i got it, without anchor it gets messy, but no with offset at 0, and with anchor offset does nothing... i think the anchor thing is to rotate envmap, but there´s something you tailoring in the ui control example yet

VanderSP commented 1 year ago

Can you elucidate more about the new renderer? i noted you instead doing updateLights, u call renderstates and queue, also u use a forwardrenderer in some examples... can you explain the differences between zen3d renderer, and core one? which path you recommends? i would like to know the best advantages use cases etc

Thanks!

shawn0326 commented 1 year ago

in the scene anchor example, idk if i got it, without anchor it gets messy, but no with offset at 0, and with anchor offset does nothing... i think the anchor thing is to rotate envmap, but there´s something you tailoring in the ui control example yet

Yes, the main function of anchorMatrix is ​​to fix the floating-point precision problem caused when the origin is too far away. The principle is that the local matrix of the anchor will be used as the root matrix in the shader. So, if the anchorMatrix contains a rotation, the envMap will rotate accordingly. The current example does not set the rotation for the anchorMatrix, you can modify the example to try, like: scene.anchorMatrix.makeRotationAxis(new t3d.Vector3(0, 1, 0), Math.PI / 4);

shawn0326 commented 1 year ago

Can you elucidate more about the new renderer? i noted you instead doing updateLights, u call renderstates and queue, also u use a forwardrenderer in some examples... can you explain the differences between zen3d renderer, and core one? which path you recommends? i would like to know the best advantages use cases etc

Like zen3d, t3d still separates the scene update and collection logic, and further subdivides the rendering granularity to obtain a more flexible rendering configuration. If you don't need to modify the default rendering configuration, you can directly use the ForwardRenderer in the example to get an experience similar to threejs. If you need to do some customized rendering configuration, you can manually call the lower-level interfaces like renderScene and renderRenderableList. In the examples, you can see that some examples that do not need to modify the default rendering process generally use ForwardRenderer directly, so that the code will be more concise. In some cases where post-processing is required or multiple renders are performed, lower-level render interfaces are used.

VanderSP commented 1 year ago

Thanks for both replies, clarified a lot... your last reply was something i imagined but wanted to confirm.. and the previous one came in the right moment as i will test rotation now, it will improve my graphics lighting letting me tune the envmap position!

Thanks Bro! i hope my project goes well in public, now im getting closer like few months to finish it... it´s a nice idea to credit T3D in some credits place on app?

shawn0326 commented 1 year ago

it depends on your workload. If you have enough time and the new features are very much needed, I would like to recommend you to switch to T3D. At present, it can basically cover the existing features of zen3d, and the interface has not changed much. And we plan to maintain it for a long time, and we also have had a large number of projects using it.

VanderSP commented 1 year ago

Yeah im already using, i liked it... u revamped things like texture2dloader, pmremgenerator, interesting stuff

VanderSP commented 1 year ago

Ah, cool that you are around... last thing i will disturb you, is while i merged geometries in three... im getting error on zen/t3d

nextRadian = startRadians
  cardsOffset = 0.5

  const tempBuffer = []

  for (let i = 0; i < 5; i++) {
    const degSlotRad = (360 / 5) * startRadians
    tempBuffer.push(
      SDCard.root.children[0].geometry
        .clone()
        .applyMatrix4(new t3d.Matrix4().makeRotationY(i * degSlotRad))
        .applyMatrix4(
          new t3d.Matrix4().makeTranslation(
            5 * (Math.sin(nextRadian) * cardsOffset),
            0,
            5 * (Math.cos(degSlotRad * i) * cardsOffset)
          )
        )
    )
    nextRadian += degSlotRad
  }
  ring = new t3d.Mesh(mergeBufferGeometries(tempBuffer), material)
  scene.add(ring)

it doesn´t know what makeRotationY is... any light to quick fix it?

i remember u did something in lab clouds

shawn0326 commented 1 year ago

Because Matrix4 of zen3d/t3d has no makeRotationY method A simpler way is to extend this method for Matrix4 before running the above code: t3d.Matrix4.prototype.makeRotationY = function() { // copy from three }

VanderSP commented 1 year ago

okay i copied it, probably will need to copy maketranslation also, then imported geometryutils, but now im stuck here


    const clonedGeo = SDCard.root.children[0].geometry.clone()
    GeometryUtils.applyMatrix4(clonedGeo, )  

    /* .applyMatrix(new t3d.Matrix4().makeRotationY(i * degSlotRad))
    .applyMatrix(
      new t3d.Matrix4().makeTranslation(
        5 * (Math.sin(nextRadian) * cardsOffset),
        0,
        5 * (Math.cos(degSlotRad * i) * cardsOffset)
      )
    ) */

    tempBuffer.push(

    )

i need to create some temporary mesh??? im a bit lost lol, THANKS

VanderSP commented 1 year ago

hey, think I suddenly got an insight, and it worked, check if it´s fine for you:


  const tempBuffer = []

  for (let i = 0; i < 5; i++) {
    const degSlotRad = (360 / 5) * startRadians

    const clonedGeo = SDCard.root.children[0].geometry.clone()
    GeometryUtils.applyMatrix4(clonedGeo, new t3d.Matrix4().makeRotationY(i * degSlotRad))
    GeometryUtils.applyMatrix4(
      clonedGeo,
      new t3d.Matrix4().makeTranslation(
        5 * (Math.sin(nextRadian) * cardsOffset),
        0,
        5 * (Math.cos(degSlotRad * i) * cardsOffset)
      )
    )
    tempBuffer.push(clonedGeo)
    nextRadian += degSlotRad
  }
  ring = new t3d.Mesh(GeometryUtils.mergeGeometries(tempBuffer), material)