A bit of a code cleanup in GLSL shader

This commit is contained in:
Sergey Sharybin 2014-09-02 15:58:38 +06:00
parent ac1ddb6e64
commit d4fe34b1c0
1 changed files with 9 additions and 4 deletions

View File

@ -1211,7 +1211,12 @@ void mtex_mapping_size(vec3 texco, vec3 size, out vec3 outtexco)
void mtex_2d_mapping(vec3 vec, out vec3 outvec)
{
outvec = vec3(vec.xy*0.5 + vec2(0.5, 0.5), vec.z);
outvec = vec3(vec.xy*0.5 + vec2(0.5), vec.z);
}
vec3 mtex_2d_mapping(vec3 vec)
{
return vec3(vec.xy*0.5 + vec2(0.5), vec.z);
}
void mtex_image(vec3 texco, sampler2D ima, out float value, out vec4 color)
@ -2317,13 +2322,13 @@ void node_tex_coord(vec3 I, vec3 N, mat4 viewinvmat, mat4 obinvmat,
out vec3 generated, out vec3 normal, out vec3 uv, out vec3 object,
out vec3 camera, out vec3 window, out vec3 reflection)
{
generated = attr_orco * 0.5 + vec3(0.5);
generated = mtex_2d_mapping(attr_orco);
normal = normalize((obinvmat*(viewinvmat*vec4(N, 0.0))).xyz);
uv = attr_uv;
object = (obinvmat*(viewinvmat*vec4(I, 1.0))).xyz;
camera = I;
vec4 projvec = gl_ProjectionMatrix * vec4(I, 1.0);
window = (projvec.xyz/projvec.w)*0.5 + vec3(0.5);
vec4 projvec = gl_ProjectionMatrix * vec4(I, 1.0);
window = mtex_2d_mapping(projvec.xyz/projvec.w);
vec3 shade_I;
shade_view(I, shade_I);