OSL
Revision as of 17:23, 28 March 2024 by Bernie (talk | contribs) (Created page with "===Octane Cubemap=== Using octane + houdini. Wip this is just shit I stole from the octane forums to give me a start because OSL is a little confusing, and Houdini implementation even worse. <pre> shader OslCamera( float roomWidth = 1 float min = 0.0, float max = 100.0 , float roomHeight = 1.0 float min = 0.0, float max = 100.0 , float roomDepth = 1.0 float min = 0.0, float max = 100.0 , float ceilingOffset = 0, float...")
Octane Cubemap
Using octane + houdini.
Wip this is just shit I stole from the octane forums to give me a start because OSL is a little confusing, and Houdini implementation even worse.
shader OslCamera(
float roomWidth = 1 [[ float min = 0.0, float max = 100.0 ]],
float roomHeight = 1.0 [[ float min = 0.0, float max = 100.0 ]],
float roomDepth = 1.0 [[ float min = 0.0, float max = 100.0 ]],
float ceilingOffset = 0,
float leftOffset = 0.5,
float frontOffset = 0.5,
float rightOffset = 0.5,
float floorOffset = 0,
output point pos = P,
output vector dir = 0,
output float tMax = 1.0/0.0)
{
float pa;
int res[2];
float r = 8.0;
//float zoomFac = 4.0;
float col = floor(u*3);
float row = floor(v*3);
float nu = (u*3) - floor(u*3)-0.5;
float nv = (v*3) - floor(v*3)-0.5;
vector forward = vector(0,0,1);
vector up = vector(0,0,0);
vector right = vector(0,0,0);
float width = 1;
float height = 1;
vector pN = vector(0,0,0);
if(col==1 && row==2) {
//ceiling
forward = vector(0,1,0);
right = vector(roomWidth,0,0);
up = vector(0,0,roomDepth);
pN = vector(0,roomHeight-ceilingOffset,0);
}
if(col==0 && row==1) {
//left
forward = vector(-1,0,0);
up = vector(0,roomHeight,0);
right = vector (0,0,-roomDepth);
pN = vector(leftOffset-roomWidth/2,roomHeight/2,0);
}
if(col==1 && row==1) {
///forward
forward = vector(0,0,-1);
up = vector(0,roomHeight,0);
right = vector(roomWidth,0,0);
pN = vector(0,roomHeight/2,-(frontOffset-(roomDepth/2.0)));
}
if(col==2 && row==1) {
///right
forward = vector(1,0,0);
up = vector(0,roomHeight,0);
right = vector(0,0,roomDepth);
pN = vector(roomWidth/2-rightOffset,roomHeight/2,0);
}
if(col==1 && row==0) {
//floor
forward = vector(0,-1,0);
up = vector(0,0,-roomDepth);
right = vector(roomWidth,0,0);
pN = vector(0,floorOffset,0);
}
if(col==0 && row==2) {
//curtains
forward = vector(0,0,-1);
up = vector(0,roomHeight,0);
right = vector(roomWidth,0,0);
pN = vector(roomWidth*2.0,0.5,roomDepth);
}
if(col==0 && row==0) {
//curtains
forward = vector(0,0,-1);
up = vector(0,roomHeight,0);
right = vector(roomWidth,0,0);
pN = vector(roomWidth,0.5,roomDepth);
}
//getattribute("camera:pixelaspect", pa);
//getattribute("camera:resolution", res);
//float aspect = pa * res[1] / res[0] * n;
dir = forward;
pos = pN+(nu*right)+(nv*up);
}