- Home /
Does static batching work with replacement shaders?
It doesn't appear to, with dynamic batching. I don't have Unity Pro, so I just want to know.
Here's an easy way for you to test:
- Create a new scene.
- Create a primitive.
- Set the primitive as static.
- Parent the primitive to the camera.
- Duplicate the primitive a few times.
- Attach the script below to the camera (*):
- Drag the shader below onto that variable slot:
- Hit Play and watch the Stats window.
(*) I've never used StaticBatchingUtility. If this isn't the correct usage, let me know.
var shader : Shader;
function Awake () { StaticBatchingUtility.Combine(gameObject); camera.SetReplacementShader(shader, "RenderType"); }
.
Shader "Replacement" {
SubShader { Tags {"RenderType"="Opaque"} Pass {} }
}
ok, I think i get what static batching is all about. Now a question for you... do you mean replacement shaders you've written? Or do you mean replacing shaders during runtime?
Your answer
Follow this Question
Related Questions
static batching and verts 1 Answer
Will calling setActive on static objects cause overhead? 0 Answers
Static Batching with Asset Bundles 1 Answer
"Tree creator" trees with wind, static batching? 0 Answers
Static Batching Weird Bug 0 Answers