I use instanced model drawing for my minecraft like game. It is a cube world. I succeeded of changing lighting of the HLSL shader. That changes lighting’s of all the instances of the same model. But I want to set lightings from instance to instance. How can I do this?. I know that this could be impossible. But is their any cunning ways to do this?. (I’m Progamming monogame DirectX windows with Visual basic)
What do you mean? A different light for each/some instance?
Or do you wanna change the way some of them reflect light ?
Having a normal map for all instances should allow you to do the latter case and have for ex.one light illuminating and shadowing all the cubes, appearing differently function of their position relative to the light.
I’m hasindu and I wanna know how to set lighting for instance by instance. When we are using instanced model drawing, the shader only used once. Then that lighting are used to draw all the instances. So when used shader effect parameters it changes all the instances.
With how low level a library MonoGame is, it’s really vague if you talk about lighting. There’s million ways to implement it. But the general concept to have per instance lighting is really straightforward if you understand how the underlying system works.
You have a vertex buffer with model data and one with instance data. Whatever is specific to an instance goes into the vertex buffer with instance data. What that data is differs depending on how your lighting/models work. I explained a bit how the binding works in this thread: How to use multiple vertex buffers?
There’s also an example linked in reply.
So basically if you have effect parameters that you want to change for each instance, consider passing them as vertex data in the instance buffer instead.