Issues with OSL texture

Forums: Issues with OSL texture
Generic forum to discuss Octane Render, post ideas and suggest improvements.
Forum rules
Please add your OS and Hardware Configuration in your signature, it makes it easier for us to help you analyze problems. Example: Win 7 64 | Geforce GTX680 | i7 3770 | 16GB

Issues with OSL texture

Postby blackshore » Sun Oct 17, 2021 5:11 pm

blackshore Sun Oct 17, 2021 5:11 pm
Do anyone know how to get this OSL texture working with Octane:
https://github.com/cuckon/scratched/blo ... cratch.osl


I'm currently getting following error in maya+octane:
Code: Select all
// Error: Octane: Failed to compile OSL texture node:
error: No shader function defined
 //


System: win7 64bit
Maya: 2018
Octane:4.05
Maya plugin: 13.49


OSL shader:
Code: Select all
// Micro Scratched Texture
//
// Author: John Su <[email protected]>
//
// An OSL shader that generates texture to make swirly micro scratch look by
// controlling the anistropy and roughness.
// The original idea is from Hang Li(悬挂鲤) and Ben Paschke. Here I implemented
// it using OSL and exposured some arts friendly parameters.

#define DIVISION 40
#define DEBUG(_) Cf=_; return;


float line(point p, float direction, float width){
    float theta = direction * M_PI;
    float k = tan(theta);
    float distance = abs(k * p[0] - p[1])/sqrt(k * k + 1);
    return 1 - step(width*0.5, distance);
}


shader scratch(
   float density=0.1,
   float roughness_min=0.0,
   float roughness_max=0.01,
   float roughness_default = 0.1,
   float anisotropic_min = 0.1,
   float anisotropic_max = 0.2,
   float anisotropic_default = 0,
    float width=0.001,
    float offset=0.0,
    output color Cf = 0
){
    float delta = 1.0/(DIVISION - 1);
    float max_radius = sqrt(density);
    int max_search_cell = (int)ceil(max_radius/delta);
    point index = point(round(u/delta), round(v/delta), 0.0);
    point shading_p = point(u, v , 0.0);
    point current_index;

    point current_origin_p;
    float scratch = 0, direction=0;
    float roughness = roughness_default, anisotropic = anisotropic_default;
    for (int x = -max_search_cell; x <= max_search_cell; ++x){
        for (int y = -max_search_cell; y <= max_search_cell; ++y){
            current_index = index + point(x, y, 0);

            current_origin_p = (current_index + (hashnoise(current_index) - 0.5)) * delta;
            direction = hashnoise(current_index + vector(123, 456, 0));
            scratch = line(
               current_origin_p - shading_p,
               direction,
               width * hashnoise(current_index)
            );
            if (scratch)
            {
               roughness = roughness_default + mix(
                  roughness_min,
                  roughness_max,
                  hashnoise(current_index + vector(123, 456, 1))
               );
                anisotropic = anisotropic_default + mix(
                   anisotropic_min,
                   anisotropic_max,
                   hashnoise(current_index + vector(123, 456, 2))
                );
                break;
            }
        }
        if (scratch)
            break;
    }
   
    Cf = color(
       roughness,
       (direction * 0.5 + offset) * (scratch > 1e-4),
       anisotropic
    );
}
User avatar
blackshore
Licensed Customer
Licensed Customer
 
Posts: 117
Joined: Wed Jul 31, 2013 6:22 pm

Re: Issues with OSL texture

Postby bepeg4d » Mon Oct 18, 2021 7:18 am

bepeg4d Mon Oct 18, 2021 7:18 am
Hi,
sorry, not a Maya user, but your osl script is working correctly in both Standalone 2020.2.5, and 2021.1-RC3 here:
F51A7B65-C425-4354-9385-28A3548B0DE3.jpeg

8B832495-A38F-406B-A5DB-30A1AADF8134.jpeg


And also in Standalone 4.05:
CFE58D1B-E430-42B5-B02A-F6310447C88C.jpeg


Please post the issue in the related Maya discussion here:
viewtopic.php?f=109&t=74712

ciao
Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 9940
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: Issues with OSL texture

Postby blackshore » Tue Oct 19, 2021 4:05 pm

blackshore Tue Oct 19, 2021 4:05 pm
You are correct, not sure on why it works without any issues in standalone. I did not check that. Thanks, I will lay it to the maya forum
User avatar
blackshore
Licensed Customer
Licensed Customer
 
Posts: 117
Joined: Wed Jul 31, 2013 6:22 pm

Re: Issues with OSL texture

Postby jobigoud » Tue Oct 19, 2021 8:36 pm

jobigoud Tue Oct 19, 2021 8:36 pm
The shader compiles in standalone but it's currently not quite possible to reproduce exactly the effect seen in the project's repository, because the Anisotropy field on the Material node is a single float not a texture. The shader output needs to be split into three grayscale textures for roughness, anisotropy and anisotropy rotation, and defines different values for each depending on whether we are on a scratch or not. We can use Channel picker nodes to split the result but we can't connect the anisotropy.

This is scheduled to be addressed in Octane 2022.
User avatar
jobigoud
OctaneRender Team
OctaneRender Team
 
Posts: 230
Joined: Sat Aug 15, 2015 1:28 pm

Return to General Discussion


Who is online

Users browsing this forum: No registered users and 16 guests

Thu Mar 28, 2024 10:54 am [ UTC ]