View Full Version : final gathering with custom shaders ?
June 25th, 2007, 21:19
In my custom shaders, I would like to use final gathering.
In the code I have :
//Detect final gather preprocessing phase
int dummy; //for tile size query
if (state->options->finalgather && !mi_query(miQ_TILE_PIXELS, state, 0, dummy))
//We are in FG preprocessing phase
miIRRAD_DEFAULT( &opts, state );
if(state->type == miRAY_SHADOW || state->type == miRAY_DISPLACE || miRAY_PHOTON(state->type))
*result = transp_black;
Should I add something else to support final gathering ?
It seems that enabling it has no effect in my scene on my custom shaders.
June 28th, 2007, 01:18
When using FG with my custom shaders, the final gather preprocess phase result to a black image then everything is drawn normallly.
But when using the others shaders, we see a draft of the resulting image.
Does someone know why this is wrong with my custom shaders ?
June 29th, 2007, 03:43
Detection for the pre-processing phase is not necessary for the regular use of finalgathering. Usually detection is used to optimize out things that are not necessary at pre-processing time.
First try using mi_compute_avg_radiance without the fg phase detection. It will return your indirect illumination which you can then multiply by your diffuse color.
At FG pre-processing time, mr knows to save the first hit from the camera into an FG point automatically.
June 29th, 2007, 03:46
Also, note that something in the scene during that phase has to return a color in order to see anything. If it is all only compute_avg_radiance, and there is no environment color, then no light is entering the scene to see it eventually indirectly. I hope that made sense.
June 29th, 2007, 19:52
Actually my shader is special as it's a shader that is a container for 3 others shaders.
It stores these 3 shaders, the first in the frame buffer and the 2 others in additional users frame buffers.
So I need to detect the phase of FG preprocessing or if not I get an error with users frame buffer not created as they are created after the FG preprocess phase.
But the mi_compute_avg_radiance call is made in the shader that is stored in the frame buffer not in the container.
So what should I modify to handle correctly FG ?
June 30th, 2007, 04:59
First of all, user framebuffers are specified and entered into the mental ray database at scene input, or if in a geometry shader, at scene preprocessing time.
Look at the render phase diagram in http://www.lamrug.org/resources/memorytips.html
mental ray Memory Tips
Framebuffers are created before FG point presampling.
You are on shader beta and have looked at the framebuffer code, right?
Those 10 input framebuffer shaders you could use for a container template.
Note they depend on user framebuffers having already been created by a geometry shader or by the application.
June 30th, 2007, 06:52
Well, it seems like if they are not created before the preprocessing phase as if I don't detect this FG preprocess, I get an error in my shader as the users frame buffers are not yet created, the mi_fb_put return miFALSE.
This is in Maya 7, 8.5, same in Max 8,9.
July 3rd, 2007, 09:30
That doesn't seem right, or I'm misunderstanding something. Are they being created by the Maya UI, or by geometry shaders? There is no max UI to create framebuffers.
Did you try the framebuffer code we have supplied? Make sure that works first, and then proceed in the direction of your code.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.