Here my question is
i am using instance buffer geometry with shader material but i am not able to pick the instances
So i walk through the article and found that it is going to work with instancemesh is that right or is there any other way to pick objects
InstancedMesh takes a BufferGeometry, not InstancedBufferGeometry as your file indicates you are using. Other than that you’ll have to provide more information on what you’re doing / trying to do in order for us to help.
Can you make a jsfiddle that demonstrates your issue?
This is not true , it is working now but i am not able to pick any objects from my instanced mesh. Means raycasting is not working , i am using this example to achieve my goal.
if we look at my intancebuffergeometry so i am using some attributes like elevation and orientation and shader material so according to that these attribute values my object is following the terrain. So here my question is can we achieve this affect with shader material also.
Main things here why raycasting is not working due to instanceBufferGeometry
This is not true , it is working now but i am not able to pick any objects from my instanced mesh.
Again without an example demonstrating the issue it’s hard to pin down exactly what’s happening. I was simply pointing out what the documentation states you should use – there should be no reason to use InstancedBufferGeometry even if it works.
Regarding your raycasting issue you’ll need to make a jsfiddle. It entirely depends on what you’re doing in the shader and it’s not productive for us to guess.
But you can walk through the code so here i have a shader program that is running for an instanceBufferGeometry is it possible to pick the individual instances if not so i have such a same shader program for each instance i will share that instance data also to you but first let me know the possbility.
The fiddle you’ve posted doe not run for me. I get the following error:
three.module.js:41367 Uncaught TypeError: Cannot read property 'type' of undefined
That aside it looks like you are doing custom calculations to set gl_Position in the shader which means that three.js cannot know where the triangles wind up being transformed to – so you’ll have to implement a custom raycast function. And it looks like you aren’t using instanceMatrix, either, which means there’s no point to using InstancedMesh here, either. I recommend using a regular ShaderMaterial rather than RawShaderMaterial and regular Mesh in that case.
Unfortunately not – shaders can be notoriously difficult to debug. I often output intermediate variables as color so I can more easily see what’s going on.