Jump to content

Problems on ObjectMeshCluster and Shader


photo

Recommended Posts

In order to access each mesh of in the ObjectMeshCluster, we are marking each mesh in the cluster with an ID. And the ID is passed into the shader by buffer or texture. In the shader, we use IN_INSTANCE to find the corresponding ID. 

But in the practice, we found the ID is changed by the visible count of the mesh. 

How can we get the right ID like using s_clutter_cluster_instances in the shader? 

Link to comment

Hi @zhang.jian_bin,

have you used the define for clutter and cluster parameters? You can find it in data/core/materials/default/mesh/mesh_base.basemat, str. 547. This define enables logic for Cluster objects.

Also, please check how we handle cluster transformation in vertex shader (data/core/shaders/mesh/common/vertex.h). If you need more help. please, send us your custom shader.

Thanks.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

I found that the problem was in the Calculations phase, Checks the intersections of objects with frustum (frustum culling) and finds those which present in the frame. The RENDER_MESH_NUM_INSTANCES change caused IN_INSTANCE to not correspond to the Id we wrote the texture. And I also want to modify the mesh's transform in the vertex shader, but the original transform will cause an exception to occur in the Calculations stage. How can I turn off the clipping of the related model or override the related vertex shader in the Calculations stage?

Link to comment

The code had been uploaded.

As you can see, our demo is modified from the meshbase material.
The modification is mainly in the file: vertex.h, fragment.h, deferred.shader and ambient.shader.

The problem:  
1 Shadow is not correct.
2 Color and object clipping is not correct while moving the camera.

unigine_ClusterId.rar

Link to comment
  • 1 month later...

Hi Zhang,

Sorry for the late reply.

Unfortunately, there is no way to control the cluster culling, that's why you have these weird artifacts all over again. We can recommend only to use a custom object derived from ObjectExtern. There you can do full custom CPU logic and shading as you want. Trying to adjust built-in Cluster object is not a good choice, because it was designed specifically to do one thing - large performance with static objects.

If you can explain in more details what kind of task you are trying to achieve maybe we can suggest you a different approach that is more suitable for you.

Thanks!

 

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

At first, we are only concerned about performance, and we used lots of clusters in the scene. And then the demand for interaction came, which heavily depends on fast object selection.

It seems that performance and flexibility can not have together.

Link to comment

Hi, silent:
We are going to try the custom object derived from ObjectExtern. It may help us to balance the performance and flexibility.

The problem is: can we utilize the instance rendering capability of the hardware, as we noticed that cluster rendering is similar with instance rendering which may take advantages from hardware.

Link to comment
×
×
  • Create New...