OSL camera projection node

Forums: OSL camera projection node
Post, discuss and share handy resources like textures, models and HDRI maps in this forum.
Forum rules
Please do not post any material that is copyrighted or restricted from public use in any way. OTOY NZ LTD and it's forum members are not liable for any copyright infringements on material in this forum. Please contact us if this is the case and we will remove the material in question.

OSL camera projection node

Postby calus » Mon Feb 26, 2018 11:58 am

calus Mon Feb 26, 2018 11:58 am
Here are 2 OSL projection shaders useful for camera mapping :

- the first one project texture from camera to geometry.

- the second one project from camera to environment.


cameraProj.orbx
(251.39 KiB) Downloaded 103 times



cameraMap_geometry.osl
Code: Select all
shader CameraMap_geo(
    output point uvw = 0)
{
    vector p = transform("camera", P);
    float fov;
    int res[2];
    getattribute("camera:fov", fov);
    getattribute("camera:resolution", res);
    uvw[0] = 0.5 - 0.5 * p[0] / p[2] / tan(fov / 2) ;
    uvw[1] = 0.5 - 0.5 * p[1] / p[2] / tan(fov / 2) * res[0] / res[1];
}


cameraMap_environment.osl
Code: Select all
shader CameraMap_env(
    output point uvw = 0)
{
    vector p = transform("camera", I);
    float fov;
    int res[2];
    getattribute("camera:fov", fov);
    getattribute("camera:resolution", res);
    uvw[0] = 0.5 + 0.5 * p[0] / p[2] / tan(fov / 2) ;
    uvw[1] = 0.5 - 0.5 * p[1] / p[2] / tan(fov / 2) * res[0] / res[1];
}
Last edited by calus on Sun Nov 25, 2018 5:05 pm, edited 1 time in total.
Pascal ANDRE
--------------------
Maya 2019, Windows 7, 128 GB RAM
4x GTX 1070, driver 430.39
--------------------

--------------------
Join MAYA OCTANE USERS Skype discussion here :
https://join.skype.com/LXEQaqqfN15w
--------------------
calus
Licensed Customer
Licensed Customer
 
Posts: 1293
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: OSL camera projection node

Postby paride4331 » Mon Feb 26, 2018 12:46 pm

paride4331 Mon Feb 26, 2018 12:46 pm
Hi calus,
very cool, thanks!
Paride
Gabriele
Win 7 / i7 5930 - 32gb / 1 x quadro K620 / 2 x Evga Titan X Hybrid
User avatar
paride4331
Octane Guru
Octane Guru
 
Posts: 2441
Joined: Fri Sep 18, 2015 7:19 am

Re: OSL camera projection node

Postby calus » Sun Nov 25, 2018 5:08 pm

calus Sun Nov 25, 2018 5:08 pm
There was a mistake in previous shader version, I have updated the first post with scripts that should work just fine in any case now :)
Pascal ANDRE
--------------------
Maya 2019, Windows 7, 128 GB RAM
4x GTX 1070, driver 430.39
--------------------

--------------------
Join MAYA OCTANE USERS Skype discussion here :
https://join.skype.com/LXEQaqqfN15w
--------------------
calus
Licensed Customer
Licensed Customer
 
Posts: 1293
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: OSL camera projection node

Postby J.C » Fri Feb 15, 2019 8:24 am

J.C Fri Feb 15, 2019 8:24 am
Great scripts! Thank you for sharing :)
CPU – i7 8700k 4.8Ghz + 64GB RAM, GPU – 2xGTX 980 Ti, 1xGTX 970
System – OS X 10.12.6, Windows 10, Octane 4/2018, Blender Plugin 16.x.x and 17.x
My Behance portfolio, Blender plugin FB support group
J.C
Licensed Customer
Licensed Customer
 
Posts: 823
Joined: Thu May 13, 2010 6:35 pm
Location: Wrocław

Re: OSL camera projection node

Postby whersmy » Sun Feb 17, 2019 2:54 pm

whersmy Sun Feb 17, 2019 2:54 pm
calus, can you post an example of when this script would come in handy?
mac pro g5| pentium g2030 iGPU| maximus extreme V| 2x gtx590 - 8gb - SSD - win7-x64- 1500W Silverstone|
x201t - gtx580 - egpu ec
Octane Render experiments
User avatar
whersmy
Licensed Customer
Licensed Customer
 
Posts: 560
Joined: Thu Aug 30, 2012 7:40 am

Re: OSL camera projection node

Postby calus » Sun Feb 17, 2019 6:24 pm

calus Sun Feb 17, 2019 6:24 pm
whersmy wrote:calus, can you post an example of when this script would come in handy?

There's an ORBX sample in the first post, you can see how to use the OSL projection shader for environment backplate or with geometry foreground objects.
Camera projection is typically useful for VFX when you need to integrate live footage and CG elements.

Standalone and some plugins don't have this feature builtin, and in it's not easy to setup with the perspective projection node,
so in this case this OSL projection shader can be handy .
Pascal ANDRE
--------------------
Maya 2019, Windows 7, 128 GB RAM
4x GTX 1070, driver 430.39
--------------------

--------------------
Join MAYA OCTANE USERS Skype discussion here :
https://join.skype.com/LXEQaqqfN15w
--------------------
calus
Licensed Customer
Licensed Customer
 
Posts: 1293
Joined: Sat May 22, 2010 9:31 am
Location: Paris

Re: OSL camera projection node

Postby Hugh69 » Sat Mar 02, 2019 4:56 pm

Hugh69 Sat Mar 02, 2019 4:56 pm
Hi, I'm relatively new to octane (a couple of weeks) and I'm trying to do a projection of an image onto geometry so i can make a photograph (of a car park) look like it has a slight camera move. The image in live view is slightly off to the geometry I've built to catch the projection of objects in the scene (buildings, wall, antennas). I tried googling for an answer but didn't find anything that would fix it.

I'm using C4D and the octane plugin, without knowing much about octane it seems like this post might fix my problem, but I'm not sure how to apply this OSL code to my scene. Would really appreciate a walk through.

*I downloaded the orbx file and it opened in the standalone renderer but I'm still getting to terms with using the C4D plugin, and its the first time I've opened up the standalone renderer so I feel like a fish on dry land right now!
Hugh69
 
Posts: 1
Joined: Tue Feb 19, 2019 8:02 pm

Re: OSL camera projection node

Postby bepeg4d » Mon Mar 04, 2019 7:17 am

bepeg4d Mon Mar 04, 2019 7:17 am
Hi Hugh69,
about c4doctane and osl. you can start to have a look at the manual here:
http://www.aoktar.com/octane/TEXTUREOSL1.html
Both calus’s scripts are already present in the osl Script preset popup menu.
ciao Beppe
User avatar
bepeg4d
Octane Guru
Octane Guru
 
Posts: 6485
Joined: Wed Jun 02, 2010 6:02 am
Location: Italy

Return to Resources and Sharing


Who is online

Users browsing this forum: No registered users and 7 guests

Thu Jun 27, 2019 6:14 am [ UTC ]