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
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
|