Blur OSL node and render time

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

Moderators: ChrisHekman, aoktar

Post Reply
FxDesign
Licensed Customer
Posts: 110
Joined: Wed Apr 24, 2013 10:47 am
Contact:

Hi,

I've noticed that using the OSL node "blur" works well, but increase a lot the render times, when pushing iterations up.

Is there an other way/node to blur input textures without increasing render times ?

Thank you
User avatar
SSmolak
Licensed Customer
Posts: 1157
Joined: Sat Feb 07, 2015 5:41 pm
Location: Poland
Contact:

Yes, this is awful that Octane doesn't have real built-in blur node. Even simple contrast in color correction node doesn't work well.
Sometimes you can achieve good result using Baking node with low resolution. It is effective for smoothing bumps and roughness.
Architectural Visualizations http://www.archviz-4d.studio
ofirgardy
Licensed Customer
Posts: 14
Joined: Wed Feb 05, 2020 12:17 pm

How have you manged to get the Blur.OSL to work?
I was following this tut (for RS) and trying to mimic it in Octane for 3dsmax (not that it matters much)- but couldn't.

could you elaborate on how you did it? or maybe post a screengrab of the flow?

Darby Edelen's wonderful set:
https://github.com/.../RedshiftOSLSha.. ... /README.md

How to apply in RS:
https://youtu.be/D65HyxaC35o?si=mew5R61-2-ooIH3v

Here is a link to FB where I've asked the community for assistance:
https://www.facebook.com/groups/OctaneR ... 278479467/
frankmci
Licensed Customer
Posts: 917
Joined: Fri May 26, 2017 2:00 pm
Location: Washington DC

I don't use Octane in Max, but according to the manual it seems to have the same "OSL Delayed UV" option that is required in C4D when doing certain OSL UV related stuff.
Animation Technical Director - Washington DC
ofirgardy
Licensed Customer
Posts: 14
Joined: Wed Feb 05, 2020 12:17 pm

Yes. I understood this just like you did. But failed to recreate.

Do you have any idea how to implement this (even in C4D) I guess I could match it in Max.
frankmci
Licensed Customer
Posts: 917
Joined: Fri May 26, 2017 2:00 pm
Location: Washington DC

ofirgardy wrote:Yes. I understood this just like you did. But failed to recreate.

Do you have any idea how to implement this (even in C4D) I guess I could match it in Max.
Oops. I thought I had added a picture in my reply. Here you go. The setting is in the standard Texture Projection node.
Attachments
"OSL Delayed UVs" projection with OSL blur node
"OSL Delayed UVs" projection with OSL blur node
Animation Technical Director - Washington DC
ofirgardy
Licensed Customer
Posts: 14
Joined: Wed Feb 05, 2020 12:17 pm

I can see you've started with a specular material.

then plugged what? the Blur.OSL into the Albedo? or is it another type of OSL there?
Then second is the Checkers? or is the Second one titled "Image Texture" is that the Blur.OSL?

the last one - the delayed Projection - this one is straight forward
frankmci
Licensed Customer
Posts: 917
Joined: Fri May 26, 2017 2:00 pm
Location: Washington DC

ofirgardy wrote:I can see you've started with a specular material.

then plugged what? the Blur.OSL into the Albedo? or is it another type of OSL there?
Then second is the Checkers? or is the Second one titled "Image Texture" is that the Blur.OSL?

the last one - the delayed Projection - this one is straight forward
It's
Projection Node (OSL Delayed UV) >>
Image Texture Node (just a standard UV check grid image) >>
Gaussian Blur OSL Node>>
Gloss Material (Diffuse channel)

This is the GaussianBlur.osl that currently ships with Octane C4D:

Code: Select all

#include <octane-oslintrin.h>

#define MAX_ITERATIONS  10
#define MAX_KERNEL_SIZE 11 // MAX_ITERATIONS + 1

// OSL sample implementation of gaussian blur for Octane Render
shader GaussianBlur(
    color in = 0
        [[string label = "Input texture"]],
    int iterations = 5
        [[int min = 0, int max = MAX_ITERATIONS,
          string label = "Step count",
          string description = "Number of steps"]],
    float stepSize = 0.001
        [[float min = 0.00001, float max = 0.01,
          string label = "Step size",
          string description = "UV distance between steps"]],
    output color out = 0)
{
    if (iterations == 0)
    {
        // just return the input with the right UV mapping
        out =  _evaluateDelayed(in, u, v);
    }
    else
    {
        float kernel[MAX_KERNEL_SIZE];

        // initialize the kernel
        float normFactor = 0;
        for (int i = 0; i <= iterations; ++i)
        {
            // use normal probability density function with sigma = 7
            float n  = 0.05699175 * exp(-0.01020408 * i * i);
            normFactor += i == 0 ? n : 2*n;
            kernel[i] = n;
        }

        // average the neighbours
        color c  = 0;
        for (int i = -iterations; i <= iterations; ++i)
        {
            float n = kernel[iterations - abs(i)];
            for (int j = -iterations; j <= iterations; ++j)
            {
                float f = n * kernel[iterations - abs(j)];
                c += f * _evaluateDelayed(in, u + i * stepSize, v + j * stepSize);
            }
        }

        // calculate the final value
        out = c/(normFactor*normFactor);
    }
}
Last edited by frankmci on Thu Mar 21, 2024 5:48 pm, edited 1 time in total.
Animation Technical Director - Washington DC
ofirgardy
Licensed Customer
Posts: 14
Joined: Wed Feb 05, 2020 12:17 pm

Oh... so it's a different type of bluring OSL, different than the one on the yt video. Yes?
Since that "blur.osl" doesn't have an in-connection for hooking an rgb texture (at least not in the manifestation of it on 3dsmax).

I'll search for another OSL solution.
Post Reply

Return to “Maxon Cinema 4D”