0
$\begingroup$

Why this is happening!?

enter image description here

enter image description here

osl script:

shader TestNoise(
    vector vec = (0,0,0),

    output vector outV = (0,0,0)
){
    outV = (vec[0],vec[1],vec[2]);

}

In this case, it should not modify anything. It just passing the same value. Why is this happening?

I mean, if the public input vec is receiving the texture coordinate object vec = (x,y,z) and the outV = (vec[0],vec[ 1 ],vec[ 2 ]) is should vec = outV = (x,y,z) = (vec[ 0 ],vec[ 1 ],vec[ 2 ]), right? In this image, instead of a black and white stripe is should not be a default checker? I don't know, can someone explain to me?

$\endgroup$
  • 1
    $\begingroup$ Why is what happening? You didn't tell us what's wrong. $\endgroup$ – Linguini May 20 '18 at 2:29
0
$\begingroup$

You seem to have a mismatch in types in the assignment of the output variable - you need to include the 'vector' type in the assignment.

ie, instead of :

outV = (vec[0],vec[1],vec[2]);

Change it to :

outV = vector(vec[0],vec[1],vec[2]);

So the final script should be :

shader TestNoise(
    vector vec = (0,0,0),

    output vector outV = (0,0,0)
){
    outV = vector(vec[0],vec[1],vec[2]);

}
| improve this answer | |
$\endgroup$
  • $\begingroup$ why does this happen? $\endgroup$ – Yugo Harago May 20 '18 at 14:08
  • $\begingroup$ Without the ‘vector’ keyword you’re not casting it to a vector - it’s just a list of values - and it seems that it’s effectively just passing the last one (Z) back from the shader as a scalar. This means that your Texture is only being plotted in one dimension - so stripes in the Z direction. Technically I suppose it should be flagged as a syntax error at compile time but since vectors can be set to a scalar (so setting to 0.5 sets it to vector(0.5,0.5,0.5)) it compiles as falid but is actually discarding vec[0] and vec[1]. $\endgroup$ – Rich Sedman May 20 '18 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.