[Bf-blender-cvs] [ed1aba4] cycles-ptex-19: WIP GPU stuff
Nicholas Bishop
noreply at git.blender.org
Wed Jan 28 19:40:24 CET 2015
Commit: ed1aba4960d51843ba451fe459bd55024ef5798a
Author: Nicholas Bishop
Date: Mon Jan 19 20:03:59 2015 +0100
Branches: cycles-ptex-19
https://developer.blender.org/rBed1aba4960d51843ba451fe459bd55024ef5798a
WIP GPU stuff
===================================================================
M source/blender/gpu/shaders/gpu_shader_material.glsl
===================================================================
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index a79bb23..781b043 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -2369,13 +2369,15 @@ void node_geometry(vec3 I, vec3 N, mat4 toworld,
}
void node_tex_coord(vec3 I, vec3 N, mat4 viewinvmat, mat4 obinvmat,
- vec3 attr_orco, vec3 attr_uv,
+ vec3 attr_orco, vec3 attr_uv, vec3 attr_ptex,
out vec3 generated, out vec3 normal, out vec3 uv, out vec3 object,
- out vec3 camera, out vec3 window, out vec3 reflection)
+ out vec3 camera, out vec3 window, out vec3 reflection,
+ out vec3 ptex)
{
generated = attr_orco * 0.5 + vec3(0.5);
normal = normalize((obinvmat*(viewinvmat*vec4(N, 0.0))).xyz);
uv = attr_uv;
+ ptex = attr_ptex;
object = (obinvmat*(viewinvmat*vec4(I, 1.0))).xyz;
camera = vec3(I.xy, -I.z);
vec4 projvec = gl_ProjectionMatrix * vec4(I, 1.0);
@@ -2467,9 +2469,23 @@ void node_tex_environment_empty(vec3 co, out vec4 color)
color = vec4(1.0, 0.0, 1.0, 1.0);
}
-void node_tex_image(vec3 co, sampler2D ima, out vec4 color, out float alpha)
+void node_tex_image(vec3 co, sampler2D ima, sampler2D ptex_map, out vec4 color, out float alpha)
{
- color = texture2D(ima, co.xy);
+ //color = texture2D(ima, co.xy);
+
+ // TODO :)
+ color = vec4(0, 0, 0, 1);
+ ivec2 offset = ivec2(int(co.z + 0.5), 0);
+ vec4 pm = texelFetch(ptex_map, offset, 0);
+ vec2 rect_xy = pm.xy;
+ vec2 rect_wh = pm.zw;
+
+ vec2 tex_size = vec2(textureSize(ima, 0));
+
+ vec2 uv = (co.xy * rect_wh + rect_xy) / tex_size;
+
+ color = texture2D(ima, uv);
+
alpha = color.a;
}
More information about the Bf-blender-cvs
mailing list