OSL-data from image texture (mac) [SOLVED]


(poromaa) #1

[ATTACH=CONFIG]465404[/ATTACH]

Having read this thread:


There is an example how to store data within an image to use for an OSL-shader here:

However, I can’t get this example to work. In my example the box is black no matter what output Im using. Im using a mac so I think something is wrong with how the path to the texture is given. I have tried absolute path to the file with no success. Using blender 2.7.8

Has anyone on a mac succeeded to load image-data into an osl-shader? E.g getting a red cube in the example above. If so, could someone share the blend or just direct me into the setting of the example above to work?

Cheers


(poromaa) #2

Ok. I have pulled my hair over this the last 12 hours and it seems that no path-functionality works.
Have tried this simple script:

shader imageReadColorOut(
   string FileName = "f.png",
    output color Color = 0)
{ 
    color outColor =0;
    float index = 0;
    int pixelWidth = 5;
    float uu = 1;
    float vv = 1;
    index = 2;
    uu = index/pixelWidth;

    Color = texture(FileName, uu, vv,"interp","closest");
}

Whatever I do i get a pink color (like when the image is not found). Is there anyway to debug osl-scripts? the file f.png is located in the same folder as the blend-file. I have tried the function in both windows and MacOs without success.

To use textures as input to osl open up a lot of semi-procedural maps whereas the granularity in the texture can be extended with some noise and procedural patterns.


(poromaa) #3

Ok. solved it. On a mac you have to use absolute path, also you have to give the path on the node. It won’t take the default value.

shader dataTestShader(   string FileName = "",
    output color Color = 0,
    int idx =0)
{   
    
    color outColor =0;
    float index = 0;
    int pixelWidth = 5;
    float uu = 1;
    float vv = 1;
    
    
    index = (idx % 5 )+ 1;
    uu = index/pixelWidth;


     //printf("%s" , FileName );
    outColor= texture(FileName, uu, vv,"interp","closest");
    
    Color = outColor;
    // example 2. Index the 2nd pixel in the 5 x 1 pixel image. This pixel has the RGB value (1,1,1). W    
}