I'm working with GLSL and Vulkan. Is there a way to keep data computed from vertex shader as "uniform" for all next vertices of one instance ?
I have to create the model matrix inside the vertex shader for bill boarding. And I was wondering if there is a chance to tell the shader to keep a specific data when using instancing knowing it will be the same for all vertices of the instance ?
I could give the model matrix for each instance, but the position and the scaling vectors are enough and reduce the VBO size.
There is no sensible way to pass data between vertices inside the same draw call. That is to say, I'm sure it's technically possible with some hairy use of atomics and storage buffers (if your implementation allows them in the vertex stage, not all do) but it's not going to be at all efficient.
The stream-based nature of the geometry pipeline is explicitly designed to avoid this kind of usage, because this kind of data sharing kills performance scalability for a massively multithreaded architecture. It's usually faster just to recompute the data you need. GPUs are very good at computation, rather less so at efficient cross-thread data sharing. Amdahl's law is a real problem when you have tens of thousands of threads running ...
The more sensible way to do it would be to run a compute shader first, which is responsible for computing the common per instance data and writing it into to a storage buffer, and then you read from that buffer in the following vertex shader using the instance ID as the array index.
That said, this may not help much in practice. GPUs are very good at computation, so unless you are saving a lot of work for a lot of vertices, I'm not entirely convinced this is going to be worth the effort.