i wonder if anyone can point me how to achieve:
one scene, two meshes A and B, renderer with 3 viewports
Is it possible to have SELECTIVE RENDERING for every single viewport?
viewport1 renders mesh A only,
viewport2 renders just mesh B,
viewport3 renders mesh A and B
kind of ViewPortLayer option?
all without running multiple instances of the scene.
thanks in advance
perhaps multiple rendertargets might help … there’s an example in the girlpower folder
I’ve checked it before, but could not catch what exactly multiple rendertargets shader does and how i can apply to my situation.
viewport_selective rendering.v4p (15.9 kB)
well what it does, it makes spread of textures out of render, but same technique like in that shader can be used for what you asked for. But…
don’t think that can be apllyed to meshes, more like to the textures ot parts of meshes, don’t forget that shader called for each subset.
and concerning your question, i don’t see a sahader here, three objects can be pretty far from each other
sory for late. what you are asking to do can be done via some trickery. here is the theory:
while all subsets of a mesh will still be drawn in all viewports you can at least selectively hide them by e.g. scaling them to 0 if they are not supposed to be in the currently rendered viewport. so i’d suggest you create a mesh with 3 subsets which you connect to your custom effect. also create an Index on the effect which you fill with a spread of 0, 1 and 2. like this the first subset gets a 0, the second a 1 and the third a 2.
now, as ex9.hlsl.semantics tells us the following two semantics exist for effects in vvvv:
- viewportindex: the index of the currently drawn viewport (int)
- viewportcount: how many viewports the renderer draws (int)
so via the viewportindex you know (in the shader) which viewport is drawn at the moment and you can decide to hide (e.g. scale down to 0) if the Index equals the index. see?
also see the ScreenNumber.fx used by the ScreenNumber (EX9) module.
bump… no text …
SelectiveViewport.fx (3.3 kB)
hah, i’ve been using the exact same method as that shader.
i was wondering if there’d be a way to do something with render states to perform this (although obviously not without some core rewrite) to avoid running the vertex shader on all vertices of all objects in all viewports
@sugoku: if i understand you correctly, this does not make much sense. the main idea of different viewports is to have different views on objects in a scene, right?
so in order to view a mesh through different cameras it is exactly the vertexshader you want to compute per viewport (in order to apply different view/perspective transformations). no?
as a question. i presume vvvv independently renders all objects on all viewports
vvvv renders viewport 1, therefore sets up viewport 1, renders object A, gpu performs vertex shader, etc
vvvv renders viewport 2, therefore sets up viewport 2, renders object A, gpu performs vertex shader, etc
if we could make it so that when vvvv looks at object A, it can see by its render state which viewport it is intended to be rendered on (-1=all, 0,1,etc)
then we save some rendering time by avoiding draw calls for objects not intended for that viewport
this paradigm only works if the patcher is deciding to work that way
e.g. I use the paradigm that:
- viewport 0 = projector 0
- objects on viewport 0 are normalised to -1,1 (no view/projection transform)
- objects on viewport 1 are superimposed on objects on viewport 0, but we only see the correct viewport’s objects for any given viewport.
It works quite well for me, and can easily reorganise viewports.
still not sure i am on the right track. are you essentially talking of a Viewport Index for primitives and effects? i don’t get the renderstate and paradigm parts…
yeah that’s pretty much exactly what i meant
i thought that (although perhaps not 100% truthful to the concept of RenderState), that we could have a
ViewportSelect (RenderState) node