AOV OSL Fog Opacity node?

Maxon Cinema 4D (Export script developed by abstrax, Integrated Plugin developed by aoktar)

Moderators: ChrisHekman, aoktar

Post Reply
GXGsynth
Licensed Customer
Posts: 21
Joined: Sun Feb 13, 2022 10:04 pm

Following Lino Grandi's tutorial about using AOVs + Z-Depth for fog in Octane for Blender and trying to apply the same concept in the C4D Octane isn't quite as straightforward as I'd hoped

looking at the AOV section of the manual, the example it gives shows the use of an OSL Fog Opacity node to create a fast fog composite, where can I find the OSL script for this?
Image

is this demo scene available for download somewhere?
Image
jayroth2020
OctaneRender Team
Posts: 488
Joined: Mon May 04, 2020 7:30 pm

Create an OSL texture node, and paste the following OSL script into it. Then compile:

Code: Select all

shader OslTexture(
    float density = 0.1 [[string label="Density", float min=0.01, float max=100]],
    float maxDistance = 1000 [[string label="Max. distance", float min=0.01, float max=1000000, float slidermin=1, float slidermax=10000]],
    output color c = 0)
{
    float dist = clamp(length(transform("camera", P)), 0, maxDistance);
    float opacity = clamp(1 - exp(-dist * density* 0.001), 0, 1);
    c = color(opacity);
}
This is the exact OSL script I used for the image and the nodegraph you showed.
Puget Systems / Intel Core Z790 ATX / RTX 4090 / Cinema 4D
GXGsynth
Licensed Customer
Posts: 21
Joined: Sun Feb 13, 2022 10:04 pm

jayroth2020 wrote:Create an OSL texture node, and paste the following OSL script into it. Then compile:

Code: Select all

shader OslTexture(
    float density = 0.1 [[string label="Density", float min=0.01, float max=100]],
    float maxDistance = 1000 [[string label="Max. distance", float min=0.01, float max=1000000, float slidermin=1, float slidermax=10000]],
    output color c = 0)
{
    float dist = clamp(length(transform("camera", P)), 0, maxDistance);
    float opacity = clamp(1 - exp(-dist * density* 0.001), 0, 1);
    c = color(opacity);
}
This is the exact OSL script I used for the image and the nodegraph you showed.
Thank you for this! any advice on getting it working? I can get the Global Tex AOV to show up correctly if the Composite AOV is disconnected, but as soon as I connect the Composite AOV, my Global Tex AOV disappears and I can't get the compositing to work at all. What blending modes do I need for the Composite AOV Output layers?
2022-05-23 11_45_15 - .png
2022-05-23 11_45_22 - .png
2022-05-23 11_45_33 - .png
2022-05-23 11_45_41 - .png
GXGsynth
Licensed Customer
Posts: 21
Joined: Sun Feb 13, 2022 10:04 pm

jayroth2020 wrote:Create an OSL texture node, and paste the following OSL script into it. Then compile:

Code: Select all

shader OslTexture(
    float density = 0.1 [[string label="Density", float min=0.01, float max=100]],
    float maxDistance = 1000 [[string label="Max. distance", float min=0.01, float max=1000000, float slidermin=1, float slidermax=10000]],
    output color c = 0)
{
    float dist = clamp(length(transform("camera", P)), 0, maxDistance);
    float opacity = clamp(1 - exp(-dist * density* 0.001), 0, 1);
    c = color(opacity);
}
This is the exact OSL script I used for the image and the nodegraph you showed.
any chance you'd upload that scene file? I'm still failing to get this working properly
jayroth2020
OctaneRender Team
Posts: 488
Joined: Mon May 04, 2020 7:30 pm

I'll take a look at your file, if you like.
Puget Systems / Intel Core Z790 ATX / RTX 4090 / Cinema 4D
Post Reply

Return to “Maxon Cinema 4D”