Hi Luther,
if you are using c4doctane, please have a look at this Xpresso example, where you can change the reference Camera:
viewtopic.php?f=87&t=63808
ciao Beppe
OSL camera projection node
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.
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.
I am using Octane for Blender and I am trying to solve the following problem:
In Blender I need a backplate image (a jpg, not an environment image) in the Octane preview in the viewport to exactly match the Blender render border while in active camera view (numpad 0). In Blender Cycles you can simply do this by using window coordinates from the the texture coordinate node, using those to display an image in the world nodes (so without any object). But in Octane I could not find any other way to do that then using OSL. I adapted the example script from the beginning of the thread a little and came up with the following:
shader CameraMap_env(
output point uvw = 0)
{
vector p = transform("camera", I);
float fov[2];
int res[2];
getattribute("camera:fov", fov);
getattribute("camera:resolution", res);
uvw[0] = 0.5 + 0.5 * p[0] / p[2] / tan(fov[1] / 2) * 2160 / 3840;
uvw[1] = 0.5 - 0.5 * p[1] / p[2] / tan(fov[1] / 2) ;
}
This gets the aspect correct for a 4k image (due to the 2160/3840 value) disregarding the aspect of the viewport. However, this backplate setup does not zoom in/out when manually zooming in/out in the viewport. What would need to be changed/added in the OSL script to make this work? Or is there a simpler way to get a backplate in the world/environment nodes in Octane?
In Blender I need a backplate image (a jpg, not an environment image) in the Octane preview in the viewport to exactly match the Blender render border while in active camera view (numpad 0). In Blender Cycles you can simply do this by using window coordinates from the the texture coordinate node, using those to display an image in the world nodes (so without any object). But in Octane I could not find any other way to do that then using OSL. I adapted the example script from the beginning of the thread a little and came up with the following:
shader CameraMap_env(
output point uvw = 0)
{
vector p = transform("camera", I);
float fov[2];
int res[2];
getattribute("camera:fov", fov);
getattribute("camera:resolution", res);
uvw[0] = 0.5 + 0.5 * p[0] / p[2] / tan(fov[1] / 2) * 2160 / 3840;
uvw[1] = 0.5 - 0.5 * p[1] / p[2] / tan(fov[1] / 2) ;
}
This gets the aspect correct for a 4k image (due to the 2160/3840 value) disregarding the aspect of the viewport. However, this backplate setup does not zoom in/out when manually zooming in/out in the viewport. What would need to be changed/added in the OSL script to make this work? Or is there a simpler way to get a backplate in the world/environment nodes in Octane?
Only a couple of hours after my post above I finally found the proper solution for a flat backplate image in Blender Octane:
There is the Camera node (below Input in the Add menu). The Camera node has an "Octane Front Projection" output which when connected to the projection input of an image node does exactly what I was looking for in the World nodes.
A very simple and effective solution, but quite hard to find on the web unfortunately.
There is the Camera node (below Input in the Add menu). The Camera node has an "Octane Front Projection" output which when connected to the projection input of an image node does exactly what I was looking for in the World nodes.
A very simple and effective solution, but quite hard to find on the web unfortunately.
Hi You guys - thanks for this script.
I used it in the OSL Projection node in Blender. It works but I get odd results. Any help? I have a camera called 'Camera.001' so I changed that in the script. It projects, but i not aligned correctly.
Thanks in advance!
My Node:
Results:
I used it in the OSL Projection node in Blender. It works but I get odd results. Any help? I have a camera called 'Camera.001' so I changed that in the script. It projects, but i not aligned correctly.
Thanks in advance!
My Node:
Code: Select all
shader CameraMap_geo(
output point uvw = 0)
{
vector p = transform("Camera.001", P);
float fov;
int res[2];
getattribute("camera:fov", fov);
getattribute("camera:resolution", res);
uvw[0] = .5 - .5 * p[0] / p[2] / tan(fov / 2) ;
uvw[1] = .5 - .5 * p[1] / p[2] / tan(fov / 2) * res[0] / res[1];
}
Hey all - really hoping for some help here.
I'm using Octane for Blender, and I am unable to get this to work.
Am I correct in assuming this first method is to project textures onto geometry? An that the textures projected will be fixed to that geometry at render time?
I'm using Octane for Blender, and I am unable to get this to work.
Am I correct in assuming this first method is to project textures onto geometry? An that the textures projected will be fixed to that geometry at render time?
Code: Select all
shader CameraMap_geo(
output point uvw = 0)
{
vector p = transform("Camera.001", 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];
}