formZ SDK | 5.0 API Reference | Project | Modeling | Rendering | Shaders

fz_shdr_ambient_occl_addtl_contrast

Description

Scales the surface color by additional ambient occlusion contrast. The original (unscaled) ambient factor is passed in, as well as the ambient occlusion factor calculated by . Note, that and fz_shdr_ambient_occl_addtl_contrast are designed to be called together. The first calculates the ambient occlusion contrast between maximum ambient illumination (no occlusion) and no ambient illumination (maxiumum occlusion). This contrasts is multiplied into the ambient factor argument passed to . The scaled ambient factor can now be used in the traditional illumination calculation of a pixel. In order to add additional darkness to areas that have no ambient illumination, but still appear to bright, fz_shdr_ambient_occl_addtl_contrast is called. It further scales the pixel color towards black, based on the ambt_occl_factor calculated by and the amount of additional contrast selected by the user. Therefore, the typical illumination calculation code should be wrapped by those two function calls as shown in the code example. Note, that if a reflection shader also calculates mirrored reflections and glass like transmission, the shading contributed from those calculations to the pixel color should occur after the call to fz_shdr_ambient_occl_addtl_contrast. This is necessary, since the mirrored contribution, is not subject to ambient illumination. For example, in a perfect mirror, one would not want to see any ambient shading.
If the reflection shader choses to handle ambient occlusion with these extra function calls, it is also necessary to tell formZ, that this is done. Therefore, in the shader's callback, the ambient parameter needs to be set up with the api call instead of fz_shdr_set_ambient_parm.
In summary, if the reflection shader is simple and only calculates basic diffuse and ambient illumination, it is ok to not deal with ambient occlusion. formZ will handle it automatically. However, if the reflection shader handles more complex illumination, such as refelction and transmission, it is best to handle ambient oacclusion locally as described above. The glossy sample reflection shader serves as a good example.

Plugin Prototype

void fz_shdr_ambient_occl_addtl_contrast(

fz_rgb_float_td *

col,

double

ambt_factor_org,

double

ambt_occl_factor )

Parameters

col [Input, Result]

The pixel color, which is to be shaded by additional ambient occlusion.

ambt_factor_org [Input]

The original ambient factor, as returned by .

ambt_occl_factor [Input]

The ambient occlusion factor calculated by .

Returns

Error codes.

Availability

6.5.0.0

Plugin Example

fz_shdr_ambient_occl_contrast(ambt_factor,&ambt_factor_new,&ambt_occl_factor);
col = surf_col * (ambt_factor_new * ambient_light) + diff_factor * diff_light;
fz_shdr_ambient_occl_addtl_contrast(col, ambt_factor, ambt_occl_factor);

Script Example

fz_shdr_ambient_occl_contrast(ambt_factor,ambt_factor_new,ambt_occl_factor);
col = surf_col * (ambt_factor_new * ambient_light) + diff_factor * diff_light;
fz_shdr_ambient_occl_addtl_contrast(col, ambt_factor, ambt_occl_factor);

Function Set

fz_shdr_fset


Defined in

fz_rzne_shdr_api.h