Thanks, I’ve been trying to learn more about shaders but even in the RBWhitakers Example shader here:
http://rbwhitaker.wikidot.com/first-shader
The models still are only black. My shader is exactly the same as the one in that example and the model code just is this:
foreach (var mesh in ThisModel.Meshes) { foreach (var meshPart in mesh.MeshParts) { GraphicsDevice.Indices = meshPart.IndexBuffer; Effect effect = ScreenManager.Instance.Content.Load<Effect>("Shaders/shader_02"); effect.CurrentTechnique = effect.Techniques["Ambient"]; effect.Parameters["World"].SetValue(transforms[mesh.ParentBone.Index]); effect.Parameters["View"].SetValue(ScreenManager.Instance.ViewMatrix); effect.Parameters["Projection"].SetValue(ScreenManager.Instance.ProjectionMatrix); foreach (var pass in effect.CurrentTechnique.Passes) { pass.Apply(); } GraphicsDevice.DrawInstancedPrimitives(PrimitiveType.TriangleList, 0, meshPart.StartIndex, meshPart.PrimitiveCount, 1); } }
I’m not sure if it is something I am supposed to be passing into the Shader from the model to get the textures or if it is as you said the model class being janky.
I found one forum post from a while ago with the same problem: Vertex colors are not displayed with custom shader
However the linked solution doesn’t load the website and other solution seems a bit advanced as I am already using the Content Pipeline for a lot of things.
At the end of the day all I am trying to do is improve game performance as best I can (Frustrum, Localized Collision, Occlusion, Instancing where possible) On high object counts. Frustrum is implemented, Localized Collision is Sorted into a Grid (Was using Octree but had issues), Occlusion I have working but I need to get that on multiple buffers somehow as it does only 1 model at a time which is too slow, and Instancing for repeat models such as the ground/grass/flowers.