user32

I'm trying to render two separate models (x-files) with the same shader-technique but each with a different pass. Is this possible I tried this but keep seeing the rendered objects rendered with the first pass.

Re: XNA Framework Using multiple passes in same technique

Kyle_W

I believe that the ModelMesh.Draw() method will automatically iterate through all passes of the current technique. Passes within a technique are not really intended to be used individually. You really should use a separate technique or a separate Effect for the second model. If there is some reason why you feel those options would not work for you, please explain.



Re: XNA Framework Using multiple passes in same technique

Ultrahead

... Passes within a technique are not really intended to be used individually ...

Well, unless you need to improve performance and thus, decide to avoid changing techniques -and consider a pass as a "different technique"- to gain some speed ...






Re: XNA Framework Using multiple passes in same technique

user32

Correct, that's why i tried something like:

if
(e.CurrentTechnique.Name.Equals("Effect1") && pass.Name.Equals("Pass_1"))

To separate functionality to different passes (to no avail though ;)).
The reason for my question is that i'm trying to streamline the output from RenderMonkey to XNA. That went pretty good until i encountered that in RenderMonkey you can select different models to passes and so assumed that this also could be done with XNA. Thanks for the tip, i will not pursue this any further.





Re: XNA Framework Using multiple passes in same technique

Kyle_W

Well I don't believe it is common practice, but I won't go so far as to say that it cannot be done. I thought I had seen a lower level Draw() method other than ModelMesh.Draw() that could be used with a Model, but now when I look for it I can't find it.



Re: XNA Framework Using multiple passes in same technique

Shawn Hargreaves - MSFT

Ultrahead wrote:

... Passes within a technique are not really intended to be used individually ...

Well, unless you need to improve performance and thus, decide to avoid changing techniques -and consider a pass as a "different technique"- to gain some speed ...



I very much doubt you'll see any perf gain from doing something like that.

The reason changing effect technique costs is because this has to alter lots of renderstates on the graphics device. There is no difference in how much state has to change when you switch between two techniques, compared to two passes that change the same amount of state, so there isn't any huge performance difference between one and the other.

The effect system is designed to use techniques to represent different ways of rendering an object, and passes to represent multiple draw calls that are needed to display a single object. I would very much recommend using it like this: trying to force passes to do what techniques were designed for is just going to cause hassle and not gain you anything useful.