Giter Club home page Giter Club logo

Comments (9)

FarazzShaikh avatar FarazzShaikh commented on July 20, 2024 1

Ahh yes, instanceMatrix is not available if not used with InstancedMesh. Glad it’s solved πŸ˜„

from three-customshadermaterial.

FarazzShaikh avatar FarazzShaikh commented on July 20, 2024

csm_PositionRaw is the same as gl_Position thus, to use it with InstancedMesh, you need to multiply the position with the instanceMatrix before projection

csm_PositionRaw = projectionMatrix * modelViewMatrix * instanceMatrix * vec4(position, 1.0);

Let me know if this fixes your issue

csm_Position is the prefered way to override vertex position as you dont need to project or multiply the instanceMatrix to it, it is done for you.

from three-customshadermaterial.

ManHunterGroms avatar ManHunterGroms commented on July 20, 2024

@FarazzShaikh thanks for reply πŸ™
It's very strange, but I get an error:
ERROR: 0:472: 'instanceMatrix' : undeclared identifier

instanceMatrix it should be because I tried to declare attribute mat4 instanceMatrix; it and got an error
ERROR: 0:394: 'instanceMatrix' : redefinition

csm_Position is the prefered way to override vertex position as you dont need to project or multiply the instanceMatrix to it, it is done for you.

I'm working with csm_PositionRaw because I need to convert the vertex position to world coordinates, and csm_Position needs to be passed to local coordinates.

from three-customshadermaterial.

FarazzShaikh avatar FarazzShaikh commented on July 20, 2024

What is your baseMaterial? Can you make a Sandbox (https://codesandbox.io/)? I will debug

from three-customshadermaterial.

FarazzShaikh avatar FarazzShaikh commented on July 20, 2024

Here: https://codesandbox.io/s/wizardly-neco-hczrcn?file=/src/App.tsx:869-976

It seems to work just fine. In my sandbox. Toggling "instanceMesh" in the controls will toggle the multiplication of the matrix.

from three-customshadermaterial.

ManHunterGroms avatar ManHunterGroms commented on July 20, 2024

@FarazzShaikh yeah, sorry for delay, I never used the sandbox)
My sandbox is working fine... strange.
https://codesandbox.io/s/kind-vaughan-thjnch?file=/src/index.js

ok, I will search and fix the error in my project.
Thank you so much for support.

Please do not close the Issue, later I will answer what the problem was πŸ˜€

from three-customshadermaterial.

ManHunterGroms avatar ManHunterGroms commented on July 20, 2024

Found the cause of the problem, I was used the material not only in InstancedMesh πŸ€¦β€β™‚οΈ

from three-customshadermaterial.

FarazzShaikh avatar FarazzShaikh commented on July 20, 2024

What was the solution?

from three-customshadermaterial.

ManHunterGroms avatar ManHunterGroms commented on July 20, 2024

What was the solution?

Use USE_INSTANCING preprocessor directive.

   #ifdef USE_INSTANCING
        vec4 vertexWorldPosition = modelViewMatrix * instanceMatrix * vec4(position, 1.0);
   #else
        vec4 vertexWorldPosition = modelViewMatrix * vec4(position, 1.0);
    #endif

from three-customshadermaterial.

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.