Using hardware Instancing and Custom Shaders together

Following the Hardware instancing tutorial found at:
https://github.com/playcanvas/playcanvas.github.io/blob/master/graphics/hardware-instancing.html

ive realized that the interface of StandardMaterial(hardware instancing) differs greatly from Material interface(custom Shaders)…All I want to know is how do I create hardware instanced custom shader objects… introduce custom shaders to a standard material object? introduce instancing to material object?

Hi @plasmalasgun,

There is no difference on how you enable hardware instancing on a standard material:

      // --- enable instancing on any material
      material.onUpdateShader = function (options) {
        options.useInstancing = true;
        return options;
      };
      material.update();

On that material you can override most shader chunks and write shader code that will affect each instance separately.

If you would like to introduce additional instancing parameters check this thread on how to do it:

2 Likes