Dreaded Artifacts. A bad sign this is going to be a long day. |
In material shaders, this is probably caused by RGB values you are returning to the renderer are outside the 0.0 to 1.0 range, which can often cause such random behavior in the final image.
You can check for these problems easily using a single box designed specifically to help debug such errors in shaders.. it's called ColorCheck, which can be found in Functions->DebugTools->ColorCheck, and looks like..
Basically, you insert this box into a data stream where you suspect the values are falling outside the range 0.0 to 1.0. Always connect IN to the value you suspect is going out of range, and either pass EOUT or COUT down the chain.
Use EOUT if you want to flag offending colors in a particular 'error color' like red. (You can pick the error color via the ERR input color). For instance:
|
|
Before: rendered image shows random image artifacts. | After: Inserting ColorCheck into the datastream, using EOUT to reveal regions of rogue values in bright red. |
Use COUT if you just want the offending colors clamped to reasonable values. This often gets rid of the artifacts, giving a good indication that range problems are probably the cause:
|
|
Before: rendered image shows random image artifacts. | After: Using COUT clamps the values to the 0.0 - 1.0 range, removing all the artifacts. |
As an added convenience, when the PRINT flag is enabled, offending colors are printed to your text window as RGBA values, for the purposes of scrutiny.. for instance:
ColorCheck ERROR: soft_material_3_OUT = -0.022404 0.059902 0.142209 1.000000 ColorCheck ERROR: soft_material_3_OUT = 1.526663 1.717495 1.908328 1.000000 ColorCheck ERROR: soft_material_3_OUT = 1.414190 1.590963 1.767737 1.000000 |
This is ColorCheck's output. Note it only prints colors that have any of their components outside the 0.0 - 1.0 range. |
If this gets too verbose, you can always turn the PRINT flag off by setting it to FALSE.
The following layout shows what'd you'd have to do without the ColorCheck box just to check for values greater than 1.0 using the low level logic boxes. But this may be valuable to give you an idea of how to make custom debugging.
In this case, any component value greater than 1.0 is printed, and the output color becomes a bright magenta, flagging the offending color:
Rogue color tester. Tests if any color component exceeds 1.0, printing rogue values to screen, and shows in the render in a magenta warning color. This only does half of what the ColorCheck box does for you. |
Greater_Than Box. Compare A inputs to 1.0. |
If Box. Magenta 'True' value. |
The input color comes in from the lower left, and is broken into its RGB components, and delivered individually to the A inputs of each greater than test; all are compared to 1.0 at the B inputs.
The boolean outputs are logically OR'ed together, controling an IF box. This either passes the original color through its FALSE input, or if any component exceeds 1.0, returns the bright magenta color at the IF box's TRUE input.
Also, the boolean OR box triggers the PRINTF box to print the rogue input color to the screen.