How do you use the Mesh and Model Draw() methods? I have tried using them in a PostEffect script and attempted hooking them into some RenderTask callbacks but cannot seem it get it to work. I am attempting to draw a bunch of instances simulate to how I would do it in Unity by submitting a model and an array of Transform information.
I anticipate this might be a longer thread as I have a couple more questions regarding this but this is the first step I need to figure out.
Currently I am just trying to Render a custom mesh with material using the RenderPipeline.
Here is a simple example of what I am trying.
public class DrawModel : PostProcessEffect
{
public Model Model;
public Material Material;
// Just referencing Actor to use transform for debugging
// I don't want to actualy use the Actor
public Actor TargetTransform;
Matrix _matrix;
public bool Valid;
public override bool CanRender()
{
Valid = (Model != null && Material != null && TargetTransform != null);
return Valid && this.Actor.IsActiveInHierarchy;
}
public override void Render(GPUContext context, ref RenderContext renderContext, GPUTexture input, GPUTexture output)
{
_matrix = TargetTransform.Transform.GetWorld();
Model.Draw(ref renderContext, Material, ref _matrix); // Nothing happens..
}
}
So to elaborate a little more. I’m trying to understand the graphics pipeline process.
I want to render a list of models/meshes that will render the same as Flax already does but without having to use the Renderer method that takes an actor list.
I am assuming I have to subscribe to multiple callbacks for each stage of the process (depth/gbuffer/forward) and loop through each mesh in the Model and submit a call with the material set to the specific pass.
But right now I’m just traying to get the Model.Draw() to do something lol.
So far using the PostProcessScript render method will draw the objects emission when set to after deffered. I have not been able to get anything to happen using callbacks from MainRenderTask.
Since I am able to atleast get emissions to render on the PostProcessScript I am assuming I might have to bind the targets for Normal and Diffuse as they are most likely multirender targets?