- Home /
Will Camera.RenderWithShader work with Graphics.DrawMesh (and DrawMeshInstanced)?
I have a script that draws a set of meshes in the scene. Graphics.DrawMesh
at the moment is called in Update
.
I now have to create an effect with a replacement shader that uses an auxiliary camera to render onto a RenderTexture that would later be used for the effect.
RenderWithShader call is done in the OnPreRender
method:
private void OnPostRender()
{
if (repShader != null)
{
auxCam.RenderWithShader(repShader, "");
}
}
I tried OnPostRender too.
And here's how I am drawing in the Update
:
Graphics.DrawMesh(tileMesh, m, tileMaterial, 0, cam, 0, mpb, false, true, false);
Graphics.DrawMesh(tileMesh, m, tileMaterial, 0, auxCam, 0, mpb, false, false); // to aux camera
where mpb
is a MaterialPropertyBlock
Because I have 2 cameras, I am using Graphics.DrawMesh
overloads that take a Camera in their parameters. I don't have any minimal complete examples at the moment but I think the question can be reduced to the following:
does Graphics.DrawMesh
work only with GameObjects present in the scene or does it also work with Meshes that are rendered with Graphics methods?
If this approach doesn't work, what are the alternatives other than turning meshes into GameObject instances?
Your answer
Follow this Question
Related Questions
How to attach a mesh created with Graphics.DrawMesh to a GameObject? 1 Answer
How to access full Shuriken simulation mesh for use with DrawMeshNow? 0 Answers
Graphics.DrawMeshInstancedIndirect vs CommandBuffer.DrawMeshInstancedIndirect 1 Answer
Pro develop to Free 1 Answer
I cannot pass parameters to my custom shaders... help please... 2 Answers