Why are the Unity API lacking support for different kind of rendering primitives and only offer triangles ?
Why does the Unity API need to specify all color and normal attributes per vertex and not per mesh (or per primitive if they existed) ?
Why are the Unity API lacking support for different kind of rendering primitives and only offer triangles ?
Why does the Unity API need to specify all color and normal attributes per vertex and not per mesh (or per primitive if they existed) ?
What kind of primitives do you lack and in which Unity API?
You can use multiple different primitive types, as set by the MeshTopology.
It only supports those primitive types and per-vertex attributes since those are the only primitive types and attribute definition GPUs support. More complex polygon shape primitives shapes always need to be meshed into triangles for the GPU (and Quads on most GPUs are automatically converted into triangles for you by the graphics API, very few support those in hardware).
If you want per-primitive attributes, you can define those as an array or compute buffer/structured buffer and access that via the SV_PrimitiveID in the fragment shader. If you want per-mesh attributes, isn’t that what a material is for?
I miss trifans and tristrips as this reduces the number of vertices sent to the gpu through the api for streaming and extensive loading of large geometries
I also lack the ability to set a normal per primitive. You can help me here. What should i do if i only want one normal per primitive or one normal for the entire mesh
Unity doesn’t appear to use triangle strips anymore because on modern hardware it offers no benefits over basic indexed triangles. The triangle array uses very little memory, only the vertex array really matters, and you can easily reuse vertices when using indexed triangles.
You also can’t set a normal per primitive since it’s not something GPUs support. If you want a single normal per primitive, see the various threads on flat shading. If you want a single normal per mesh, either store the same normal in every vertex, or use a material with a normal vector property.
So i have to store a normal for every vertex ? Is this really performant ?
I use a lot of rendering where i upload just one normal and other attributes per primitive or per complete mesh
I agree its not that common nowadays to upload color or normal per primitive but at least per mesh should be there in the API. What a waste of time setting an array of normals for each vertex if you just want an overall attribute
You can use a material property for that, as @bgolus said.
Ah. Didnt get that you could set properties per material . Great response ! Thanx both of you !
So if i just want to set a normal mean and lean for a complete mesh, would i use set vector with some specific name or how ?
A material is a container for properties and a reference to a shader to use. You’ll need a custom shader that defines a Vector property and uses that as the normal during shading.
Ok. Thanx for the clarifications. Its now clear !