ctrl.buffer v1.5


Hi guys,

          there's an update for the ctrl.buffer shader pack with 
          enhancements, some bug fixes and even new features :)
          . it is no longer required to put a file path where to save additional images,
            leaving the path empty infact the shader will use the xsi output path.
          . added force.correct.extensions to save buildin buffers (depth, normal...)
            with the correct format and extensions automagically.
          . coverage buffer (that is required to correctly filter user framebuffer) has now
            a toggle to be enabled or not from the buffer.api.
          . when applying padding, it is no longer required to fill all the names to have
            correctly saved the user framebuffers.
          . support for xsi.pass.channels that permits to work with them without having
             to use buffer.store in the rendertree.
          bug fixes
          . buildin buffers are now correctly 'padded' when enabled from buffer.write
          . verbose output for buffers not available, when probably not enabled from
          the buffer.api while trying to save them with the buffer.write.
          . coverage and tag buffers are now saved with the correct format.
          new features
          . openEXR is now fully supported.
          . openEXR tiling and various compression support.
          . it is also supported multichannels openEXR, that permits to save all
            the user framebuffer in the same openEXR file to be retrieved later in 
            an editing application that support them (for example Fusion and Shake)
          . customizable timestamping via the additional buffer_xwrite.
            (require to setup an env variable, read instruction)
          what's next ?
        . direct support for xsi.pass.channels in the buffer_Store shader.
          . support for layered photoshop files.
          . if possible (need to check it) support in the fxtree for multichannel openEXR.
        [ctrl.buffers v1.5b](http://www.arteoff.it/ctrl_shaders/ctrl_buffers_v1.5b.rar)
       big thanks to Max at ctrl.studio for all the base code.
      I will post scenes and some video later, during the weekend.


Wow… another great update. Thanks so much.


awesome stuff :thumbsup:
can’t wait to play with this, and yes… any videos and scenes will be appreciately as well!!

Thanks for all the hard work and for sharing this,



Awesome Fran !!!
You guys make working in MentalRay fun :slight_smile:


thanx …as always for the shader

but now for the stupid part i guess what exactly does the shader do for some of us who don’t know what we could be missing out on if we don’t get it or just browsing through and saw it?


Once again thank you Francesca and Max too.


Good stuff Francesca. Thanks.

What are you using to write text on the frame… freetype lib? How are you grabbing the rendertime from mr?


Thank you Fran, It looks great. Cant wait for the videos and scenes, as theres a few questions that I have about this. Do you use this in production at CTRLstudios?


what exactly does the shader do for some of us who don’t know

it’s pretty simple: mentalray can collect during rendering
multiple buffers/channels and write’em out as images
when it has finished its work. with ctrl.buffer you can
control that mechanism. if with xsi5 you have a way to
do it in a ‘pass’ fashion using just pass.channels with
ctrl.buffer you have a customizable way to do it. both
work together in a non exclusive way. you can use
mainly pass channel without having to be worried about
anything if you need standard pass like ambient diffuse
irradiance and a like then you’ll use ctrl.buffer if you
wanna add some personalizations.
with buffer.api you enable the channels. with buffer.store
you’ll fill those channels and with buffer.write you’ll write
them out. pratically each buffer has a numberID, - let’s
say you enable buffer0 and buffer1 via the buffer.api
by specifing 0-1 as range. then in the rendertree
you’ll apply a buffer.store to every object you need to
have their properties in the respective channels… in any
slot of the shader you can just type the numberID you
have enabled to store in the properties you need like
diffuse for example in the buffer0 and specular in the
buffer1. eventually you apply a buffer.write as an output
shader to your pass to spit them out at the end of your
render. infact this way to work does not require you to
shot n. renders to get out in images the mat properties
you need.

How are you grabbing the rendertime from mr?

well believe it, it’s not the most trivial think I ever done.
the camera ftime returns crap. so I grab an initial time with
the buffer_api (that so it is required also if you don’t plan
to spit out buffer… set the min.range to -1 to disable the
buffer feature. same on the buffer_write, -1 for the min it’ll
disable the buffer writing ), and so write a userdata to the
option block, then in the buffer_xwrite I grab the final time,
bring the initial time from the userdata… compare them and
as the difference is in seconds I also need to translate it
in hms. :slight_smile:



for example here a simple scene that works with xsi
pass.channels but that uses buffer.api to enable’ em
and buffer.write to write out a singlemultichannel
openExr plus a coverage image for some advanced
post processing. as we ‘extract’ diffuse, specular
and irradiance… we set the range for the buffer to
0-2, select rgba_h to get half floating point exr, and
check multi.channel in the buffer.write exr options.

(take care that if you open the exr image in an apz that does
not support multichannel you’ll see only the first buffer saved,
in this case the diffuse channel ).





Yup, fully aware. I’ve been trying to finish a timestamp shader for a while now. I’m no MR guru so it’s been a rocky road :slight_smile:

Just getting text on a rendered frame was a feat. I’m using the freetype libs.


also, here a simple scene where I matte a couple
of objects (thing that’s not possible for example
with xsi pass channels) plus the new feature of
timestamping with the correct time per frame,
frame number, buildin buffer numberID (useful to
understand what’s the ID that mentalray uses
internally to map its user frame buffers) plus a
custom text as annotation.

(if you take a look at the verbose when logmessage is
set to information you’ll see in the first part a list of
buffers enabled. the first user frame buffer is the 12
and it is mapped to the ctrl.buffer as 0. not that you
have to take care about this things to use the shaders
but just for your knoweledges).




Hi Fransesca,

Thanks very much for the example scenes, much appreciated :thumbsup:



Thank you Francesca, this is amazing stuff…

P.S. Sorry for the shameless plug, but I am looking for xsi version of multidisplace shader for weeks now, is it still avaliable from somewhere?


not last, we can extract each light contribution and
output it to separate images. here for example there
are two spot lights, one on the left and one on the
right side of the item, one that casts shadow and the
other one that acts more as an ambient light. we will
save each contribution on separate images. as we’re
not really sure about the background we will save it on
a separate image too that will allow us to tweak it in
post. to add a bit of realism we’ll get also an ambient
occlusion pass to be multiplied over the whole. all from
the same render shot.

 (it is required to install a new simple shader called ctrl.xshading. 
 it supports all the xsi features like pass channels, inclusive/exclusive 
 lights and so on but it allows also to link indipendently a list of lights. 
 plus some other things as you can read in the readme file).





nice work

got a few questions though

I was testing this shader last night and I had a pretty complex rendertree that I wanted to output into different passes, now, trying to add the buffer node to a complex tree becomes a nightmare to be honest because of the way its implemented, why do you have to put the node at the end and then plug everything in it? that always created a mess of crossing noodles… why not instead have a “passthrough” style node, like the deriver, for each pass you want to output you just make a new buffer node and tell it where to save out that pass to… that way you dont have to reorganize your rendertree.

also, there probably isnt much to do about this but lets say you want to tweak the specular texture, if you do so if I understand this correctly you have to re-render the whole scene… if you set things up in a more “traditional” way with xsi passes you only have to re-render one pass, just something to keep in mind


wurp !! :slight_smile:

I’m going to enhance the workflow.
I did a mix8layer ala maya where you can plug
things in buffers while having the shader acting
as a passthrough and also to see the whole result in
the renderegion without having to rerender the whole
thing or plug the various user buffers to the main
one to see how they look. I’ll put these things, sure the
‘passthrough’ , also in the buffer.store, thanks for the



ctrl.genius :scream:


Looks very cool fran,
I’m trying to download now but, I’m getting and error,
can’t connect to server ?

edit: its working now :slight_smile:


as you already know i have been waiting for this!! Also your maya mix8layer version hides very well the geo shader and all the mess.
Thanks for the update anyway, it looks easier to combine pass channels and custom buffers now… I am glad to see you back on the xsi side