Multi pass shaders

Aug 29, 2013 at 12:35pm

Multi pass shaders

I’ve made an SSAO shader (4 different shader) in Max, BUT for this I need to render 3 different textures from the same geometry, so i made 3 different vertex/fragment shader pairs and connected each to a copy of the jit.gl.mesh object … (One’s output is a normal lighting shader, other outputs a texture with viewspace coorinates rendered into the rgb texture, the 3rd will render the normals into texture output)

so now, i need 3 copies of the same object in the same position/scale/rotation (same geometry) to be able to work with it, as every object has it’s own shader if i know it well from MAX tutorials…

My question is: is there any way in MAX, to render a mesh with different fragment shaders in the same frame? so i wouldnt need 3 copies of the mesh in max, 3 times more vertex data to GPU transfer, and 3 times running the vertex shader on the same geometry…

Transmitting 3 times more vertex data and running the same vertex shader 3 times for the same data doesn’t seems too efficient method to do it :))))

thanx in adv,
Kevin

#260219
Aug 30, 2013 at 5:55pm

MRT (multi render targers) are not available yet in Max. So its all tricks. An approach I once took to do shadowing was to use layers and cameras.

  • for each auto bang of render
  • have one or more cameras as you need which capture to texture
  • sequence the layers so that as each camera outputs its texture for the scene, that then causes a param to be sent to your shader. a trigger hooked on the camera’s matrix outlet can be great for this
  • the shader changes modes based on this param (the 3 or 4 of them you need)
  • etc

It took many days of experimenting and using Max debugging to get the sequencing right and not need a lot of duplicate ob3ds. Finally it worked.

#263787
Sep 1, 2013 at 3:36pm

Thanx a lot, it makes sense will get on this to see if i can make it work! :)

#263925

You must be logged in to reply to this topic.