2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdosl.h"
|
|
|
|
|
|
|
|
shader node_texture_coordinate(
|
2012-10-20 15:09:36 +00:00
|
|
|
normal NormalIn = N,
|
2011-04-27 11:58:34 +00:00
|
|
|
int is_background = 0,
|
2013-12-31 16:33:55 +00:00
|
|
|
int is_volume = 0,
|
2012-10-20 15:09:36 +00:00
|
|
|
int from_dupli = 0,
|
2011-04-27 11:58:34 +00:00
|
|
|
string bump_offset = "center",
|
|
|
|
|
|
|
|
output point Generated = point(0.0, 0.0, 0.0),
|
|
|
|
output point UV = point(0.0, 0.0, 0.0),
|
|
|
|
output point Object = point(0.0, 0.0, 0.0),
|
|
|
|
output point Camera = point(0.0, 0.0, 0.0),
|
|
|
|
output point Window = point(0.0, 0.0, 0.0),
|
2012-10-20 15:09:36 +00:00
|
|
|
output normal Normal = normal(0.0, 0.0, 0.0),
|
2011-04-27 11:58:34 +00:00
|
|
|
output point Reflection = point(0.0, 0.0, 0.0))
|
|
|
|
{
|
2012-10-17 01:47:37 +00:00
|
|
|
if (is_background) {
|
2011-04-27 11:58:34 +00:00
|
|
|
Generated = P;
|
|
|
|
UV = point(0.0, 0.0, 0.0);
|
|
|
|
Object = P;
|
|
|
|
point Pcam = transform("camera", "world", point(0, 0, 0));
|
|
|
|
Camera = transform("camera", P + Pcam);
|
2013-06-08 10:51:33 +00:00
|
|
|
getattribute("NDC", Window);
|
2012-10-20 15:09:36 +00:00
|
|
|
Normal = NormalIn;
|
2011-04-27 11:58:34 +00:00
|
|
|
Reflection = I;
|
|
|
|
}
|
|
|
|
else {
|
2012-10-20 15:09:36 +00:00
|
|
|
if (from_dupli) {
|
2012-11-03 14:32:13 +00:00
|
|
|
getattribute("geom:dupli_generated", Generated);
|
|
|
|
getattribute("geom:dupli_uv", UV);
|
2012-10-20 15:09:36 +00:00
|
|
|
}
|
2014-01-06 02:52:27 +00:00
|
|
|
else if (is_volume) {
|
2013-12-31 16:33:55 +00:00
|
|
|
Generated = transform("object", P);
|
|
|
|
|
|
|
|
matrix tfm;
|
2014-01-06 02:52:27 +00:00
|
|
|
if (getattribute("geom:generated_transform", tfm))
|
2013-12-31 16:33:55 +00:00
|
|
|
Generated = transform(tfm, Generated);
|
|
|
|
|
|
|
|
getattribute("geom:uv", UV);
|
|
|
|
}
|
2012-10-20 15:09:36 +00:00
|
|
|
else {
|
2012-11-03 14:32:13 +00:00
|
|
|
getattribute("geom:generated", Generated);
|
|
|
|
getattribute("geom:uv", UV);
|
2012-10-20 15:09:36 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Object = transform("object", P);
|
|
|
|
Camera = transform("camera", P);
|
|
|
|
Window = transform("NDC", P);
|
2012-10-20 15:09:36 +00:00
|
|
|
Normal = transform("world", "object", NormalIn);
|
2012-11-22 22:24:34 +00:00
|
|
|
Reflection = -reflect(I, NormalIn);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2012-10-17 01:47:37 +00:00
|
|
|
if (bump_offset == "dx") {
|
2012-10-20 15:09:36 +00:00
|
|
|
if (!from_dupli) {
|
|
|
|
Generated += Dx(Generated);
|
|
|
|
UV += Dx(UV);
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
Object += Dx(Object);
|
|
|
|
Camera += Dx(Camera);
|
|
|
|
Window += Dx(Window);
|
|
|
|
}
|
2012-10-17 01:47:37 +00:00
|
|
|
else if (bump_offset == "dy") {
|
2012-10-20 15:09:36 +00:00
|
|
|
if (!from_dupli) {
|
|
|
|
Generated += Dy(Generated);
|
|
|
|
UV += Dy(UV);
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
Object += Dy(Object);
|
|
|
|
Camera += Dy(Camera);
|
|
|
|
Window += Dy(Window);
|
|
|
|
}
|
2012-11-21 13:00:57 +00:00
|
|
|
|
|
|
|
Window[2] = 0.0;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|