Overview of OSL Shaders in Octane

Forums: Overview of OSL Shaders in Octane
A forum where development builds are posted for testing by the community.
Forum rules
NOTE: The software in this forum is not %100 reliable, they are development builds and are meant for testing by experienced octane users. If you are a new octane user, we recommend to use the current stable release from the 'Commercial Product News & Releases' forum.

Re: Overview of OSL Shaders in Octane

Postby funk » Tue Aug 28, 2018 7:45 am

funk Tue Aug 28, 2018 7:45 am
rohandalvi, I was looking into photoshop blend modes for OSL and found this:
https://blendersushi.blogspot.com/2013/ ... tions.html
Win10 Pro/ Ryzen 5950X / 128GB / RTX 4090 / MODO
"I am the resurrection, and the life: he that believeth in me, though he were dead, yet shall he live" - Jesus Christ
User avatar
funk
Licensed Customer
Licensed Customer
 
Posts: 1204
Joined: Mon Feb 07, 2011 1:24 pm
Location: Australia

Re: Overview of OSL Shaders in Octane

Postby roeland » Fri Sep 07, 2018 12:35 am

roeland Fri Sep 07, 2018 12:35 am
For this you can use the step function. step(a, b) is equivalent to a >= b but is calculated component-wise.

Code: Select all
    color lt = step(Target, 0.5);
    c = (1 - lt) * (1 - (1-2*(Target-0.5)) * (1-Blend)) + lt * ((2*Target) * Blend);
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1810
Joined: Wed Mar 09, 2011 10:09 pm

Re: Overview of OSL Shaders in Octane

Postby Notiusweb » Fri Sep 07, 2018 1:40 am

Notiusweb Fri Sep 07, 2018 1:40 am
Is it possible to blur a texture, or a shader 'result', with a float?
What might that look like, in Octane-OSL

(I do not mean 'blur' as in motion blur...I am referring to, say, a Gaussian blur, aka sharpness reduction...like in Photoshop)

Thank you.
Win 10 Pro 64, Xeon E5-2687W v2 (8x 3.40GHz), G.Skill 64 GB DDR3-2400, ASRock X79 Extreme 11
Mobo: 1 Titan RTX, 1 Titan Xp
External: 6 Titan X Pascal, 2 GTX Titan X
Plugs: Enterprise
User avatar
Notiusweb
Licensed Customer
Licensed Customer
 
Posts: 1285
Joined: Mon Nov 10, 2014 4:51 am

Re: Overview of OSL Shaders in Octane

Postby Rico_uk » Mon Sep 10, 2018 6:59 pm

Rico_uk Mon Sep 10, 2018 6:59 pm
Any developers we can pay to create a custom texture shader using OSL for Octane?
Rico_uk
Licensed Customer
Licensed Customer
 
Posts: 118
Joined: Mon Oct 24, 2011 6:42 pm

Re: Overview of OSL Shaders in Octane

Postby whersmy » Wed Sep 12, 2018 12:27 pm

whersmy Wed Sep 12, 2018 12:27 pm
roeland wrote:A basic shader for a laminate floor looks like this:

Code: Select all
#include <octane-oslintrin.h>

shader Laminate(
    color plank1 = .3,
    color plank2 = color(0, 0, 1),
    color plank3 = color(0, 1, 0),
    color plank4 = color(0, 1, 1),
    color plank5 = color(1, 0, 0),
    color plank6 = color(1, 0, 1),
    color plank7 = color(1, 1, 0),
    color plank8 = 1,
    color plank9 = .1,
    float plankAspect = 5 [[float min = .01, float max=100, float sliderexponent=3]],
    matrix Transform = .25,
    point Projection = point(u, v, 0) [[string inputType = "projection"]],
    output color c = 0)
{
    int AMOUNT = 9;
    // use the projection and transform inputs
    point p = transform(1/Transform, Projection);
    float y = p[1] * plankAspect;
    // random offset for each row
    float x = p[0] + noise("cell", y, 0);
    // random plank and orientation for each cell
    float rnd = noise("cell", x, y) * AMOUNT;
    int flip = (rnd - floor(rnd)) < .5;
    // make UV mapping per cell and evaluate the right texture
    float plU = x - floor(x);
    float plV = y - floor(y);
    if (flip)
    {
        plU = 1 - plU;
        plV = 1 - plV;
    }
    if      (rnd < 1) { c = _evaluateDelayed(plank1, plU, plV); }
    else if (rnd < 2) { c = _evaluateDelayed(plank2, plU, plV); }
    else if (rnd < 3) { c = _evaluateDelayed(plank3, plU, plV); }
    else if (rnd < 4) { c = _evaluateDelayed(plank4, plU, plV); }
    else if (rnd < 5) { c = _evaluateDelayed(plank5, plU, plV); }
    else if (rnd < 6) { c = _evaluateDelayed(plank6, plU, plV); }
    else if (rnd < 7) { c = _evaluateDelayed(plank7, plU, plV); }
    else if (rnd < 8) { c = _evaluateDelayed(plank8, plU, plV); }
    else              { c = _evaluateDelayed(plank9, plU, plV); }
}


How to use: the OSL texture node node will have 9 texture inputs named plank1 to plank9. Connect each to an image texture, and for the image textures set the projection to “OSL UV”.

-Roeland


Would love to get this working, but I get the following output:
Code: Select all
Script: [string "Script"]:1: unexpected symbol near '#'
Octane 2022.1.1 nv535.98
mac pro g5| pentium g2030 iGPU| maximus extreme V| 2x gtx590 - 8gb - SSD - win7-x64- 1500W Silverstone|
x201t - gtx580 - egpu ec
Dell G5 - 16GB - dgpu GTX1060 - TB3 egpu @ 1060 / RTX 4090

Octane Render experiments
User avatar
whersmy
Licensed Customer
Licensed Customer
 
Posts: 723
Joined: Thu Aug 30, 2012 7:40 am

Re: Overview of OSL Shaders in Octane

Postby Notiusweb » Fri Sep 14, 2018 12:22 am

Notiusweb Fri Sep 14, 2018 12:22 am
I am able to get it to work in V4_R3 (in this case I am projecting it as an emitter onto the floor. )
But Roeland's code seems good, the OSL-language compiler accepts it.

LaminateFloor.jpg
Win 10 Pro 64, Xeon E5-2687W v2 (8x 3.40GHz), G.Skill 64 GB DDR3-2400, ASRock X79 Extreme 11
Mobo: 1 Titan RTX, 1 Titan Xp
External: 6 Titan X Pascal, 2 GTX Titan X
Plugs: Enterprise
User avatar
Notiusweb
Licensed Customer
Licensed Customer
 
Posts: 1285
Joined: Mon Nov 10, 2014 4:51 am

Re: overview of OSL Shaders in Octane

Postby Notiusweb » Fri Sep 14, 2018 1:39 am

Notiusweb Fri Sep 14, 2018 1:39 am
This one just gives Compilation failed in Standalone V4_RC3


aoktar wrote:Doing some tests with codes from internet while improving the stuff.

simple deformation with osl_projection.
Code: Select all
shader OslProjection
(
     color dist=0,
    output point uvw = 0
    )
{
    uvw = 2*point(u, v, 0)+dist;
}




This one.... :evil:
This one leads to All GPU failed in Red.
It actually compiles fine per the OSL language compiler.
But whether I am using all 8 GPU, or just 1...they all go red! (V4_RC3)

aoktar wrote:Crazy parquet script
Code: Select all
shader DWParquetTile (

        float DiffuseAmt = 0.75 ,
        float SpecularAmt = 0.15,
        float Roughness = 0.025,
        color SpecularColor = color(1.0),
        float RingScale = 25.0,
        float GrainScale = 55.0,
        float Grainy = 1.0,
        float Wavy = 0.08,
        float TextureScale = 5.0,
        color LightWood = color (0.57, 0.292, 0.125),
        color DarkWood  = color (0.275, 0.15, 0.06),
        color GrooveColor  = color (0.05, 0.04, 0.015),
        int PlanksPerTile = 1,
        float PlankWidth = 0.2,
        float PlankVary = 0.6,
        float GrooveWidth = 0.1,
        output color BSDF = .5 )
{
#define snoise(x) (2 * noise((x)) - 1)
#define boxstep(a,b,x) (clamp(((x)-(a))/((b)-(a)),0,1))
#define MINFILTERWIDTH 1.0e-7

        vector Vector = P;
    float su = Vector[0];
    float tv = Vector[1];
    float r, r2;
    point Nf;
    float whichrow, whichplank;
    float swidth, twidth, fwidth, ss, tt, w, h, fade, ttt;
    color Ct, woodcolor;
    float groovy;
    float PGWIDTH, PGHEIGHT, GWF, GHF;
    float tilewidth, whichtile, tmp, planklength;

    PGWIDTH = PlankWidth+GrooveWidth;
    planklength = PGWIDTH * PlanksPerTile - GrooveWidth;
    PGHEIGHT = planklength+GrooveWidth;
    GWF = GrooveWidth*0.05/PGWIDTH;
    GHF = GrooveWidth*0.05/PGHEIGHT;

    /* Determine how wide in s-t space one pixel projects to */
    swidth = (max (abs(Dx(su)*su) + abs(Dy(su)*tv), MINFILTERWIDTH) / PGWIDTH) * TextureScale;
    twidth = (max (abs(Dx(tv)*su) + abs(Dy(tv)*tv), MINFILTERWIDTH) / PGHEIGHT) * TextureScale;
    fwidth = max(swidth,twidth);

    ss = (TextureScale * su) / PGWIDTH;
    whichrow = floor (ss);
    tt = (TextureScale * tv) / PGHEIGHT;
    whichplank = floor(tt);
    if (mod (whichrow/PlanksPerTile + whichplank, 2) >= 1) {
        ss = TextureScale * tv / PGWIDTH;
        whichrow = floor (ss);
        tt = TextureScale * su / PGHEIGHT;
        whichplank = floor(tt);
        tmp = swidth;  swidth = twidth;  twidth = tmp;
    }
    ss -= whichrow;
    tt -= whichplank;
    whichplank += 20*(whichrow+10);

    /*
     * Figure out where the grooves are.  The value groovy is 0 where there
     * are grooves, 1 where the wood grain is visible.  Do some simple
     * antialiasing.
     */
    if (swidth >= 1)
        w = 1 - 2*GWF;
    else {
        w = clamp (boxstep(GWF-swidth,GWF,ss), max(1-GWF/swidth,0), 1)
        - clamp (boxstep(1-GWF-swidth,1-GWF,ss), 0, 2*GWF/swidth);
    }
    if (twidth >= 1)
        h = 1 - 2*GHF;
    else {
        h = clamp (boxstep(GHF-twidth,GHF,tt), max(1-GHF/twidth,0),1)
        - clamp (boxstep(1-GHF-twidth,1-GHF,tt), 0, 2*GHF/twidth);
    }
    /* This would be the non-antialiased version:
     * w = step (GWF,ss) - step(1-GWF,ss);
     * h = step (GHF,tt) - step(1-GHF,tt);
     */
    groovy = w*h;


    /*
     * Add the ring patterns
     */
    fade = smoothstep (1/RingScale, 8/RingScale, fwidth);
    if (fade < 0.999) {
        ttt = tt/4+whichplank/28.38 + Wavy * noise (8*ss, tt/4);
        r = RingScale * noise (ss-whichplank, ttt);
        r -= floor (r);
        r = 0.3 + 0.7 * smoothstep(0.2, 0.55, r) * (1 - smoothstep(0.75, 0.8, r));
        r = (1-fade)*r + 0.65*fade;

        /*
         * Multiply the ring pattern by the fine grain
         */
        fade = smoothstep (2/GrainScale, 8/GrainScale, fwidth);
        if (fade < 0.999) {
            r2 = 1.3 - noise (ss*GrainScale, (tt*GrainScale/4));
            r2 = Grainy * r2*r2 + (1-Grainy);
            r *= (1-fade)*r2 + (0.75*fade);
        }
        else
            r *= 0.75;
    }
    else
        r = 0.4875;
 

    /* Mix the light and dark wood according to the grain pattern */
    woodcolor = mix (LightWood, DarkWood, r);

    /* Add plank-to-plank variation in overall color */
    woodcolor *= (1-PlankVary/2 + PlankVary * noise (whichplank+0.5));

    Ct = mix (GrooveColor, woodcolor, groovy);
    Nf = normalize(N);
BSDF =  Ct * DiffuseAmt;

   // BSDF = Ct * DiffuseAmt * diffuse(Nf);
  //  BSDF += SpecularColor * SpecularAmt;
}
Win 10 Pro 64, Xeon E5-2687W v2 (8x 3.40GHz), G.Skill 64 GB DDR3-2400, ASRock X79 Extreme 11
Mobo: 1 Titan RTX, 1 Titan Xp
External: 6 Titan X Pascal, 2 GTX Titan X
Plugs: Enterprise
User avatar
Notiusweb
Licensed Customer
Licensed Customer
 
Posts: 1285
Joined: Mon Nov 10, 2014 4:51 am

Re: Overview of OSL Shaders in Octane

Postby roeland » Tue Sep 18, 2018 12:10 am

roeland Tue Sep 18, 2018 12:10 am
`Dx` and `Dy` are not implemented yet in Octane. This is unfortunately not something we can easily add.
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1810
Joined: Wed Mar 09, 2011 10:09 pm

Re: Overview of OSL Shaders in Octane

Postby Rik » Mon Mar 11, 2019 7:42 pm

Rik Mon Mar 11, 2019 7:42 pm
Wow. So OSL really took off then?

Great work with all those samples.

FFS
Rik
Licensed Customer
Licensed Customer
 
Posts: 419
Joined: Wed Jul 28, 2010 8:57 pm

Re: Overview of OSL Shaders in Octane

Postby Goldorak » Fri Mar 29, 2019 7:36 am

Goldorak Fri Mar 29, 2019 7:36 am
Rik wrote:Wow. So OSL really took off then?

Great work with all those samples.

FFS


Universal camera among other 2019 features and new nodes is pure OSL. I promised you we’d bundle 100+ shaders in the 2019 release cycle, we’re doing that even if you don’t see the shader code (that’s the point - meant to be artist friendly).

I assume you’ve seen the OSL vector displacement and volume shading too in 2019.1?
User avatar
Goldorak
OctaneRender Team
OctaneRender Team
 
Posts: 2321
Joined: Sun Apr 22, 2012 8:09 pm
PreviousNext

Return to Development Build Releases


Who is online

Users browsing this forum: No registered users and 4 guests

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