Blender Internal: Revert own previous commit for "Camera Data" node, correct GLSL code for view vector output of "Geometry" node.

Revert 0c7d2de382. The "Camera Data" node actually gives the location
of the point in camera coordinate system.  To obtain actual camera data,
we can use "Geometry" node instead.

Also modify the "Geometry" node, to produce correct view vector output
in orthographic GLSL preview.
This commit is contained in:
2013-11-25 02:19:14 +09:00
parent 61a28ef764
commit 178bd849bf
2 changed files with 4 additions and 4 deletions

View File

@@ -140,7 +140,7 @@ void uv_attribute(vec2 attuv, out vec3 uv)
void geom(vec3 co, vec3 nor, mat4 viewinvmat, vec3 attorco, vec2 attuv, vec4 attvcol, out vec3 global, out vec3 local, out vec3 view, out vec3 orco, out vec3 uv, out vec3 normal, out vec4 vcol, out float vcol_alpha, out float frontback)
{
local = co;
view = normalize(local);
view = (gl_ProjectionMatrix[3][3] == 0.0)? normalize(local): vec3(0.0, 0.0, -1.0);
global = (viewinvmat*vec4(local, 1.0)).xyz;
orco = attorco;
uv_attribute(attuv, uv);
@@ -163,7 +163,7 @@ void camera(vec3 co, out vec3 outview, out float outdepth, out float outdist)
{
outdepth = abs(co.z);
outdist = length(co);
outview = (gl_ProjectionMatrix[3][3] == 0.0)? normalize(co): vec3(0.0, 0.0, -1.0);
outview = normalize(co);
}
void math_add(float val1, float val2, out float outval)

View File

@@ -46,9 +46,9 @@ static void node_shader_exec_camera(void *data, int UNUSED(thread), bNode *UNUSE
if (data) {
ShadeInput *shi = ((ShaderCallData *)data)->shi; /* Data we need for shading. */
copy_v3_v3(out[0]->vec, shi->view); /* get view vector */
copy_v3_v3(out[0]->vec, shi->co); /* get view vector */
out[1]->vec[0] = fabs(shi->co[2]); /* get view z-depth */
out[2]->vec[0] = len_v3(shi->co); /* get view distance */
out[2]->vec[0] = normalize_v3(out[0]->vec); /* get view distance */
}
}