OSL Texture and Projection Question

Forums: OSL Texture and Projection Question
Generic forum to discuss Octane Render, post ideas and suggest improvements.
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

OSL Texture and Projection Question

Postby Renart » Thu May 03, 2018 5:09 am

Renart Thu May 03, 2018 5:09 am
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!
Renart
Licensed Customer
Licensed Customer
 
Posts: 70
Joined: Mon Jul 04, 2016 8:21 pm

Re: OSL Texture and Projection Question

Postby bepeg4d » Thu May 03, 2018 10:21 am

bepeg4d Thu May 03, 2018 10:21 am
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&hilit=osl+perspective#p331877
ciao Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 9951
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: OSL Texture and Projection Question

Postby Renart » Fri May 04, 2018 5:24 am

Renart Fri May 04, 2018 5:24 am
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.

Code: Select all
point Vector = P [[string label = "Projection",string inputType = "projection:perspective"]],

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 ^^
Renart
Licensed Customer
Licensed Customer
 
Posts: 70
Joined: Mon Jul 04, 2016 8:21 pm

Re: OSL Texture and Projection Question

Postby bepeg4d » Fri May 04, 2018 4:15 pm

bepeg4d Fri May 04, 2018 4:15 pm
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:
cameraProjMoveOSL.osl.zip
(972 Bytes) Downloaded 162 times

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);
}


ciao Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 9951
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Re: OSL Texture and Projection Question

Postby Renart » Mon May 07, 2018 9:50 pm

Renart Mon May 07, 2018 9:50 pm
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!
Renart
Licensed Customer
Licensed Customer
 
Posts: 70
Joined: Mon Jul 04, 2016 8:21 pm

Return to General Discussion


Who is online

Users browsing this forum: No registered users and 14 guests

Tue Apr 16, 2024 8:12 am [ UTC ]
cron