We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

batch geometry and flipped normals

Home Forums Puzzles batch geometry and flipped normals

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #70083

    Hi im trying to optimize my scene, it currently consists of many instances which is flipped because of symmetry, for instance i have a steel frame that is symmetrical, what i did is, i duplicated it as instance and flippet it, having x1 y-1 z1, when this is applied the faces becomes flipped as expected, this can be worked around using double sided, and double sided shadows, and setting alpha clip in blend mode to allow ambient occlusion.
    BUT, when i use Batch geometry this does not do what i expect, the flipped half of the object becomes dark, something about shading, this is strange because if i try to merge these two instances before export leaving the other half with flipped normals, everything looks normal.

    Attachments:
    You must be logged in to view attached files.
    #70107
    xeon
    Customer

    This is an interesting issue.

    There is an issue when you scale an object on any single axis as -1 when you plan to use the Batch Geo puzzle. Lets just say that doesnt work well.

    If you want a mirror of your original object…then try 1, -1, -1. That will also fix the dark issue and it will work using the Batch Geo puzzle.

    However the better solution would be to scale your object to 1, -1, 1, then Apply Scale.
    If you notice the faces get inverted. Flip the normals and then you can include it in your batch for the Batch Geo puzzle and all will be good.

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #70146

    Thanks for the repsonse Xeon, however in my case i cant use 1, -1, -1. because of the symmetry, at least that i know of, i havent explored in depth.

    Also if i apply scale i would end up with two objects, not one instance. i did this on purpose to lower the file size tremendeously.

    Maybe there is a way to apply scale and recalculate normals afterwards in code,, but it might be very heavy task for any device.

    #70147
    Ben
    Customer

    Hi Michael,
    I’m working on a scene that sounds very similar to yours and came across the same issue – I’ve got an array of tiles and every other tile is flipped on an axis to create a kind of repeating symmetrical pattern. I found that the flipped tiles were shaded fine when separate, but when I batched them all every other tile was darker.

    In my case I found that when batched the flipped tiles took lighting info from the underside instead, so since my HDRI was darker underneath the tiles were receiving less light and appeared darker. I was able to solve it by switching the material to a simple emission, since shadows etc weren’t important in my case. I expect a uniform background light would also do the job.

    I’m not sure how you could get them shaded correctly by directional lights etc though, is there any way to flip normals in verge?

    #70196

    Hi Ben, thanks for the reply, if i could leave them unshaded then problem solved, but i have to use shading, for a bit of realism.

    At the moment im trying to explore the code behind the batch procedure, but im not a programmer.

    #70199
    kdv
    Participant

    Share your test app (with the .blend file) here. I’ll try to find the solution.

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #70277

    Hi!

    Here is the test:
    https://v3d.net/oki

    Thanks in advance, very grateful!

    #70280
    kdv
    Participant

    Ok, good test ))) But now zip it and attach the archive here )))

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #70358
    kdv
    Participant

    Solution:
    https://www.soft8soft.com/docs/api/en/core/BufferGeometry.html#computeVertexNormals

    https://v3d.net/sus

    i duplicated it as instance and flippet it, having x1 y-1 z1

    Actually, the scale of the mirrored clone is (-1, -1, -1)

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #70424
    Ben
    Customer

    Hi kdv, would you mind giving a quick example of how to use .computeVertexNormals() ?

    I have very little knowledge of coding, would it use an exec script node?
    Have gotten as far as trying the below amateur attempt in an exec script without any luck:

    var obj = app.scene.getObjectByName(VARS[‘object_reference’]);
    obj.computeVertexNormals()

    Thanks!

    #70425
    kdv
    Participant
    if (obj && obj.geometry)
      obj.geometry.computeVertexNormals();

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #72562

    Hi Kdv, its been long since ive looked at this further, thanks for the sollution, however im not very skilled at coding, yet, can you please provide a more practical explanation to how you got the test to work properly?

    #72563
    kdv
    Participant

    in an exec script

    const obj = app.scene.getObjectByName(VARS['object_reference']);
    if (obj && obj.geometry)
      obj.geometry.computeVertexNormals();

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #73278

    thanks kdv!

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.