Announcement

Collapse
No announcement yet.

Could not compile OSL

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could not compile OSL

    Hi, I was attempting to implement Zap's halftone OSL texture in vray using VrayOSLTex map. It fails to compile due to a a line that attempts to smoothstep give 2 floats and a color. The spec clearly allows for this:

    type smoothstep (type edge0, type edge1, type x)
    Returns 0 if x ≤ edge0, and 1 if x ≥ edge1, and performs a smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1. This is useful in cases where you would want a thresholding function with a smooth transition. The type may be any of of float, color, point, vector, or normal. For color and point-like types, the computations are performed component-by-component.
    and it obviously works in arnold. Is this not supported in Vray?

    Code:
    // A simple Halftone shader
    // Halftone.osl, by Zap Andersson
    // Modified: 2018-06-28
    // Copyright 2018 Autodesk Inc, All rights reserved. This file is licensed under Apache 2.0 license
    //    https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/LICENSE.txt
    
    shader HalftoneDots
        [[ string help="Halftone Dots (by default i screen space)<br>"
                       "Works well together with toon shaders.",
           string label = "Halftone Dots" ]] 
    (
        // Inputs
        vector UVW   = transform("raster", P)
            [[ string help = "The input coordinate. If not connected, uses screen pixel space" ]],
        vector Scale = vector(8.0,8.0,8.0)
            [[ string help = "This size of the dots. In the default screen space mapping, this is in pixels." ]],
        float  Angle = 45.0
            [[ string help = "Angle of the Halftoning" ]],    
        color  InputValue = 0.25
            [[ string help = "The input value defining the size of the dots to yield the right halftone density. " ]],    
        int  U_Input = 0
            [[ string help = "If checked, adds the U coordinate as the input value. This works "
                             "well when connected in a 'base_tonemap' input of an Arnold Toon shader.",
               string widget = "checkBox" ]],        
        float  Fuzz = 0.1 [[ float min = 0.0, float max = 2.0 ]],
        color  BlackDots = 0.0
            [[ string help = "The color of the dots" ]],        
        color  WhiteDots = 1.0
            [[ string help = "The color of the space between the dots" ]],        
        // Outputs
        output color Out = 0.0
    )
    {
        vector pos = rotate(UVW, radians(Angle), 0.0, vector(0.0,0.0,1.0));
        pos = vector(pos[0] / Scale[0], pos[1] / Scale[1], 0.0);
        if (Scale[0] == 0.0)
            pos[0] = 0.5;
        if (Scale[1] == 0.0)
            pos[1] = 0.5;
    
        color inputV = InputValue;
    
        if (U_Input)
            inputV += u;    
    
        pos = pos - floor(pos);
    
        float dist = 1.0 - (distance(vector(0.5,0.5,0.0), pos) / (sqrt(2.0) / 2.5));    
        color factor = smoothstep(-Fuzz, 0.0, inputV - sqrt(max(0,dist)));
    
        Out = mix(BlackDots, WhiteDots, factor);
    }

  • #2
    Well.. this is included 3dsMax.... why would u need to re-implement?

    Comment


    • #3
      Originally posted by gandhics View Post
      Well.. this is included 3dsMax.... why would u need to re-implement?
      I'm using a version of 3ds Max before OSL was integrated.

      Comment

      Working...
      X