Announcement

Collapse
No announcement yet.

distance based gradient OSL

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

  • distance based gradient OSL

    Hi,
    i want to assign black/white color to poly object based on distance from locator as below reference .

    See this
    https://vimeo.com/115913571

    Here is my test code, tell me whts wrong in code ??
    Code:
    surface 
    rbDepth_material
        [[ string description = "RB Depth Material" ]]
    (
    	point loc = point(0.0, 0.0, 0.0),
    	float min = 0.0,
    	float max = 3.0
    )
    
    {
    	color diffuseColor = linearstep(min, max, distance(loc, P));
    	Ci = diffuseColor;
    }

  • #2
    Your version contained multiple errors, below you can find a version that compiles and renders something.
    Code:
    surface 
    rbDepth_material
        [[ string description = "RB Depth Material" ]]
    (
    	point loc = point(0.0, 0.0, 0.0),
    	float minParam = 0.0,
    	float maxParam = 3.0
    )
    
    {
    	float mult = mix(minParam, maxParam, distance(loc, P));
    	Ci = mult * vray_light(1, 1); // vray_light can be replaced with emission()*M_PI
    }
    List of errors:
    1. min/max are functions, so they cannot be used as parameters
    2. converting float to color is not implicit
    3. Ci is a closure, so you must assign a closure (vray_light or emission)
    4. linearstep is not available in OSL 1.3
    5. Probably this is better written as a texture shader that you can plugin in VRayMtlLight

    You'll have to edit the math to match you're requirements.
    Also make sure to download the OSL spec version 1.3.3. Using the latest spec will cause only confusion and frustration.
    Check this page https://docs.chaosgroup.com/display/...AX/OSL+Support for details about supported features in V-Ray.
    V-Ray developer

    Comment

    Working...
    X