Paste Code
Paste Blends
Paste Images
Index: source/blender/blenloader/intern/readfile.c
===================================================================
--- source/blender/blenloader/intern/readfile.c (revision 17640)
+++ source/blender/blenloader/intern/readfile.c (working copy)
@@ -8006,6 +8006,20 @@
}
}
}
+
+ if (main->versionfile < 249) {
+ bActuator *act;
+ Object *ob;
+
+ for(ob = main->object.first; ob; ob= ob->id.next) {
+ for(act= ob->actuators.first; act; act= act->next) {
+ if (act->type == ACT_2DFILTER) {
+ bTwoDFilterActuator *twoDAct = (bTwoDFilterActuator *) act->data;
+ twoDAct->type = twoDAct->type;
+ }
+ }
+ }
+ }

/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
@@ -8783,6 +8797,10 @@
bMessageActuator *ma= act->data;
expand_doit(fd, mainvar, ma->toObject);
}
+ else if(act->type==ACT_2DFILTER) {
+ bTwoDFilterActuator *tdfa= act->data;
+ expand_doit(fd, mainvar, tdfa->ima);
+ }
act= act->next;
}

Index: source/blender/makesdna/DNA_actuator_types.h
===================================================================
--- source/blender/makesdna/DNA_actuator_types.h (revision 17640)
+++ source/blender/makesdna/DNA_actuator_types.h (working copy)
@@ -31,6 +31,8 @@
#ifndef DNA_ACTUATOR_TYPES_H
#define DNA_ACTUATOR_TYPES_H

+#include "DNA_image_types.h"
+
struct Object;
struct Mesh;
struct Scene;
@@ -210,6 +212,10 @@
/* a float argument */
float float_arg;
struct Text *text;
+
+ /* texture uniform */
+ struct Image *ima;
+ struct ImageUser iuser;
}bTwoDFilterActuator;

typedef struct bParentActuator {
@@ -474,7 +480,8 @@
#define ACT_2DFILTER_SEPIA 10
#define ACT_2DFILTER_INVERT 11
#define ACT_2DFILTER_CUSTOMFILTER 12
-#define ACT_2DFILTER_NUMBER_OF_FILTERS 13
+#define ACT_2DFILTER_UNITEXTURE 13
+#define ACT_2DFILTER_NUMBER_OF_FILTERS 14

/* parentactuator->type */
#define ACT_PARENT_SET 0
Index: source/blender/src/buttons_logic.c
===================================================================
--- source/blender/src/buttons_logic.c (revision 17640)
+++ source/blender/src/buttons_logic.c (working copy)
@@ -1685,6 +1685,7 @@

static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width)
{
+// View3D *vd = G.vd;
bSoundActuator *sa = NULL;
bCDActuator *cda = NULL;
bObjectActuator *oa = NULL;
@@ -2641,11 +2642,18 @@
{
ysize +=20;
}
+ else if(tdfa->type == ACT_2DFILTER_UNITEXTURE)
+ {
+ ysize +=40;
+ }
glRects( xco, yco-ysize, xco+width, yco );
uiEmboss( (float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1 );

switch(tdfa->type)
{
+ case ACT_2DFILTER_UNITEXTURE:
+ uiblock_image_panel_GLSL(block, &tdfa->ima, &tdfa->iuser, xco, yco,B_REDR, B_REDR);
+ break;
case ACT_2DFILTER_MOTIONBLUR:
if(!tdfa->flag)
{
@@ -2678,7 +2686,7 @@
break;
}

- str= "2D Filter %t|Motion Blur %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5|"
+ str= "2D Filter %t|Uniform Texture %x13|Motion Blur %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5|"
"Laplacian %x6|Sobel %x7|Prewitt %x8|Gray Scale %x9|Sepia %x10|Invert %x11|Custom Filter %x12|"
"Enable Filter %x-2|Disable Filter %x-1|Remove Filter %x0|";
uiDefButS(block, MENU, B_REDR, str, xco+30,yco-24,width-60, 19, &tdfa->type, 0.0, 0.0, 0.0, 0.0, "2D filter type");
Index: source/blender/src/buttons_shading.c
===================================================================
--- source/blender/src/buttons_shading.c (revision 17640)
+++ source/blender/src/buttons_shading.c (working copy)
@@ -1069,6 +1069,180 @@
}

/* The general Image panel with the loadsa callbacks! */
+void uiblock_image_panel_GLSL(uiBlock *block, Image **ima_pp, ImageUser *iuser, short xco, short yco,
+ short redraw, short imagechanged)
+{
+ Image *ima= *ima_pp;
+ uiBut *but;
+ char str[128], *strp;
+// short xco, yco;
+
+// xco = *xco_p - 1040 + 1040;
+// yco = *yco_p - 150 - 50;
+
+ yco -= 200;
+
+ /*
+ if(ima && ima->source==IMA_SRC_VIEWER) {
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser);
+
+ image_info(ima, ibuf, str);
+ uiDefBut(block, LABEL, 0, ima->id.name+2, 10, 180, 300, 20, NULL, 1, 0, 0, 0, "");
+ uiDefBut(block, LABEL, 0, str, 10, 160, 300, 20, NULL, 1, 0, 0, 0, "");
+
+ if(ima->type==IMA_TYPE_COMPOSITE) {
+ iuser= ntree_get_active_iuser(G.scene->nodetree);
+ if(iuser) {
+ uiBlockBeginAlign(block);
+ uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10,120,100,20, 0, 0, 0, 0, 0, "");
+ uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110,120,100,20, 0, 0, 0, 0, 0, "");
+ but= uiDefBut(block, BUT, B_NOP, "Free Cache", 210,120,100,20, 0, 0, 0, 0, 0, "");
+ uiButSetFunc(but, image_freecache_cb, ima, NULL);
+
+ if(iuser->frames)
+ sprintf(str, "(%d) Frames:", iuser->framenr);
+ else strcpy(str, "Frames:");
+ uiBlockBeginAlign(block);
+ uiDefButI(block, NUM, imagechanged, str, 10, 90,150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of images of a movie to use");
+ uiDefButI(block, NUM, imagechanged, "StartFr:", 160,90,150,20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Sets the global starting frame of the movie");
+ }
+ }
+ else if(ima->type==IMA_TYPE_R_RESULT) {
+ uiblock_layer_pass_arrow_buttons(block, RE_GetResult(RE_GetRender(G.scene->id.name)), iuser, imagechanged);
+ }
+ return;
+ }
+*/
+ /* the main ima source types */
+/*
+ if(ima) {
+ uiSetButLock(ima->id.lib!=NULL, ERROR_LIBDATA_MESSAGE);
+ uiBlockBeginAlign(block);
+ uiBlockSetFunc(block, image_src_change_cb, ima, iuser);
+ uiDefButS(block, ROW, imagechanged, "Still", 10, 180, 60, 20, &ima->source, 0.0, IMA_SRC_FILE, 0, 0, "Single Image file");
+ uiDefButS(block, ROW, imagechanged, "Movie", 70, 180, 60, 20, &ima->source, 0.0, IMA_SRC_MOVIE, 0, 0, "Movie file");
+ uiDefButS(block, ROW, imagechanged, "Sequence", 130, 180, 90, 20, &ima->source, 0.0, IMA_SRC_SEQUENCE, 0, 0, "Multiple Image files, as a sequence");
+ uiDefButS(block, ROW, imagechanged, "Generated", 220, 180, 90, 20, &ima->source, 0.0, IMA_SRC_GENERATED, 0, 0, "Generated Image");
+ uiBlockSetFunc(block, NULL, NULL, NULL);
+ }
+ else
+ uiDefBut(block, LABEL, 0, " ", 10, 180, 300, 20, 0, 0, 0, 0, 0, "");
+*/
+ /* Browse */
+ IMAnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), NULL, &iuser->menunr);
+
+ uiBlockBeginAlign(block);
+ but= uiDefButS(block, MENU, imagechanged, strp, xco+10,yco+155,23,20, &iuser->menunr, 0, 0, 0, 0, "Selects an existing Image");
+ uiButSetFunc(but, image_browse_cb, ima_pp, iuser);
+
+ MEM_freeN(strp);
+
+ /* name + options, or only load */
+ if(ima) {
+ int drawpack= (ima->source!=IMA_SRC_SEQUENCE && ima->source!=IMA_SRC_MOVIE && ima->ok);
+
+ but= uiDefBut(block, TEX, B_IDNAME, "IM:", xco+33, yco+155, 177, 20, ima->id.name+2, 0.0, 21.0, 0, 0, "Current Image Datablock name.");
+ uiButSetFunc(but, test_idbutton_cb, ima->id.name, NULL);
+ but= uiDefBut(block, BUT, imagechanged, "Reload", xco+210, yco+155, 60, 20, NULL, 0, 0, 0, 0, "Reloads Image or Movie");
+ uiButSetFunc(but, image_reload_cb, ima, iuser);
+
+ but= uiDefIconBut(block, BUT, imagechanged, ICON_X, xco+270,yco+155,20,20, 0, 0, 0, 0, 0, "Unlink Image block");
+ uiButSetFunc(but, image_unlink_cb, ima_pp, NULL);
+ sprintf(str, "%d", ima->id.us);
+ uiDefBut(block, BUT, B_NOP, str, xco+290,yco+155,20,20, 0, 0, 0, 0, 0, "Only displays number of users of Image block");
+
+ but= uiDefIconBut(block, BUT, imagechanged, ICON_FILESEL, xco+10, yco+135, 23, 20, 0, 0, 0, 0, 0, "Open Fileselect to load new Image");
+ uiButSetFunc(but, image_load_fs_cb, ima_pp, iuser);
+ but= uiDefBut(block, TEX, imagechanged, "", xco+33,yco+135,257+(drawpack?0:20),20, ima->name, 0.0, 239.0, 0, 0, "Image/Movie file name, change to load new");
+ uiButSetFunc(but, image_load_cb, ima_pp, iuser);
+
+ if(drawpack) {
+ if (ima->packedfile) packdummy = 1;
+ else packdummy = 0;
+ but= uiDefIconButBitI(block, TOG, 1, redraw, ICON_PACKAGE, xco+290,yco+135,20,20, &packdummy, 0, 0, 0, 0, "Toggles Packed status of this Image");
+ uiButSetFunc(but, image_pack_cb, ima, iuser);
+ }
+
+ }
+ else {
+ but= uiDefBut(block, BUT, imagechanged, "Load", xco+33, yco+155, 100,20, NULL, 0, 0, 0, 0, "Load new Image of Movie");
+ uiButSetFunc(but, image_load_fs_cb, ima_pp, iuser);
+ }
+ uiBlockEndAlign(block);
+
+ if(ima) {
+ ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser);
+
+ /* check for re-render, only buttons */
+ if(imagechanged==B_IMAGECHANGED) {
+ if(iuser->flag & IMA_ANIM_REFRESHED) {
+ iuser->flag &= ~IMA_ANIM_REFRESHED;
+ BIF_preview_changed(ID_TE);
+ }
+ }
+
+ /* multilayer? */
+ if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) {
+ uiblock_layer_pass_arrow_buttons(block, ima->rr, iuser, imagechanged);
+ }
+ else {
+ image_info(ima, ibuf, str);
+ uiDefBut(block, LABEL, 0, str, xco+10, yco+112, 300, 20, NULL, 1, 0, 0, 0, "");
+ }
+
+
+ /* fields */
+ /*
+ uiBlockBeginAlign(block);
+ but= uiDefButBitS(block, TOG, IMA_FIELDS, imagechanged, "Fields", 10, 70, 65, 20, &ima->flag, 0, 0, 0, 0, "Click to enable use of fields in Image");
+ uiButSetFunc(but, image_field_test, ima, iuser);
+ uiDefButBitS(block, TOG, IMA_STD_FIELD, B_NOP, "Odd", 75, 70, 45, 20, &ima->flag, 0, 0, 0, 0, "Standard Field Toggle");
+
+ uiBlockSetFunc(block, image_reload_cb, ima, iuser);
+ uiDefButBitS(block, TOG, IMA_ANTIALI, B_NOP, "Anti", 10, 50, 45, 20, &ima->flag, 0, 0, 0, 0, "Toggles Image anti-aliasing, only works with solid colors");
+ uiDefButBitS(block, TOG, IMA_DO_PREMUL, imagechanged, "Premul", 55, 50, 65, 20, &ima->flag, 0, 0, 0, 0, "Toggles premultiplying alpha");
+ uiBlockEndAlign(block);
+
+ if( ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
+ sprintf(str, "(%d) Frames:", iuser->framenr);
+
+ uiBlockBeginAlign(block);
+ uiBlockSetFunc(block, image_user_change, iuser, NULL);
+ uiDefButBitS(block, TOG, IMA_ANIM_ALWAYS, B_NOP, "Auto Refresh", 120, 70, 190, 20, &iuser->flag, 0, 0, 0, 0, "Always refresh Image on frame changes");
+
+ if(ima->anim) {
+ uiDefButI(block, NUM, imagechanged, str, 120, 50,170, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of images of a movie to use");
+ but= uiDefBut(block, BUT, redraw, "<", 290, 50, 20, 20, 0, 0, 0, 0, 0, "Copies number of frames in movie file to Frames: button");
+ uiButSetFunc(but, set_frames_cb, ima, iuser);
+ }
+ else
+ uiDefButI(block, NUM, imagechanged, str, 120, 50,190, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of images of a movie to use");
+
+ uiDefButI(block, NUM, imagechanged, "Offs:", 120,30,100,20, &iuser->offset, -MAXFRAMEF, MAXFRAMEF, 0, 0, "Offsets the number of the frame to use in the animation");
+ uiDefButS(block, NUM, imagechanged, "Fie/Ima:", 220,30,90,20, &iuser->fie_ima, 1.0, 200.0, 0, 0, "The number of fields per rendered frame (2 fields is 1 image)");
+
+ uiDefButI(block, NUM, imagechanged, "StartFr:", 120,10,100,20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Sets the global starting frame of the movie");
+ uiDefButS(block, TOG, imagechanged, "Cyclic", 220,10,90,20, &iuser->cycl, 0.0, 1.0, 0, 0, "Cycle the images in the movie");
+
+ uiBlockSetFunc(block, NULL, iuser, NULL);
+ }
+ else if(ima->source==IMA_SRC_GENERATED) {
+
+ uiBlockBeginAlign(block);
+ uiBlockSetFunc(block, image_generated_change_cb, ima, iuser);
+ uiDefButS(block, NUM, imagechanged, "SizeX:", 120,70,100,20, &ima->gen_x, 1.0, 5000.0, 0, 0, "Image size x");
+ uiDefButS(block, NUM, imagechanged, "SizeY:", 220,70,90,20, &ima->gen_y, 1.0, 5000.0, 0, 0, "Image size y");
+ uiDefButS(block, TOG, imagechanged, "UV Test grid",120,50,190,20, &ima->gen_type, 0.0, 1.0, 0, 0, "");
+ uiBlockSetFunc(block, NULL, NULL, NULL);
+ }
+ }
+ uiBlockEndAlign(block);
+ */
+ }
+
+}
+
+/* The general Image panel with the loadsa callbacks! */
void uiblock_image_panel(uiBlock *block, Image **ima_pp, ImageUser *iuser,
short redraw, short imagechanged)
{
Index: source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
===================================================================
--- source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp (revision 17640)
+++ source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp (working copy)
@@ -437,9 +437,9 @@
}
}

-void KX_BlenderRenderTools::Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
+void KX_BlenderRenderTools::Update2DFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
{
- m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text);
+ m_filtermanager.EnableFilter(propNames, gameObj, ima, filtermode, pass, text);
}

void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas)
Index: source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
===================================================================
--- source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h (revision 17640)
+++ source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h (working copy)
@@ -36,6 +36,7 @@
#endif

#include "RAS_IRenderTools.h"
+#include "DNA_image_types.h"

struct KX_ClientObjectInfo;
class KX_RayCast;
@@ -89,7 +90,7 @@

virtual void MotionBlur(RAS_IRasterizer* rasterizer);

- virtual void Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
+ virtual void Update2DFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);

virtual void Render2DFilters(RAS_ICanvas* canvas);

Index: source/gameengine/Converter/KX_ConvertActuators.cpp
===================================================================
--- source/gameengine/Converter/KX_ConvertActuators.cpp (revision 17640)
+++ source/gameengine/Converter/KX_ConvertActuators.cpp (working copy)
@@ -1089,12 +1089,15 @@
case ACT_2DFILTER_ENABLED:
filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED;
break;
+ case ACT_2DFILTER_UNITEXTURE:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_UNITEXTURE;
+ break;
default:
filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
break;
}

- tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag,
+ tmp = new SCA_2DFilterActuator(gameobj, _2dfilter->ima ,filtermode, _2dfilter->flag,
_2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools);

if (_2dfilter->text)
Index: source/gameengine/GameLogic/CMakeLists.txt
===================================================================
--- source/gameengine/GameLogic/CMakeLists.txt (revision 17640)
+++ source/gameengine/GameLogic/CMakeLists.txt (working copy)
@@ -29,6 +29,7 @@
SET(INC
.
../../../source/kernel/gen_system
+ ../../../source/blender/makesdna
../../../intern/string
../../../source/gameengine/Expressions
../../../intern/moto/include
Index: source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
===================================================================
--- source/gameengine/GameLogic/SCA_2DFilterActuator.cpp (revision 17640)
+++ source/gameengine/GameLogic/SCA_2DFilterActuator.cpp (working copy)
@@ -13,6 +13,7 @@

SCA_2DFilterActuator::SCA_2DFilterActuator(
SCA_IObject *gameobj,
+ Image *ima,
RAS_2DFilterManager::RAS_2DFILTER_MODE type,
short flag,
float float_arg,
@@ -21,6 +22,7 @@
RAS_IRenderTools* rendertools,
PyTypeObject* T)
: SCA_IActuator(gameobj, T),
+ m_ima(ima),
m_type(type),
m_flag(flag),
m_float_arg(float_arg),
@@ -33,6 +35,10 @@
m_propNames = gameobj->GetPropertyNames();
m_gameObj = gameobj;
}
+ m_ima = NULL;
+ if(ima){
+ m_ima = ima;
+ }
}

void SCA_2DFilterActuator::SetShaderText(STR_String text)
@@ -72,7 +78,7 @@
}
else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS)
{
- m_rendertools->Update2DFilter(m_propNames, m_gameObj, m_type, m_int_arg, m_shaderText);
+ m_rendertools->Update2DFilter(m_propNames, m_gameObj, m_ima, m_type, m_int_arg, m_shaderText);
}
return true;
}
Index: source/gameengine/GameLogic/SCA_2DFilterActuator.h
===================================================================
--- source/gameengine/GameLogic/SCA_2DFilterActuator.h (revision 17640)
+++ source/gameengine/GameLogic/SCA_2DFilterActuator.h (working copy)
@@ -4,6 +4,7 @@
#include "RAS_IRasterizer.h"
#include "RAS_IRenderTools.h"
#include "SCA_IActuator.h"
+#include "DNA_image_types.h"

class SCA_2DFilterActuator : public SCA_IActuator
{
@@ -12,6 +13,7 @@
private:
vector<STR_String> m_propNames;
void * m_gameObj;
+ Image * m_ima;
RAS_2DFilterManager::RAS_2DFILTER_MODE m_type;
short m_flag;
float m_float_arg;
@@ -24,6 +26,7 @@

SCA_2DFilterActuator(
class SCA_IObject* gameobj,
+ Image* ima,
RAS_2DFilterManager::RAS_2DFILTER_MODE type,
short flag,
float float_arg,
Index: source/gameengine/Rasterizer/CMakeLists.txt
===================================================================
--- source/gameengine/Rasterizer/CMakeLists.txt (revision 17640)
+++ source/gameengine/Rasterizer/CMakeLists.txt (working copy)
@@ -28,9 +28,17 @@

SET(INC
.
+ ../../../source/blender/makesdna
+ ../../../source/gameengine/Ketsji
+ ../../../source/gameengine/GameLogic
+ ../../../source/gameengine/SceneGraph
+ ../../../source/gameengine/Rasterizer
+ ../../../source/gameengine/VideoTexture
../../../source/kernel/gen_system
+ ../../../source/blender/gpu
../../../intern/string
../../../intern/moto/include
+ ../../../intern/SoundSystem
../../../extern/glew/include
../Expressions
${PYTHON_INC}
Index: source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
===================================================================
--- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp (revision 17640)
+++ source/gameengine/Rasterizer/RAS_2DFilterManager.cpp (working copy)
@@ -41,14 +41,32 @@
#include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h"
#include "RAS_OpenGLFilters/RAS_Invert2DFilter.h"

+#include "DNA_ID.h"
+#include "DNA_listBase.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_image_types.h"
+
+/*
+#include "KX_GameObject.h"
+#include "RAS_MeshObject.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_image_types.h"
+#include "IMB_imbuf_types.h"
+#include "BDR_drawmesh.h"
+#include "KX_PolygonMaterial.h"
+*/
#include "STR_String.h"
#include "RAS_ICanvas.h"
#include "RAS_Rect.h"
#include "RAS_2DFilterManager.h"
+#include "KX_PolygonMaterial.h"
+#include "Texture.h"
+#include "GL/glew.h"
+
#include <iostream>

-#include "GL/glew.h"
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -272,6 +290,20 @@
glUniform1fARB(uniformLoc,value);
}
}
+ /*
+ My code !!! :)
+ */
+ if(pass_tex_uniform){
+ uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_Texture_01");
+ glActiveTextureARB(GL_TEXTURE4);
+ glBindTexture(GL_TEXTURE_2D, bl_texname[0]);
+
+ if (uniformLoc != -1)
+ {
+ glUniform1iARB(uniformLoc, 4);
+ }
+ }
+ /*end passing 01 texture */
}

void RAS_2DFilterManager::EndShaderProgram()
@@ -288,6 +320,11 @@
if(texname[2]!=(unsigned int)-1)
glDeleteTextures(1, (GLuint*)&texname[2]);
}
+void RAS_2DFilterManager::FreeBlenderTextures()
+{
+ if(bl_texname[0]!=(unsigned int)-1)
+ glDeleteTextures(1, (GLuint*)&bl_texname[0]);
+}

void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance)
{
@@ -326,7 +363,24 @@
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
}
}
+void RAS_2DFilterManager::SetupBlenderTextures(Image* ima)
+{
+ pass_tex_uniform = true;
+ Image * m_ima = ima;

+ bl_texname[0] = m_ima->bindcode;
+
+ /*
+ glGenTextures(1, (GLuint*)&bl_texname[0]);
+ glBindTexture(GL_TEXTURE_2D, bl_texname[0]);
+// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ */
+}
+
void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas)
{
RAS_Rect canvas_rect = canvas->GetWindowArea();
@@ -417,6 +471,7 @@
if(need_tex_update)
{
SetupTextures(need_depth, need_luminance);
+// SetupBlenderTextures();
need_tex_update = false;
}

@@ -446,6 +501,7 @@
{
if(m_filters[passindex] && m_enabled[passindex])
{
+
StartShaderProgram(passindex);

glActiveTextureARB(GL_TEXTURE0);
@@ -468,13 +524,13 @@
EndShaderProgram();
}

-void RAS_2DFilterManager::EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text)
+void RAS_2DFilterManager::EnableFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFILTER_MODE mode, int pass, STR_String& text)
{
if(!isshadersupported)
return;
if(pass<0 || pass>=MAX_RENDER_PASS)
return;
- need_tex_update = true;
+// need_tex_update = true;
if(mode == RAS_2DFILTER_DISABLED)
{
m_enabled[pass] = 0;
@@ -509,6 +565,15 @@
m_enabled[pass] = 1;
return;
}
+ if(mode == RAS_2DFILTER_UNITEXTURE)
+ {
+ SetupBlenderTextures(ima);
+ // pass uniform textures
+ // name of texture
+ // texture id
+ // setup textures
+ return;
+ }

if(mode>=RAS_2DFILTER_MOTIONBLUR && mode<=RAS_2DFILTER_INVERT)
{
Index: source/gameengine/Rasterizer/RAS_2DFilterManager.h
===================================================================
--- source/gameengine/Rasterizer/RAS_2DFilterManager.h (revision 17640)
+++ source/gameengine/Rasterizer/RAS_2DFilterManager.h (working copy)
@@ -30,6 +30,8 @@

#define MAX_RENDER_PASS 100

+#include "DNA_image_types.h"
+
class RAS_2DFilterManager
{
private:
@@ -42,6 +44,8 @@

void SetupTextures(bool depth, bool luminance);
void FreeTextures();
+ void SetupBlenderTextures(Image* ima);
+ void FreeBlenderTextures();

void UpdateOffsetMatrix(RAS_ICanvas* canvas);
void UpdateCanvasTextureCoord(unsigned int * viewport);
@@ -50,7 +54,14 @@
float textureoffsets[18];
float view[4];
/* texname[0] contains render to texture, texname[1] contains depth texture, texname[2] contains luminance texture*/
- unsigned int texname[3];
+ unsigned int texname[3];
+
+ /* bl_texname[0] contains first texture in the material in this object */
+ unsigned int bl_texname[3];
+
+// GLubyte checkImage[64][64][3];
+// void makeCheckImage();
+
int texturewidth;
int textureheight;
int canvaswidth;
@@ -63,10 +74,12 @@
bool isshadersupported;
bool errorprinted;
bool need_tex_update;
+ bool pass_tex_uniform; //custom textures as uniform

unsigned int m_filters[MAX_RENDER_PASS];
short m_enabled[MAX_RENDER_PASS];

+ // stores object textures to send to shaders in each pass
// stores object properties to send to shaders in each pass
vector<STR_String> m_properties[MAX_RENDER_PASS];
void* m_gameObjects[MAX_RENDER_PASS];
@@ -87,6 +100,7 @@
RAS_2DFILTER_SEPIA,
RAS_2DFILTER_INVERT,
RAS_2DFILTER_CUSTOMFILTER,
+ RAS_2DFILTER_UNITEXTURE,
RAS_2DFILTER_NUMBER_OF_FILTERS
};

@@ -96,6 +110,6 @@

void RenderFilters(RAS_ICanvas* canvas);

- void EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text);
+ void EnableFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFILTER_MODE mode, int pass, STR_String& text);
};
#endif
Index: source/gameengine/Rasterizer/RAS_IRenderTools.h
===================================================================
--- source/gameengine/Rasterizer/RAS_IRenderTools.h (revision 17640)
+++ source/gameengine/Rasterizer/RAS_IRenderTools.h (working copy)
@@ -32,6 +32,7 @@
#include "MT_Transform.h"
#include "RAS_IRasterizer.h"
#include "RAS_2DFilterManager.h"
+#include "DNA_image_types.h"

#include <vector>
#include <algorithm>
@@ -178,7 +179,7 @@

virtual
void
- Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0;
+ Update2DFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0;

virtual
void
Index: source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
===================================================================
--- source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt (revision 17640)
+++ source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt (working copy)
@@ -27,6 +27,7 @@
FILE(GLOB SRC *.cpp)

SET(INC
+ ../../../../source/blender/makesdna
../../../../source/kernel/gen_system
../../../../intern/string
../../../../intern/moto/include
  1. Index: source/blender/blenloader/intern/readfile.c
  2. ===================================================================
  3. --- source/blender/blenloader/intern/readfile.c (revision 17640)
  4. +++ source/blender/blenloader/intern/readfile.c (working copy)
  5. @@ -8006,6 +8006,20 @@
  6.                         }
  7.                 }
  8.         }
  9. +
  10. +       if (main->versionfile < 249) {
  11. +               bActuator *act;
  12. +               Object *ob;
  13. +              
  14. +               for(ob = main->object.first; ob; ob= ob->id.next) {
  15. +                       for(act= ob->actuators.first; act; act= act->next) {
  16. +                               if (act->type == ACT_2DFILTER) {
  17. +                                       bTwoDFilterActuator *twoDAct = (bTwoDFilterActuator *) act->data;
  18. +                                       twoDAct->type = twoDAct->type;
  19. +                               }
  20. +                       }
  21. +               }
  22. +       }
  23.         
  24.         /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
  25.         /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
  26. @@ -8783,6 +8797,10 @@
  27.                         bMessageActuator *ma= act->data;
  28.                         expand_doit(fd, mainvar, ma->toObject);
  29.                 }
  30. +               else if(act->type==ACT_2DFILTER) {
  31. +                       bTwoDFilterActuator     *tdfa= act->data;
  32. +                       expand_doit(fd, mainvar, tdfa->ima);
  33. +               }
  34.                 act= act->next;
  35.         }
  36.  
  37. Index: source/blender/makesdna/DNA_actuator_types.h
  38. ===================================================================
  39. --- source/blender/makesdna/DNA_actuator_types.h        (revision 17640)
  40. +++ source/blender/makesdna/DNA_actuator_types.h        (working copy)
  41. @@ -31,6 +31,8 @@
  42.  #ifndef DNA_ACTUATOR_TYPES_H
  43.  #define DNA_ACTUATOR_TYPES_H
  44.  
  45. +#include "DNA_image_types.h"
  46. +
  47.  struct Object;
  48.  struct Mesh;
  49.  struct Scene;
  50. @@ -210,6 +212,10 @@
  51.         /* a float argument */
  52.         float float_arg;
  53.         struct Text *text;
  54. +
  55. +       /* texture uniform */
  56. +       struct Image *ima;
  57. +       struct ImageUser iuser;
  58.  }bTwoDFilterActuator;
  59.  
  60.  typedef struct bParentActuator {
  61. @@ -474,7 +480,8 @@
  62.  #define ACT_2DFILTER_SEPIA                             10
  63.  #define ACT_2DFILTER_INVERT                            11
  64.  #define ACT_2DFILTER_CUSTOMFILTER              12
  65. -#define ACT_2DFILTER_NUMBER_OF_FILTERS 13
  66. +#define ACT_2DFILTER_UNITEXTURE                        13
  67. +#define ACT_2DFILTER_NUMBER_OF_FILTERS 14
  68.  
  69.  /* parentactuator->type */
  70.  #define ACT_PARENT_SET      0
  71. Index: source/blender/src/buttons_logic.c
  72. ===================================================================
  73. --- source/blender/src/buttons_logic.c  (revision 17640)
  74. +++ source/blender/src/buttons_logic.c  (working copy)
  75. @@ -1685,6 +1685,7 @@
  76.  
  77.  static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, short xco, short yco, short width)
  78.  {
  79. +//     View3D *vd = G.vd;
  80.         bSoundActuator      *sa      = NULL;
  81.         bCDActuator                     *cda     = NULL;
  82.         bObjectActuator     *oa      = NULL;
  83. @@ -2641,11 +2642,18 @@
  84.                 {
  85.                         ysize +=20;
  86.                 }
  87. +               else if(tdfa->type == ACT_2DFILTER_UNITEXTURE)
  88. +               {
  89. +                       ysize +=40;
  90. +               }
  91.          glRects( xco, yco-ysize, xco+width, yco );
  92.                 uiEmboss( (float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1 );
  93.  
  94.                 switch(tdfa->type)
  95.                 {
  96. +                       case ACT_2DFILTER_UNITEXTURE:
  97. +                               uiblock_image_panel_GLSL(block, &tdfa->ima, &tdfa->iuser, xco, yco,B_REDR, B_REDR);
  98. +                               break;
  99.                         case ACT_2DFILTER_MOTIONBLUR:
  100.                                 if(!tdfa->flag)
  101.                                 {
  102. @@ -2678,7 +2686,7 @@
  103.                                 break;
  104.                 }
  105.                
  106. -               str= "2D Filter   %t|Motion Blur   %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5|"
  107. +               str= "2D Filter   %t|Uniform Texture %x13|Motion Blur   %x1|Blur %x2|Sharpen %x3|Dilation %x4|Erosion %x5|"
  108.                                 "Laplacian %x6|Sobel %x7|Prewitt %x8|Gray Scale %x9|Sepia %x10|Invert %x11|Custom Filter %x12|"
  109.                                 "Enable Filter %x-2|Disable Filter %x-1|Remove Filter %x0|";
  110.                 uiDefButS(block, MENU, B_REDR, str,     xco+30,yco-24,width-60, 19, &tdfa->type, 0.0, 0.0, 0.0, 0.0, "2D filter type");
  111. Index: source/blender/src/buttons_shading.c
  112. ===================================================================
  113. --- source/blender/src/buttons_shading.c        (revision 17640)
  114. +++ source/blender/src/buttons_shading.c        (working copy)
  115. @@ -1069,6 +1069,180 @@
  116.  }
  117.  
  118.  /* The general Image panel with the loadsa callbacks! */
  119. +void uiblock_image_panel_GLSL(uiBlock *block, Image **ima_pp, ImageUser *iuser, short xco, short yco,
  120. +                                                short redraw, short imagechanged)
  121. +{
  122. +       Image *ima= *ima_pp;
  123. +       uiBut *but;
  124. +       char str[128], *strp;
  125. +//     short xco, yco;
  126. +
  127. +//     xco = *xco_p - 1040 + 1040;
  128. +//     yco = *yco_p - 150 - 50;
  129. +
  130. +       yco -= 200;
  131. +
  132. +       /*
  133. +       if(ima && ima->source==IMA_SRC_VIEWER) {
  134. +               ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser);
  135. +              
  136. +               image_info(ima, ibuf, str);
  137. +               uiDefBut(block, LABEL, 0, ima->id.name+2,       10, 180, 300, 20, NULL, 1, 0, 0, 0, "");
  138. +               uiDefBut(block, LABEL, 0, str,                          10, 160, 300, 20, NULL, 1, 0, 0, 0, "");
  139. +              
  140. +               if(ima->type==IMA_TYPE_COMPOSITE) {
  141. +                       iuser= ntree_get_active_iuser(G.scene->nodetree);
  142. +                       if(iuser) {
  143. +                               uiBlockBeginAlign(block);
  144. +                               uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10,120,100,20, 0, 0, 0, 0, 0, "");
  145. +                               uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play",    110,120,100,20, 0, 0, 0, 0, 0, "");
  146. +                               but= uiDefBut(block, BUT, B_NOP, "Free Cache",  210,120,100,20, 0, 0, 0, 0, 0, "");
  147. +                               uiButSetFunc(but, image_freecache_cb, ima, NULL);
  148. +                              
  149. +                               if(iuser->frames)
  150. +                                       sprintf(str, "(%d) Frames:", iuser->framenr);
  151. +                               else strcpy(str, "Frames:");
  152. +                               uiBlockBeginAlign(block);
  153. +                               uiDefButI(block, NUM, imagechanged, str,                10, 90,150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of images of a movie to use");
  154. +                               uiDefButI(block, NUM, imagechanged, "StartFr:", 160,90,150,20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Sets the global starting frame of the movie");
  155. +                       }
  156. +               }
  157. +               else if(ima->type==IMA_TYPE_R_RESULT) {
  158. +                       uiblock_layer_pass_arrow_buttons(block, RE_GetResult(RE_GetRender(G.scene->id.name)), iuser, imagechanged);
  159. +               }
  160. +               return;
  161. +       }
  162. +*/     
  163. +       /* the main ima source types */
  164. +/*
  165. +       if(ima) {
  166. +               uiSetButLock(ima->id.lib!=NULL, ERROR_LIBDATA_MESSAGE);
  167. +               uiBlockBeginAlign(block);
  168. +               uiBlockSetFunc(block, image_src_change_cb, ima, iuser);
  169. +               uiDefButS(block, ROW, imagechanged, "Still",            10, 180, 60, 20, &ima->source, 0.0, IMA_SRC_FILE, 0, 0, "Single Image file");
  170. +               uiDefButS(block, ROW, imagechanged, "Movie",            70, 180, 60, 20, &ima->source, 0.0, IMA_SRC_MOVIE, 0, 0, "Movie file");
  171. +               uiDefButS(block, ROW, imagechanged, "Sequence", 130, 180, 90, 20, &ima->source, 0.0, IMA_SRC_SEQUENCE, 0, 0, "Multiple Image files, as a sequence");
  172. +               uiDefButS(block, ROW, imagechanged, "Generated",        220, 180, 90, 20, &ima->source, 0.0, IMA_SRC_GENERATED, 0, 0, "Generated Image");
  173. +               uiBlockSetFunc(block, NULL, NULL, NULL);
  174. +       }
  175. +       else
  176. +               uiDefBut(block, LABEL, 0, " ",                                  10, 180, 300, 20, 0, 0, 0, 0, 0, "");
  177. +*/
  178. +        /* Browse */
  179. +        IMAnames_to_pupstring(&strp, NULL, NULL, &(G.main->image), NULL, &iuser->menunr);
  180. +       
  181. +        uiBlockBeginAlign(block);
  182. +        but= uiDefButS(block, MENU, imagechanged, strp,                xco+10,yco+155,23,20, &iuser->menunr, 0, 0, 0, 0, "Selects an existing Image");
  183. +        uiButSetFunc(but, image_browse_cb, ima_pp, iuser);
  184. +       
  185. +        MEM_freeN(strp);
  186. +
  187. +        /* name + options, or only load */
  188. +        if(ima) {
  189. +                int drawpack= (ima->source!=IMA_SRC_SEQUENCE && ima->source!=IMA_SRC_MOVIE && ima->ok);
  190. +
  191. +                but= uiDefBut(block, TEX, B_IDNAME, "IM:",             xco+33, yco+155, 177, 20, ima->id.name+2, 0.0, 21.0, 0, 0, "Current Image Datablock name.");
  192. +                uiButSetFunc(but, test_idbutton_cb, ima->id.name, NULL);
  193. +                but= uiDefBut(block, BUT, imagechanged, "Reload",              xco+210, yco+155, 60, 20, NULL, 0, 0, 0, 0, "Reloads Image or Movie");
  194. +                uiButSetFunc(but, image_reload_cb, ima, iuser);
  195. +                
  196. +                but= uiDefIconBut(block, BUT, imagechanged, ICON_X,    xco+270,yco+155,20,20, 0, 0, 0, 0, 0, "Unlink Image block");
  197. +                uiButSetFunc(but, image_unlink_cb, ima_pp, NULL);
  198. +                sprintf(str, "%d", ima->id.us);
  199. +                uiDefBut(block, BUT, B_NOP, str,                                       xco+290,yco+155,20,20, 0, 0, 0, 0, 0, "Only displays number of users of Image block");
  200. +                
  201. +                but= uiDefIconBut(block, BUT, imagechanged, ICON_FILESEL,      xco+10, yco+135, 23, 20, 0, 0, 0, 0, 0, "Open Fileselect to load new Image");
  202. +                uiButSetFunc(but, image_load_fs_cb, ima_pp, iuser);
  203. +                but= uiDefBut(block, TEX, imagechanged, "",                            xco+33,yco+135,257+(drawpack?0:20),20, ima->name, 0.0, 239.0, 0, 0, "Image/Movie file name, change to load new");
  204. +                uiButSetFunc(but, image_load_cb, ima_pp, iuser);
  205. +                
  206. +                if(drawpack) {
  207. +                        if (ima->packedfile) packdummy = 1;
  208. +                        else packdummy = 0;
  209. +                        but= uiDefIconButBitI(block, TOG, 1, redraw, ICON_PACKAGE, xco+290,yco+135,20,20, &packdummy, 0, 0, 0, 0, "Toggles Packed status of this Image");
  210. +                        uiButSetFunc(but, image_pack_cb, ima, iuser);
  211. +                }
  212. +                
  213. +        }
  214. +        else {
  215. +                but= uiDefBut(block, BUT, imagechanged, "Load",                xco+33, yco+155, 100,20, NULL, 0, 0, 0, 0, "Load new Image of Movie");
  216. +                uiButSetFunc(but, image_load_fs_cb, ima_pp, iuser);
  217. +        }
  218. +        uiBlockEndAlign(block);
  219. +
  220. +        if(ima) {
  221. +                ImBuf *ibuf= BKE_image_get_ibuf(ima, iuser);
  222. +                
  223. +                /* check for re-render, only buttons */
  224. +                if(imagechanged==B_IMAGECHANGED) {
  225. +                        if(iuser->flag & IMA_ANIM_REFRESHED) {
  226. +                                iuser->flag &= ~IMA_ANIM_REFRESHED;
  227. +                                BIF_preview_changed(ID_TE);
  228. +                        }
  229. +                }
  230. +                
  231. +                /* multilayer? */
  232. +                if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) {
  233. +                        uiblock_layer_pass_arrow_buttons(block, ima->rr, iuser, imagechanged);
  234. +                }
  235. +                else {
  236. +                        image_info(ima, ibuf, str);
  237. +                        uiDefBut(block, LABEL, 0, str,         xco+10, yco+112, 300, 20, NULL, 1, 0, 0, 0, "");
  238. +                }
  239. +                
  240. +
  241. +                /* fields */
  242. + /*
  243. +                uiBlockBeginAlign(block);
  244. +                but= uiDefButBitS(block, TOG, IMA_FIELDS, imagechanged, "Fields",      10, 70, 65, 20, &ima->flag, 0, 0, 0, 0, "Click to enable use of fields in Image");
  245. +                uiButSetFunc(but, image_field_test, ima, iuser);
  246. +                uiDefButBitS(block, TOG, IMA_STD_FIELD, B_NOP, "Odd",                  75, 70, 45, 20, &ima->flag, 0, 0, 0, 0, "Standard Field Toggle");
  247. +                
  248. +                uiBlockSetFunc(block, image_reload_cb, ima, iuser);
  249. +                uiDefButBitS(block, TOG, IMA_ANTIALI, B_NOP, "Anti",                   10, 50, 45, 20, &ima->flag, 0, 0, 0, 0, "Toggles Image anti-aliasing, only works with solid colors");
  250. +                uiDefButBitS(block, TOG, IMA_DO_PREMUL, imagechanged, "Premul",                55, 50, 65, 20, &ima->flag, 0, 0, 0, 0, "Toggles premultiplying alpha");
  251. +                uiBlockEndAlign(block);
  252. +                
  253. +                if( ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
  254. +                        sprintf(str, "(%d) Frames:", iuser->framenr);
  255. +                        
  256. +                        uiBlockBeginAlign(block);
  257. +                        uiBlockSetFunc(block, image_user_change, iuser, NULL);
  258. +                        uiDefButBitS(block, TOG, IMA_ANIM_ALWAYS, B_NOP, "Auto Refresh",       120, 70, 190, 20, &iuser->flag, 0, 0, 0, 0, "Always refresh Image on frame changes");
  259. +                        
  260. +                        if(ima->anim) {
  261. +                                uiDefButI(block, NUM, imagechanged, str,               120, 50,170, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of images of a movie to use");
  262. +                                but= uiDefBut(block, BUT, redraw, "<",         290, 50, 20, 20, 0, 0, 0, 0, 0, "Copies number of frames in movie file to Frames: button");
  263. +                                uiButSetFunc(but, set_frames_cb, ima, iuser);
  264. +                        }
  265. +                        else
  266. +                                uiDefButI(block, NUM, imagechanged, str,               120, 50,190, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Sets the number of images of a movie to use");
  267. +                        
  268. +                        uiDefButI(block, NUM, imagechanged, "Offs:",   120,30,100,20, &iuser->offset, -MAXFRAMEF, MAXFRAMEF, 0, 0, "Offsets the number of the frame to use in the animation");
  269. +                        uiDefButS(block, NUM, imagechanged, "Fie/Ima:",        220,30,90,20, &iuser->fie_ima, 1.0, 200.0, 0, 0, "The number of fields per rendered frame (2 fields is 1 image)");
  270. +                        
  271. +                        uiDefButI(block, NUM, imagechanged, "StartFr:",        120,10,100,20, &iuser->sfra, 1.0, MAXFRAMEF, 0, 0, "Sets the global starting frame of the movie");
  272. +                        uiDefButS(block, TOG, imagechanged, "Cyclic",  220,10,90,20, &iuser->cycl, 0.0, 1.0, 0, 0, "Cycle the images in the movie");
  273. +                        
  274. +                        uiBlockSetFunc(block, NULL, iuser, NULL);
  275. +                }
  276. +                else if(ima->source==IMA_SRC_GENERATED) {
  277. +                        
  278. +                        uiBlockBeginAlign(block);
  279. +                        uiBlockSetFunc(block, image_generated_change_cb, ima, iuser);
  280. +                        uiDefButS(block, NUM, imagechanged, "SizeX:",  120,70,100,20, &ima->gen_x, 1.0, 5000.0, 0, 0, "Image size x");
  281. +                        uiDefButS(block, NUM, imagechanged, "SizeY:",  220,70,90,20, &ima->gen_y, 1.0, 5000.0, 0, 0, "Image size y");
  282. +                        uiDefButS(block, TOG, imagechanged, "UV Test grid",120,50,190,20, &ima->gen_type, 0.0, 1.0, 0, 0, "");
  283. +                        uiBlockSetFunc(block, NULL, NULL, NULL);
  284. +                }
  285. +        }
  286. +        uiBlockEndAlign(block);
  287. +        */
  288. +        }
  289. +
  290. +}     
  291. +
  292. +/* The general Image panel with the loadsa callbacks! */
  293.  void uiblock_image_panel(uiBlock *block, Image **ima_pp, ImageUser *iuser,
  294.                                                  short redraw, short imagechanged)
  295.  {
  296. Index: source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
  297. ===================================================================
  298. --- source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp (revision 17640)
  299. +++ source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp (working copy)
  300. @@ -437,9 +437,9 @@
  301.         }
  302.  }
  303.  
  304. -void KX_BlenderRenderTools::Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
  305. +void KX_BlenderRenderTools::Update2DFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
  306.  {
  307. -       m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text);
  308. +       m_filtermanager.EnableFilter(propNames, gameObj, ima, filtermode, pass, text);
  309.  }
  310.  
  311.  void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas)
  312. Index: source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
  313. ===================================================================
  314. --- source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h   (revision 17640)
  315. +++ source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h   (working copy)
  316. @@ -36,6 +36,7 @@
  317.  #endif
  318.  
  319.  #include "RAS_IRenderTools.h"
  320. +#include "DNA_image_types.h"
  321.  
  322.  struct KX_ClientObjectInfo;
  323.  class KX_RayCast;
  324. @@ -89,7 +90,7 @@
  325.  
  326.         virtual void MotionBlur(RAS_IRasterizer* rasterizer);
  327.  
  328. -       virtual void Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
  329. +       virtual void Update2DFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
  330.  
  331.         virtual void Render2DFilters(RAS_ICanvas* canvas);
  332.  
  333. Index: source/gameengine/Converter/KX_ConvertActuators.cpp
  334. ===================================================================
  335. --- source/gameengine/Converter/KX_ConvertActuators.cpp (revision 17640)
  336. +++ source/gameengine/Converter/KX_ConvertActuators.cpp (working copy)
  337. @@ -1089,12 +1089,15 @@
  338.                                 case ACT_2DFILTER_ENABLED:
  339.                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED;
  340.                                         break;
  341. +                               case ACT_2DFILTER_UNITEXTURE:
  342. +                                       filtermode = RAS_2DFilterManager::RAS_2DFILTER_UNITEXTURE;
  343. +                                       break;
  344.                                 default:
  345.                                         filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
  346.                                         break;
  347.                         }
  348.              
  349. -                       tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag,
  350. +                       tmp = new SCA_2DFilterActuator(gameobj, _2dfilter->ima ,filtermode, _2dfilter->flag,
  351.                                 _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools);
  352.  
  353.                         if (_2dfilter->text)
  354. Index: source/gameengine/GameLogic/CMakeLists.txt
  355. ===================================================================
  356. --- source/gameengine/GameLogic/CMakeLists.txt  (revision 17640)
  357. +++ source/gameengine/GameLogic/CMakeLists.txt  (working copy)
  358. @@ -29,6 +29,7 @@
  359.  SET(INC
  360.    .
  361.    ../../../source/kernel/gen_system
  362. +  ../../../source/blender/makesdna  
  363.    ../../../intern/string
  364.    ../../../source/gameengine/Expressions
  365.    ../../../intern/moto/include
  366. Index: source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
  367. ===================================================================
  368. --- source/gameengine/GameLogic/SCA_2DFilterActuator.cpp        (revision 17640)
  369. +++ source/gameengine/GameLogic/SCA_2DFilterActuator.cpp        (working copy)
  370. @@ -13,6 +13,7 @@
  371.  
  372.  SCA_2DFilterActuator::SCA_2DFilterActuator(
  373.          SCA_IObject *gameobj,
  374. +               Image *ima,
  375.          RAS_2DFilterManager::RAS_2DFILTER_MODE type,
  376.                 short flag,
  377.                 float float_arg,
  378. @@ -21,6 +22,7 @@
  379.                 RAS_IRenderTools* rendertools,
  380.          PyTypeObject* T)
  381.      : SCA_IActuator(gameobj, T),
  382. +        m_ima(ima),
  383.       m_type(type),
  384.          m_flag(flag),
  385.          m_float_arg(float_arg),
  386. @@ -33,6 +35,10 @@
  387.                 m_propNames = gameobj->GetPropertyNames();
  388.                 m_gameObj = gameobj;
  389.         }
  390. +       m_ima = NULL;
  391. +       if(ima){
  392. +               m_ima = ima;
  393. +       }
  394.  }
  395.  
  396.  void SCA_2DFilterActuator::SetShaderText(STR_String text)
  397. @@ -72,7 +78,7 @@
  398.         }
  399.         else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS)
  400.         {
  401. -               m_rendertools->Update2DFilter(m_propNames, m_gameObj, m_type, m_int_arg, m_shaderText);
  402. +               m_rendertools->Update2DFilter(m_propNames, m_gameObj, m_ima, m_type, m_int_arg, m_shaderText);
  403.         }
  404.      return true;
  405.  }
  406. Index: source/gameengine/GameLogic/SCA_2DFilterActuator.h
  407. ===================================================================
  408. --- source/gameengine/GameLogic/SCA_2DFilterActuator.h  (revision 17640)
  409. +++ source/gameengine/GameLogic/SCA_2DFilterActuator.h  (working copy)
  410. @@ -4,6 +4,7 @@
  411.  #include "RAS_IRasterizer.h"
  412.  #include "RAS_IRenderTools.h"
  413.  #include "SCA_IActuator.h"
  414. +#include "DNA_image_types.h"
  415.  
  416.  class SCA_2DFilterActuator : public SCA_IActuator
  417.  {
  418. @@ -12,6 +13,7 @@
  419.  private:
  420.         vector<STR_String> m_propNames;
  421.         void * m_gameObj;
  422. +       Image * m_ima;
  423.         RAS_2DFilterManager::RAS_2DFILTER_MODE m_type;
  424.         short m_flag;
  425.         float m_float_arg;
  426. @@ -24,6 +26,7 @@
  427.  
  428.      SCA_2DFilterActuator(
  429.          class SCA_IObject* gameobj,
  430. +               Image* ima,
  431.          RAS_2DFilterManager::RAS_2DFILTER_MODE type,
  432.                 short flag,
  433.                 float float_arg,
  434. Index: source/gameengine/Rasterizer/CMakeLists.txt
  435. ===================================================================
  436. --- source/gameengine/Rasterizer/CMakeLists.txt (revision 17640)
  437. +++ source/gameengine/Rasterizer/CMakeLists.txt (working copy)
  438. @@ -28,9 +28,17 @@
  439.  
  440.  SET(INC
  441.    .
  442. +  ../../../source/blender/makesdna
  443. +  ../../../source/gameengine/Ketsji
  444. +  ../../../source/gameengine/GameLogic
  445. +  ../../../source/gameengine/SceneGraph
  446. +  ../../../source/gameengine/Rasterizer
  447. +  ../../../source/gameengine/VideoTexture
  448.    ../../../source/kernel/gen_system
  449. +  ../../../source/blender/gpu
  450.    ../../../intern/string
  451.    ../../../intern/moto/include
  452. +  ../../../intern/SoundSystem
  453.    ../../../extern/glew/include
  454.    ../Expressions
  455.    ${PYTHON_INC}
  456. Index: source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
  457. ===================================================================
  458. --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp        (revision 17640)
  459. +++ source/gameengine/Rasterizer/RAS_2DFilterManager.cpp        (working copy)
  460. @@ -41,14 +41,32 @@
  461.  #include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h"
  462.  #include "RAS_OpenGLFilters/RAS_Invert2DFilter.h"
  463.  
  464. +#include "DNA_ID.h"
  465. +#include "DNA_listBase.h"
  466. +#include "DNA_mesh_types.h"
  467. +#include "DNA_meshdata_types.h"
  468. +#include "DNA_image_types.h"
  469. +
  470. +/*
  471. +#include "KX_GameObject.h"
  472. +#include "RAS_MeshObject.h"
  473. +#include "DNA_mesh_types.h"
  474. +#include "DNA_meshdata_types.h"
  475. +#include "DNA_image_types.h"
  476. +#include "IMB_imbuf_types.h"
  477. +#include "BDR_drawmesh.h"
  478. +#include "KX_PolygonMaterial.h"
  479. +*/
  480.  #include "STR_String.h"
  481.  #include "RAS_ICanvas.h"
  482.  #include "RAS_Rect.h"
  483.  #include "RAS_2DFilterManager.h"
  484. +#include "KX_PolygonMaterial.h"
  485. +#include "Texture.h"
  486. +#include "GL/glew.h"
  487. +
  488.  #include <iostream>
  489.  
  490. -#include "GL/glew.h"
  491. -
  492.  #ifdef HAVE_CONFIG_H
  493.  #include <config.h>
  494.  #endif
  495. @@ -272,6 +290,20 @@
  496.                         glUniform1fARB(uniformLoc,value);
  497.                 }
  498.         }
  499. +       /*
  500. +       My code !!! :)
  501. +       */
  502. +       if(pass_tex_uniform){
  503. +               uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_Texture_01");
  504. +               glActiveTextureARB(GL_TEXTURE4);
  505. +               glBindTexture(GL_TEXTURE_2D, bl_texname[0]);
  506. +
  507. +               if (uniformLoc != -1)
  508. +               {
  509. +                       glUniform1iARB(uniformLoc, 4);
  510. +               }
  511. +       }
  512. +       /*end passing 01 texture */
  513.  }
  514.  
  515.  void RAS_2DFilterManager::EndShaderProgram()
  516. @@ -288,6 +320,11 @@
  517.         if(texname[2]!=(unsigned int)-1)
  518.                 glDeleteTextures(1, (GLuint*)&texname[2]);
  519.  }
  520. +void RAS_2DFilterManager::FreeBlenderTextures()
  521. +{
  522. +       if(bl_texname[0]!=(unsigned int)-1)
  523. +               glDeleteTextures(1, (GLuint*)&bl_texname[0]);
  524. +}
  525.  
  526.  void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance)
  527.  {
  528. @@ -326,7 +363,24 @@
  529.                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  530.         }
  531.  }
  532. +void RAS_2DFilterManager::SetupBlenderTextures(Image* ima)
  533. +{
  534. +       pass_tex_uniform = true;
  535. +       Image * m_ima = ima;
  536.  
  537. +       bl_texname[0] = m_ima->bindcode;
  538. +
  539. +       /*
  540. +       glGenTextures(1, (GLuint*)&bl_texname[0]);
  541. +       glBindTexture(GL_TEXTURE_2D, bl_texname[0]);
  542. +//     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checkImageWidth, checkImageHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage);
  543. +       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  544. +       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  545. +       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
  546. +       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
  547. +       */
  548. +}
  549. +
  550.  void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas)
  551.  {
  552.         RAS_Rect canvas_rect = canvas->GetWindowArea();
  553. @@ -417,6 +471,7 @@
  554.         if(need_tex_update)
  555.         {
  556.                 SetupTextures(need_depth, need_luminance);
  557. +//             SetupBlenderTextures();
  558.                 need_tex_update = false;
  559.         }
  560.  
  561. @@ -446,6 +501,7 @@
  562.         {
  563.                 if(m_filters[passindex] && m_enabled[passindex])
  564.                 {
  565. +
  566.                         StartShaderProgram(passindex);
  567.  
  568.                         glActiveTextureARB(GL_TEXTURE0);
  569. @@ -468,13 +524,13 @@
  570.         EndShaderProgram();     
  571.  }
  572.  
  573. -void RAS_2DFilterManager::EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text)
  574. +void RAS_2DFilterManager::EnableFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFILTER_MODE mode, int pass, STR_String& text)
  575.  {
  576.         if(!isshadersupported)
  577.                 return;
  578.         if(pass<0 || pass>=MAX_RENDER_PASS)
  579.                 return;
  580. -       need_tex_update = true;
  581. +//     need_tex_update = true;
  582.         if(mode == RAS_2DFILTER_DISABLED)
  583.         {
  584.                 m_enabled[pass] = 0;
  585. @@ -509,6 +565,15 @@
  586.                 m_enabled[pass] = 1;
  587.                 return;
  588.         }
  589. +       if(mode == RAS_2DFILTER_UNITEXTURE)
  590. +       {
  591. +               SetupBlenderTextures(ima);
  592. +               // pass uniform textures
  593. +               // name of texture
  594. +               // texture id
  595. +               // setup textures
  596. +               return;
  597. +       }
  598.  
  599.         if(mode>=RAS_2DFILTER_MOTIONBLUR && mode<=RAS_2DFILTER_INVERT)
  600.         {
  601. Index: source/gameengine/Rasterizer/RAS_2DFilterManager.h
  602. ===================================================================
  603. --- source/gameengine/Rasterizer/RAS_2DFilterManager.h  (revision 17640)
  604. +++ source/gameengine/Rasterizer/RAS_2DFilterManager.h  (working copy)
  605. @@ -30,6 +30,8 @@
  606.  
  607.  #define MAX_RENDER_PASS        100
  608.  
  609. +#include "DNA_image_types.h"
  610. +
  611.  class RAS_2DFilterManager
  612.  {
  613.  private:
  614. @@ -42,6 +44,8 @@
  615.  
  616.         void SetupTextures(bool depth, bool luminance);
  617.         void FreeTextures();
  618. +       void SetupBlenderTextures(Image* ima);
  619. +       void FreeBlenderTextures();
  620.  
  621.         void UpdateOffsetMatrix(RAS_ICanvas* canvas);
  622.         void UpdateCanvasTextureCoord(unsigned int * viewport);
  623. @@ -50,7 +54,14 @@
  624.         float                   textureoffsets[18];
  625.         float                   view[4];
  626.         /* texname[0] contains render to texture, texname[1] contains depth texture,  texname[2] contains luminance texture*/
  627. -       unsigned int    texname[3];
  628. +       unsigned int    texname[3];
  629. +
  630. +       /* bl_texname[0] contains first texture in the material in this object */
  631. +       unsigned int    bl_texname[3];
  632. +
  633. +//     GLubyte checkImage[64][64][3];
  634. +//     void makeCheckImage();
  635. +
  636.         int                             texturewidth;
  637.         int                             textureheight;
  638.         int                             canvaswidth;
  639. @@ -63,10 +74,12 @@
  640.         bool                    isshadersupported;
  641.         bool                    errorprinted;
  642.         bool                    need_tex_update;
  643. +       bool                    pass_tex_uniform; //custom textures as uniform
  644.  
  645.         unsigned int    m_filters[MAX_RENDER_PASS];
  646.         short           m_enabled[MAX_RENDER_PASS];
  647.  
  648. +       // stores object textures to send to shaders in each pass
  649.         // stores object properties to send to shaders in each pass
  650.         vector<STR_String>      m_properties[MAX_RENDER_PASS];
  651.         void* m_gameObjects[MAX_RENDER_PASS];
  652. @@ -87,6 +100,7 @@
  653.                 RAS_2DFILTER_SEPIA,
  654.                 RAS_2DFILTER_INVERT,
  655.                 RAS_2DFILTER_CUSTOMFILTER,
  656. +               RAS_2DFILTER_UNITEXTURE,
  657.                 RAS_2DFILTER_NUMBER_OF_FILTERS
  658.         };
  659.  
  660. @@ -96,6 +110,6 @@
  661.  
  662.         void RenderFilters(RAS_ICanvas* canvas);
  663.  
  664. -       void EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text);
  665. +       void EnableFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFILTER_MODE mode, int pass, STR_String& text);
  666.  };
  667.  #endif
  668. Index: source/gameengine/Rasterizer/RAS_IRenderTools.h
  669. ===================================================================
  670. --- source/gameengine/Rasterizer/RAS_IRenderTools.h     (revision 17640)
  671. +++ source/gameengine/Rasterizer/RAS_IRenderTools.h     (working copy)
  672. @@ -32,6 +32,7 @@
  673.  #include "MT_Transform.h"
  674.  #include "RAS_IRasterizer.h"
  675.  #include "RAS_2DFilterManager.h"
  676. +#include "DNA_image_types.h"
  677.  
  678.  #include <vector>
  679.  #include <algorithm>
  680. @@ -178,7 +179,7 @@
  681.  
  682.         virtual
  683.                 void
  684. -               Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0;
  685. +               Update2DFilter(vector<STR_String>& propNames, void* gameObj, Image* ima, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0;
  686.  
  687.         virtual
  688.                 void
  689. Index: source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
  690. ===================================================================
  691. --- source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt    (revision 17640)
  692. +++ source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt    (working copy)
  693. @@ -27,6 +27,7 @@
  694.  FILE(GLOB SRC *.cpp)
  695.  
  696.  SET(INC
  697. +  ../../../../source/blender/makesdna
  698.    ../../../../source/kernel/gen_system
  699.    ../../../../intern/string
  700.    ../../../../intern/moto/include
  701.  
go to heaven