[Bf-blender-cvs] [f122e6d] cycles-ptex-24: Add Ptex shader node

Nicholas Bishop noreply at git.blender.org
Fri Jan 30 18:00:31 CET 2015


Commit: f122e6dd9dc6983d09cb091e415ae9d99cdda3de
Author: Nicholas Bishop
Date:   Tue Jan 20 18:42:02 2015 +0100
Branches: cycles-ptex-24
https://developer.blender.org/rBf122e6dd9dc6983d09cb091e415ae9d99cdda3de

Add Ptex shader node

===================================================================

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/DerivedMesh.c
M	source/blender/blenkernel/intern/node.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/gpu/GPU_extensions.h
M	source/blender/gpu/GPU_material.h
M	source/blender/gpu/intern/gpu_codegen.c
M	source/blender/gpu/intern/gpu_codegen.h
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_extensions.c
M	source/blender/gpu/intern/gpu_material.c
M	source/blender/gpu/shaders/gpu_shader_material.glsl
M	source/blender/makesdna/DNA_image_types.h
M	source/blender/makesdna/DNA_node_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_shader.h
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/shader/nodes/node_shader_tex_ptex.c

===================================================================

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 1590bd4..9ebfbd8 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -234,6 +234,7 @@ shader_node_categories = [
         NodeItem("ShaderNodeTexMagic"),
         NodeItem("ShaderNodeTexChecker"),
         NodeItem("ShaderNodeTexBrick"),
+        NodeItem("ShaderNodeTexPtex"),
         ]),
     ShaderNewNodeCategory("SH_NEW_OP_COLOR", "Color", items=[
         NodeItem("ShaderNodeMixRGB"),
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 573fa60..42b1753 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -755,6 +755,7 @@ struct ShadeResult;
 #define SH_NODE_COMBXYZ					189
 #define SH_NODE_OUTPUT_LINESTYLE		190
 #define SH_NODE_UVALONGSTROKE			191
+#define SH_NODE_TEX_PTEX                192
 
 /* custom defines options for Material node */
 #define SH_NODE_MAT_DIFF   1
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 849f871..e347f60 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -76,6 +76,9 @@ static DerivedMesh *navmesh_dm_createNavMeshForVisualization(DerivedMesh *dm);
 #include "GPU_extensions.h"
 #include "GPU_glew.h"
 
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
 /* very slow! enable for testing only! */
 //#define USE_MODIFIER_VALIDATE
 
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index f30e3b6..d8d13da 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -3568,6 +3568,7 @@ static void registerShaderNodes(void)
 	register_node_type_sh_tex_magic();
 	register_node_type_sh_tex_checker();
 	register_node_type_sh_tex_brick();
+	register_node_type_sh_tex_ptex();
 }
 
 static void registerTextureNodes(void)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 9daa693..3c6481a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1319,6 +1319,8 @@ void blo_make_image_pointer_map(FileData *fd, Main *oldmain)
 			oldnewmap_insert(fd->imamap, ima->cache, ima->cache, 0);
 		if (ima->gputexture)
 			oldnewmap_insert(fd->imamap, ima->gputexture, ima->gputexture, 0);
+		if (ima->ptex_gputexture)
+			oldnewmap_insert(fd->imamap, ima->ptex_gputexture, ima->ptex_gputexture, 0);
 		if (ima->rr)
 			oldnewmap_insert(fd->imamap, ima->rr, ima->rr, 0);
 		for (a=0; a < IMA_MAX_RENDER_SLOT; a++)
@@ -1357,12 +1359,14 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain)
 			ima->bindcode = 0;
 			ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
 			ima->gputexture = NULL;
+			ima->ptex_gputexture = NULL;
 			ima->rr = NULL;
 		}
 		for (i = 0; i < IMA_MAX_RENDER_SLOT; i++)
 			ima->renders[i] = newimaadr(fd, ima->renders[i]);
 		
 		ima->gputexture = newimaadr(fd, ima->gputexture);
+		ima->ptex_gputexture = newimaadr(fd, ima->ptex_gputexture);
 		ima->rr = newimaadr(fd, ima->rr);
 	}
 	for (; sce; sce = sce->id.next) {
@@ -3360,6 +3364,7 @@ static void direct_link_image(FileData *fd, Image *ima)
 		ima->bindcode = 0;
 		ima->tpageflag &= ~IMA_GLBIND_IS_DATA;
 		ima->gputexture = NULL;
+		ima->ptex_gputexture = NULL;
 		ima->rr = NULL;
 	}
 	
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index b5e7008..585d9fa 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -922,6 +922,16 @@ static void node_shader_buts_uvalongstroke(uiLayout *layout, bContext *UNUSED(C)
 	uiItemR(layout, ptr, "use_tips", 0, NULL, 0);
 }
 
+static void node_shader_buts_ptex(uiLayout *layout, bContext *C, PointerRNA *ptr)
+{
+	PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
+
+	if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
+		PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
+		uiItemPointerR(layout, ptr, "layer_name", &dataptr, "loop_ptex", "", ICON_NONE);
+	}
+}
+
 static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
 	uiItemR(layout, ptr, "space", 0, "", 0);
@@ -1166,6 +1176,9 @@ static void node_shader_set_butfunc(bNodeType *ntype)
 		case SH_NODE_OUTPUT_LINESTYLE:
 			ntype->draw_buttons = node_buts_output_linestyle;
 			break;
+		case SH_NODE_TEX_PTEX:
+			ntype->draw_buttons = node_shader_buts_ptex;
+			break;
 	}
 }
 
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index b810783..a8af5e3 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2830,7 +2830,7 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar, bool
 			GPUMaterial *gpumat = GPU_material_world(scene, scene->world);
 			
 			/* calculate full shader for background */
-			GPU_material_bind(gpumat, 1, 1, 1.0, false, rv3d->viewmat, rv3d->viewinv, (v3d->scenelock != 0));
+			GPU_material_bind(gpumat, 1, 1, 1.0, false, rv3d->viewmat, rv3d->viewinv, (v3d->scenelock != 0), NULL);
 			
 			glEnable(GL_DEPTH_TEST);
 			glDepthFunc(GL_ALWAYS);
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index bb0cf2d..262399d 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -112,6 +112,9 @@ GPUTexture *GPU_texture_create_2D(int w, int h, float *pixels, char err_out[256]
 GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, float *fpixels);
 GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256]);
 GPUTexture *GPU_texture_create_vsm_shadow_map(int size, char err_out[256]);
+	// TODO
+GPUTexture *GPU_ptex_texture_from_blender(struct Image *ima,
+	struct ImageUser *iuser);
 GPUTexture *GPU_texture_from_blender(struct Image *ima,
 	struct ImageUser *iuser, bool is_data, double time, int mipmap);
 GPUTexture *GPU_texture_from_preview(struct PreviewImage *prv, int mipmap);
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index eef07fd..bc71964 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -154,6 +154,7 @@ GPUNodeLink *GPU_attribute(CustomDataType type, const char *name);
 GPUNodeLink *GPU_uniform(float *num);
 GPUNodeLink *GPU_dynamic_uniform(float *num, GPUDynamicType dynamictype, void *data);
 GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, bool is_data);
+GPUNodeLink *GPU_ptex(int ptex);
 GPUNodeLink *GPU_image_preview(struct PreviewImage *prv);
 GPUNodeLink *GPU_texture(int size, float *pixels);
 GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex, GPUDynamicType dynamictype, void *data);
@@ -177,7 +178,9 @@ void GPU_material_free(struct ListBase *gpumaterial);
 void GPU_materials_free(void);
 
 bool GPU_lamp_override_visible(GPULamp *lamp, struct SceneRenderLayer *srl, struct Material *ma);
-void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4], bool scenelock);
+void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time, int mipmap, float viewmat[4][4], float viewinv[4][4], bool scenelock,
+					   // TODO
+					   struct Object *ob);
 void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[4][4], float obcol[4], float autobumpscale);
 void GPU_material_unbind(GPUMaterial *material);
 int GPU_material_bound(GPUMaterial *material);
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index e77ea32..e35ed15 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -38,6 +38,7 @@
 #include "DNA_customdata_types.h"
 #include "DNA_image_types.h"
 #include "DNA_material_types.h"
+#include "DNA_object_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_utildefines.h"
@@ -49,6 +50,10 @@
 
 #include "BLI_sys_types.h" // for intptr_t support
 
+#include "BKE_customdata.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_ptex.h"
+
 #include "gpu_codegen.h"
 
 #include <string.h>
@@ -359,7 +364,7 @@ static int codegen_input_has_texture(GPUInput *input)
 {
 	if (input->link)
 		return 0;
-	else if (input->ima || input->prv)
+	else if (input->ima || input->prv || input->ptex)
 		return 1;
 	else
 		return input->tex != NULL;
@@ -431,6 +436,11 @@ static void codegen_set_unique_ids(ListBase *nodes)
 					/* input is texture from buffer */
 					codegen_set_texid(bindhash, input, &texid, input->link);
 				}
+				else if (input->ptex) {
+					// TODO
+					input->texid = texid++;
+					input->bindtex = 1;
+				}
 				else if (input->ima) {
 					/* input is texture from image */
 					codegen_set_texid(bindhash, input, &texid, input->ima);
@@ -778,7 +788,7 @@ static void gpu_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes)
 				continue;
 			}
 
-			if (input->ima || input->tex || input->prv)
+			if (input->ima || input->tex || input->prv || input->ptex)
 				BLI_snprintf(input->shadername, sizeof(input->shadername), "samp%d", input->texid);
 			else
 				BLI_snprintf(input->shadername, sizeof(input->shadername), "unf%d", input->id);
@@ -786,7 +796,7 @@ static void gpu_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes)
 			/* pass non-dynamic uniforms to opengl */
 			extract = 0;
 
-			if (input->ima || input->tex || input->prv) {
+			if (input->ima || input->tex || input->prv || input->ptex) {
 				if (input->bindtex)
 					extract = 1;
 			}
@@ -807,7 +817,9 @@ static void gpu_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes)
 	GPU_shader_unbind();
 }
 
-void GPU_pass_bind(GPUPass *pass, double time, int mipmap)
+void GPU_pass_bind(GPUPass *pass, double time, int mipmap,
+				   // TODO
+				   Object *ob)
 {
 	GPUInput *input;
 	GPUShader *shader = pass->shader;
@@ -818,6 +830,26 @@ void GPU_pass_bind(GPUPass *pass, double time, int mipmap)
 
 	GPU_shader_bind

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list