AOV OSL Fog Opacity node?

Forums: AOV OSL Fog Opacity node?
Maxon Cinema 4D (Export script developed by abstrax, Integrated Plugin developed by aoktar)

Moderator: aoktar

AOV OSL Fog Opacity node?

Postby GXGsynth » Fri May 13, 2022 10:16 pm

GXGsynth Fri May 13, 2022 10:16 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
GXGsynth
Licensed Customer
Licensed Customer
 
Posts: 21
Joined: Sun Feb 13, 2022 10:04 pm

Re: AOV OSL Fog Opacity node?

Postby jayroth2020 » Fri May 13, 2022 11:03 pm

jayroth2020 Fri May 13, 2022 11:03 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.
CaseLabs Mercury S8 / ASUS Z10PE-D8 WS / Crucial 64GB 2133 DDR4 / 2 XEON E5-2687W v3 3.1 GHz / EVGA 1600 P2 / 1 EVGA RTX 3090Ti FTW3 Hybrid / 2 EVGA RTX 2080Ti FTW3 Hybrid/ Cinema 4D
jayroth2020
OctaneRender Team
OctaneRender Team
 
Posts: 471
Joined: Mon May 04, 2020 7:30 pm

Re: AOV OSL Fog Opacity node?

Postby GXGsynth » Mon May 23, 2022 4:53 pm

GXGsynth Mon May 23, 2022 4:53 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
Licensed Customer
 
Posts: 21
Joined: Sun Feb 13, 2022 10:04 pm

Re: AOV OSL Fog Opacity node?

Postby GXGsynth » Thu May 26, 2022 6:25 pm

GXGsynth Thu May 26, 2022 6:25 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
GXGsynth
Licensed Customer
Licensed Customer
 
Posts: 21
Joined: Sun Feb 13, 2022 10:04 pm

Re: AOV OSL Fog Opacity node?

Postby jayroth2020 » Thu May 26, 2022 7:38 pm

jayroth2020 Thu May 26, 2022 7:38 pm
I'll take a look at your file, if you like.
CaseLabs Mercury S8 / ASUS Z10PE-D8 WS / Crucial 64GB 2133 DDR4 / 2 XEON E5-2687W v3 3.1 GHz / EVGA 1600 P2 / 1 EVGA RTX 3090Ti FTW3 Hybrid / 2 EVGA RTX 2080Ti FTW3 Hybrid/ Cinema 4D
jayroth2020
OctaneRender Team
OctaneRender Team
 
Posts: 471
Joined: Mon May 04, 2020 7:30 pm

Return to Maxon Cinema 4D


Who is online

Users browsing this forum: MarcoCappelletti and 25 guests

Thu Apr 18, 2024 9:49 am [ UTC ]