Hello!
I'm slowing trying to learn how to create OSL textures.
But one thing is not clear for me and I would like to have you help about that.
I'm trying to do a simple thing. display an image texture, using a perspective projection type.
I other things in mind after that but I want to start with something like this, and I'm already struggling.
I want to be able to plug an image texture to my OSL texture node. To be able to display my image, I need to set its Projection to OSL UV, but I want to force the OSL Texture node to display it with the Perspective mode.
And in the mean time, be able to control the value of the Perspective Projection.
I had a look at the documentation:
https://docs.otoy.com/osl/input%20types/
But I'm a bit confused about how to use the information gave here.
"To specify a default projection type for projection input, use "projection:<type>"."
I will be very grateful if someone can enlighten me about that!
OSL Texture and Projection Question
Forum rules
Please add your OS and Hardware Configuration in your signature, it makes it easier for us to help you analyze problems. Example: Win 7 64 | Geforce GTX680 | i7 3770 | 16GB
Please add your OS and Hardware Configuration in your signature, it makes it easier for us to help you analyze problems. Example: Win 7 64 | Geforce GTX680 | i7 3770 | 16GB
Hi Tenart,
please, have a look at this discussion about OSC Camera Projection node with examples, from Calus:
viewtopic.php?f=21&t=65575&p=331877&hil ... ve#p331877
ciao Beppe
please, have a look at this discussion about OSC Camera Projection node with examples, from Calus:
viewtopic.php?f=21&t=65575&p=331877&hil ... ve#p331877
ciao Beppe
Thank you Bege, it was very help to see how to manipulate the projection.
Another question would be, how to manipulate the value inside of a point, projection type of node.
For instance I'm using this line to declare my projection.
But I want to force it to have specific values ( in my case, I want to change the Translation values)
Sorry for my lack of knowledge and thanks for your help ^^
Another question would be, how to manipulate the value inside of a point, projection type of node.
Code: Select all
point Vector = P [[string label = "Projection",string inputType = "projection:perspective"]],But I want to force it to have specific values ( in my case, I want to change the Translation values)
Sorry for my lack of knowledge and thanks for your help ^^
Hi Renart,
since I don't know exactly what you want to obtain, I have modified the script from Calus, adding a Move X and Y input:
ciao Beppe
since I don't know exactly what you want to obtain, I have modified the script from Calus, adding a Move X and Y input:
Code: Select all
shader OslCameraProjectionMove(
float mx = 0 [[ string label = "Move X"]],
float my = 0 [[ string label = "Move Y"]],
output point uvw = 0)
{
float setRange( float f)
{
return 0.5 * (1.0 + f);
}
vector cameraProj(vector p)
{
float fov;
float pa;
float scale;
int res[2];
vector st;
getattribute("camera:fov", fov); //fov is already in radians
getattribute("camera:pixelaspect", pa);
getattribute("camera:resolution", res);
float ar = pa * res[1] / res[0];
scale = 2/tan(fov/2);
st[0] = setRange(p[0]/-p[2]*ar*scale)+mx;
st[1] = setRange(p[1]/-p[2]*scale)+my;
return st;
}
vector PP = transform("camera", P);
PP = vector(PP[0], PP[1], PP[2]);
uvw = cameraProj(PP);
}Grazie mile Beppe.
Not exactly what I was thinking tho. I was talking about in general, when I create a projection using OSL, how to change its transform values.
Like when I create an Integer or float input I can specify its default values and use them/access them, easily in my functions.
Is it related to the delayed evaluation?
Thanks for your help!
Not exactly what I was thinking tho. I was talking about in general, when I create a projection using OSL, how to change its transform values.
Like when I create an Integer or float input I can specify its default values and use them/access them, easily in my functions.
Is it related to the delayed evaluation?
Thanks for your help!

