lunedì 28 dicembre 2015

Day 108: Vertex attributes abstraction

Today I jumped right into the shadow/lights shaders, in order to make them work with the same batch as the other ones. However I immediatly noticed the first problem: they send less vertex attributes...just the position, instead of position,uvs, normals and tangent.

In the ryno engine the shader has ~4 types of data: vertices attributes, instance attributes, temporary uniforms and global uniforms. The latter 3 are now automatically handled, however I didn't do it for the vertices, because they are consistent when rendering geometry, and I manually specified them.

However in my goal of an olistic system that handles all the shaders with a single batch class, I needed to take care of that as well. I decided to just use a big macro-vertex struct, and then send only the attributes found in the shader. If an attribute is called "in_Position", "in_Uv", "in_Tangent" or "in_Normal", the batch sends data to the shader by sampling the vertex struct.

This works well with the geometry shader, however i'll probably need to tweaks a few things to make it work with meshes that use a different vertex format, but it shouldn't take long.

Nessun commento:

Posta un commento