From b6d4cb42aa577f8db409f49cda03199bc1cc8077 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud guennebaud Date: Mon, 5 Jul 2010 16:39:09 +0000 Subject: [PATCH] add a new radiance scaling render plugin --- .../framebufferObject.cpp | 237 ++++++++++ .../framebufferObject.h | 77 ++++ .../render_radiance_scaling/gpl.txt | 340 +++++++++++++++ .../render_radiance_scaling/gpuProgram.cpp | 224 ++++++++++ .../render_radiance_scaling/gpuProgram.h | 404 ++++++++++++++++++ .../render_radiance_scaling/gpuShader.cpp | 156 +++++++ .../render_radiance_scaling/gpuShader.h | 72 ++++ .../litSpheres/ls01.png | Bin 0 -> 13113 bytes .../litSpheres/ls02.png | Bin 0 -> 12963 bytes .../radianceScalingRenderer.cpp | 273 ++++++++++++ .../radianceScalingRenderer.h | 192 +++++++++ .../radianceScalingRenderer.qrc | 10 + .../render_radiance_scaling/readme.txt | 50 +++ .../render_radiance_scaling.pro | 13 + .../render_radiance_scaling/shaderDialog.cpp | 187 ++++++++ .../render_radiance_scaling/shaderDialog.h | 96 +++++ .../render_radiance_scaling/shaderDialog.ui | 257 +++++++++++ .../shaders/01_buffer.fs | 45 ++ .../shaders/01_buffer.vs | 35 ++ .../render_radiance_scaling/shaders/02_rs.fs | 231 ++++++++++ .../render_radiance_scaling/shaders/02_rs.vs | 28 ++ .../render_radiance_scaling/texture2D.h | 149 +++++++ .../render_radiance_scaling/textureFormat.cpp | 63 +++ .../render_radiance_scaling/textureFormat.h | 85 ++++ .../render_radiance_scaling/textureParams.cpp | 49 +++ .../render_radiance_scaling/textureParams.h | 65 +++ 26 files changed, 3338 insertions(+) create mode 100644 src/meshlabplugins/render_radiance_scaling/framebufferObject.cpp create mode 100644 src/meshlabplugins/render_radiance_scaling/framebufferObject.h create mode 100644 src/meshlabplugins/render_radiance_scaling/gpl.txt create mode 100644 src/meshlabplugins/render_radiance_scaling/gpuProgram.cpp create mode 100644 src/meshlabplugins/render_radiance_scaling/gpuProgram.h create mode 100644 src/meshlabplugins/render_radiance_scaling/gpuShader.cpp create mode 100644 src/meshlabplugins/render_radiance_scaling/gpuShader.h create mode 100644 src/meshlabplugins/render_radiance_scaling/litSpheres/ls01.png create mode 100644 src/meshlabplugins/render_radiance_scaling/litSpheres/ls02.png create mode 100644 src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.cpp create mode 100644 src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.h create mode 100644 src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.qrc create mode 100644 src/meshlabplugins/render_radiance_scaling/readme.txt create mode 100644 src/meshlabplugins/render_radiance_scaling/render_radiance_scaling.pro create mode 100644 src/meshlabplugins/render_radiance_scaling/shaderDialog.cpp create mode 100644 src/meshlabplugins/render_radiance_scaling/shaderDialog.h create mode 100644 src/meshlabplugins/render_radiance_scaling/shaderDialog.ui create mode 100644 src/meshlabplugins/render_radiance_scaling/shaders/01_buffer.fs create mode 100644 src/meshlabplugins/render_radiance_scaling/shaders/01_buffer.vs create mode 100644 src/meshlabplugins/render_radiance_scaling/shaders/02_rs.fs create mode 100644 src/meshlabplugins/render_radiance_scaling/shaders/02_rs.vs create mode 100644 src/meshlabplugins/render_radiance_scaling/texture2D.h create mode 100644 src/meshlabplugins/render_radiance_scaling/textureFormat.cpp create mode 100644 src/meshlabplugins/render_radiance_scaling/textureFormat.h create mode 100644 src/meshlabplugins/render_radiance_scaling/textureParams.cpp create mode 100644 src/meshlabplugins/render_radiance_scaling/textureParams.h diff --git a/src/meshlabplugins/render_radiance_scaling/framebufferObject.cpp b/src/meshlabplugins/render_radiance_scaling/framebufferObject.cpp new file mode 100644 index 000000000..2cb1c2975 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/framebufferObject.cpp @@ -0,0 +1,237 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#include "framebufferObject.h" +#include +#include + +using namespace std; + +std::vector _buffers; + +FramebufferObject::FramebufferObject() + : fbo_id(0) { + glGenFramebuffersEXT(1,&fbo_id); +} + +FramebufferObject::~FramebufferObject() { + glDeleteFramebuffersEXT(1,&fbo_id); +} + +void FramebufferObject::attachTexture(GLenum tex_target,GLuint tex_id, + GLenum attachment,int mip_level,int z_slice) { + unbindCurrentBindThis(); + + glBindTexture(tex_target,tex_id); + + if(tex_target==GL_TEXTURE_1D) + glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT,attachment, + GL_TEXTURE_1D,tex_id,mip_level); + else if(tex_target == GL_TEXTURE_3D) + glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT,attachment, + GL_TEXTURE_3D,tex_id,mip_level,z_slice); + else + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,attachment, + tex_target,tex_id,mip_level); + + unbindThisBindCurrent(); +} + +void FramebufferObject::attachRenderBuffer(GLuint buff_id,GLenum attachment) { + unbindCurrentBindThis(); + + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,attachment, + GL_RENDERBUFFER_EXT,buff_id); + + unbindThisBindCurrent(); +} + +void FramebufferObject::unattach(GLenum attachment) { + unbindCurrentBindThis(); + + GLenum type = getAttachedType(attachment); + switch(type){ + case GL_RENDERBUFFER_EXT: + attachRenderBuffer(0, attachment); + break; + case GL_TEXTURE: + attachTexture(GL_TEXTURE_2D, 0, attachment); + break; + default: + break; + } + + unbindThisBindCurrent(); +} + +void FramebufferObject::unattachAll() { + int nb_attachments = getMaxColorAttachments(); + for(int i=0;i +#include + +class FramebufferObject { + public: + FramebufferObject(); + ~FramebufferObject(); + + inline void bind(); + inline static void unbind(); + + void attachTexture(GLenum tex_target, + GLuint tex_id, + GLenum attachment = GL_COLOR_ATTACHMENT0_EXT, + int mip_level = 0, + int z_slice = 0); + + void attachRenderBuffer(GLuint rb_id, + GLenum attachment = GL_COLOR_ATTACHMENT0_EXT); + + void unattach(GLenum attachment); + void unattachAll(); + + bool isValid(); + + GLenum getAttachedType(GLenum attachment); + GLuint getAttachedId(GLenum attachment); + GLint getAttachedMipLevel(GLenum attachment); + GLint getAttachedCubeFace(GLenum attachment); + GLint getAttachedZSlice(GLenum attachment); + + static int getMaxColorAttachments(); + static GLenum *buffers(unsigned int i=0); + + private: + void unbindCurrentBindThis(); + void unbindThisBindCurrent(); + + GLuint fbo_id; + GLint current_fbo_id; +}; + +inline void FramebufferObject::bind() { + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo_id); +} + +inline void FramebufferObject::unbind() { + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); +} + + +#endif // FRAMEBUFFER_OBJECT diff --git a/src/meshlabplugins/render_radiance_scaling/gpl.txt b/src/meshlabplugins/render_radiance_scaling/gpl.txt new file mode 100644 index 000000000..b6ee268ef --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/gpl.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/src/meshlabplugins/render_radiance_scaling/gpuProgram.cpp b/src/meshlabplugins/render_radiance_scaling/gpuProgram.cpp new file mode 100644 index 000000000..3cfea127f --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/gpuProgram.cpp @@ -0,0 +1,224 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#include "gpuProgram.h" +#include + +using namespace std; + + +GPUProgram::GPUProgram(GPUShader* vs,GPUShader* fs,GPUShader *gs, + int inputGeometry,int outputGeometry,int outVertices) + : _vs(vs), + _fs(fs), + _gs(gs), + _inputGeometry(inputGeometry), + _outputGeometry(outputGeometry), + _outVertices(outVertices) { + + _programId = glCreateProgram(); + setGeometryParameters(_inputGeometry,_outputGeometry,_outVertices); + attachAndLink(); + } + +GPUProgram::GPUProgram(const string &vsFile, + const string &fsFile, + const string &gsFile, + int inputGeometry, + int outputGeometry, + int outVertices) + :_inputGeometry(inputGeometry), + _outputGeometry(outputGeometry), + _outVertices(outVertices) { + + _vs = _fs = _gs = NULL; + + if(vsFile!="") + _vs = new GPUShader(VERT,vsFile); + + if(fsFile!="") + _fs = new GPUShader(FRAG,fsFile); + + if(gsFile!="") + _gs = new GPUShader(GEOM,gsFile); + + _programId = glCreateProgram(); + setGeometryParameters(_inputGeometry,_outputGeometry,_outVertices); + attachAndLink(); + } + +GPUProgram::~GPUProgram() { + + detach(); + + if(_vs!=NULL) { + delete _vs; + } + + if(_fs!=NULL) { + delete _fs; + } + + if(_gs!=NULL) { + delete _gs; + } + + glDeleteProgram(_programId); +} + +void GPUProgram::setGeometryParameters(int inputGeometry,int outputGeometry,int outVertices) { +#ifdef GL_EXT_geometry_shader4 + if(GL_EXT_geometry_shader4 && _gs!=NULL && _gs->id()!=0) { + glProgramParameteriEXT(_programId,GL_GEOMETRY_INPUT_TYPE_EXT,inputGeometry); + glProgramParameteriEXT(_programId,GL_GEOMETRY_OUTPUT_TYPE_EXT,outputGeometry); + glProgramParameteriEXT(_programId,GL_GEOMETRY_VERTICES_OUT_EXT,outVertices); + } +#endif +} + +void GPUProgram::attach() { + if(_vs!=NULL) { + glAttachShader(_programId,_vs->id()); + } + + if(_fs!=NULL) { + glAttachShader(_programId,_fs->id()); + } + + if(_gs!=NULL) { + glAttachShader(_programId,_gs->id()); + } +} + +void GPUProgram::detach() { + + if(_vs!=NULL) { + glDetachShader(_programId,_vs->id()); + } + + if(_fs!=NULL) { + glDetachShader(_programId,_fs->id()); + } + + if(_gs!=NULL) { + glDetachShader(_programId,_gs->id()); + } +} + +bool GPUProgram::link() { + int linked = 1; + + glLinkProgram(_programId); + + glGetObjectParameterivARB(_programId,GL_OBJECT_LINK_STATUS_ARB,&linked); + + if(linked) + return true; + + return false; +} + +bool GPUProgram::attachAndLink() { + attach(); + return link(); +} + +void GPUProgram::reload() { + + detach(); + + bool allOk = true; + if(_vs!=NULL) { + allOk = allOk && _vs->loadAndCompile(); + } + + if(_fs!=NULL) { + allOk = allOk && _fs->loadAndCompile(); + } + + if(_gs!=NULL) { + allOk = allOk && _gs->loadAndCompile(); + } + + if(!allOk){ + std::cout << "reload fail, maybe missing file" << std::endl; + } + setGeometryParameters(_inputGeometry,_outputGeometry,_outVertices); + attachAndLink(); + + // reload uniforms + for(map::iterator i=_uniformLocations.begin();i!=_uniformLocations.end();i++) { + _uniformLocations[(*i).first] = glGetUniformLocation(_programId,(*i).first.c_str()); + } + + // reload attributes + for(map::iterator i=_attributeLocations.begin();i!=_attributeLocations.end();i++) { + _uniformLocations[(*i).first] = glGetAttribLocation(_programId,(*i).first.c_str()); + } + + // free textures + _textures.clear(); +} + +void GPUProgram::addUniform(const string &uniformName) { + GLint location = glGetUniformLocation(_programId,uniformName.c_str()); + + _uniformLocations[uniformName] = location; +} + +void GPUProgram::addAttribute(const string &attributeName) { + GLint location = glGetAttribLocation(_programId,attributeName.c_str()); + + _attributeLocations[attributeName] = location; +} + +bool GPUProgram::haveShaderOfType(SHADER_TYPE type) { + + if(type==VERT) + return _vs!=NULL; + + if(type==FRAG) + return _fs!=NULL; + + if(type==GEOM) + return _gs!=NULL; + + cout << "Warning : unknown type !" << endl; + + return false; +} + +string GPUProgram::filename(SHADER_TYPE type) { + + if(type==VERT && _vs!=NULL) + return _vs->filename(); + + if(type==FRAG && _fs!=NULL) + return _fs->filename(); + + if(type==GEOM && _gs!=NULL) + return _gs->filename(); + + cout << "Warning : unknown type !" << endl; + + return ""; +} diff --git a/src/meshlabplugins/render_radiance_scaling/gpuProgram.h b/src/meshlabplugins/render_radiance_scaling/gpuProgram.h new file mode 100644 index 000000000..16d8d32b0 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/gpuProgram.h @@ -0,0 +1,404 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#ifndef GPUPROGRAM_H +#define GPUPROGRAM_H + +#include +#include +#include +#include +#include +#include + +class GPUProgram { + + public: + GPUProgram(GPUShader *vs=NULL,GPUShader *fs=NULL,GPUShader *geom=NULL, + int inputGeometry=0,int outputGeometry=0,int outVertices=0); + + GPUProgram(const std::string &vsFile="", + const std::string &fsFile="", + const std::string &gsFile="", + int inputGeometry=0, + int outputGeometry=0, + int outVertices=0); + + ~GPUProgram(); + + void addUniform(const std::string &uniformName); + void addAttribute(const std::string &attributeName); + void reload(); + + inline GLuint id() const; + bool haveShaderOfType(SHADER_TYPE type); + std::string filename(SHADER_TYPE type); + + inline void enable(); + inline void disable(); + + inline GLint getUniformLocation(const std::string &uniformName); + inline GLint getAttributeLocation(const std::string &attributeName); + + inline void setUniform1f(const std::string &uniformName,GLfloat v); + inline void setUniform2f(const std::string &uniformName,GLfloat v1,GLfloat v2); + inline void setUniform3f(const std::string &uniformName,GLfloat v1,GLfloat v2,GLfloat v3); + inline void setUniform4f(const std::string &uniformName,GLfloat v1,GLfloat v2,GLfloat v3,GLfloat v4); + inline void setUniform1f(GLint loc,GLfloat v); + inline void setUniform2f(GLint loc,GLfloat v1,GLfloat v2); + inline void setUniform3f(GLint loc,GLfloat v1,GLfloat v2,GLfloat v3); + inline void setUniform4f(GLint loc,GLfloat v1,GLfloat v2,GLfloat v3,GLfloat v4); + + inline void setUniform1i(const std::string &uniformName,GLint v); + inline void setUniform2i(const std::string &uniformName,GLint v1,GLint v2); + inline void setUniform3i(const std::string &uniformName,GLint v1,GLint v2,GLint v3); + inline void setUniform4i(const std::string &uniformName,GLint v1,GLint v2,GLint v3,GLint v4); + inline void setUniform1i(GLint loc,GLint v); + inline void setUniform2i(GLint loc,GLint v1,GLint v2); + inline void setUniform3i(GLint loc,GLint v1,GLint v2,GLint v3); + inline void setUniform4i(GLint loc,GLint v1,GLint v2,GLint v3,GLint v4); + + inline void setUniform1fv(const std::string &uniformName,GLfloat *v,GLsizei count=1); + inline void setUniform2fv(const std::string &uniformName,GLfloat *v,GLsizei count=1); + inline void setUniform3fv(const std::string &uniformName,GLfloat *v,GLsizei count=1); + inline void setUniform4fv(const std::string &uniformName,GLfloat *v,GLsizei count=1); + inline void setUniform1fv(GLint loc,GLfloat *v,GLsizei count=1); + inline void setUniform2fv(GLint loc,GLfloat *v,GLsizei count=1); + inline void setUniform3fv(GLint loc,GLfloat *v,GLsizei count=1); + inline void setUniform4fv(GLint loc,GLfloat *v,GLsizei count=1); + + inline void setUniform1iv(const std::string &uniformName,GLint *v,GLsizei count=1); + inline void setUniform2iv(const std::string &uniformName,GLint *v,GLsizei count=1); + inline void setUniform3iv(const std::string &uniformName,GLint *v,GLsizei count=1); + inline void setUniform4iv(const std::string &uniformName,GLint *v,GLsizei count=1); + inline void setUniform1iv(GLint loc,GLint *v,GLsizei count=1); + inline void setUniform2iv(GLint loc,GLint *v,GLsizei count=1); + inline void setUniform3iv(GLint loc,GLint *v,GLsizei count=1); + inline void setUniform4iv(GLint loc,GLint *v,GLsizei count=1); + + inline void setUniformMatrix2fv(const std::string &uniformName,GLfloat *v,GLsizei count=1,GLboolean transpose=false); + inline void setUniformMatrix3fv(const std::string &uniformName,GLfloat *v,GLsizei count=1,GLboolean transpose=false); + inline void setUniformMatrix4fv(const std::string &uniformName,GLfloat *v,GLsizei count=1,GLboolean transpose=false); + inline void setUniformMatrix2fv(GLint loc,GLfloat *v,GLsizei count=1,GLboolean transpose=false); + inline void setUniformMatrix3fv(GLint loc,GLfloat *v,GLsizei count=1,GLboolean transpose=false); + inline void setUniformMatrix4fv(GLint loc,GLfloat *v,GLsizei count=1,GLboolean transpose=false); + + inline void setUniformTexture(const std::string &uniformName,GLint num,GLenum type,GLuint textureName); + inline void setUniformTexture(GLint loc,GLint num,GLenum type,GLuint textureName); + + inline void setUniformBuffer(const std::string &uniformName,GLuint buffer); + inline void setUniformBuffer(GLint loc,GLuint buffer); + inline GLint getUniformBufferSize(const std::string &uniformName); + inline GLint getUniformBufferSize(GLint loc); + + protected: + void attach(); + bool link(); + bool attachAndLink(); + void detach(); + void setGeometryParameters(int inputGeometry,int outputGeometry,int outVertices); + + private: + + GPUShader* _vs; + GPUShader* _fs; + GPUShader* _gs; + GLuint _programId; + + std::map _uniformLocations; + std::map _attributeLocations; + std::map > _textures; + + int _inputGeometry; + int _outputGeometry; + int _outVertices; +}; + +inline void GPUProgram::enable() { + glUseProgramObjectARB(_programId); + + for(std::map >::iterator i=_textures.begin();i!=_textures.end();++i) { + glActiveTexture((*i).second.first); + glBindTexture((*i).second.second,(*i).first); + glEnable((*i).second.second); + } + +} + +inline void GPUProgram::disable() { + for(std::map >::reverse_iterator i=_textures.rbegin();i!=_textures.rend();++i) { + glActiveTexture((*i).second.first); + glDisable((*i).second.second); + } + + glUseProgramObjectARB(0); +} + +inline GLuint GPUProgram::id() const { + return _programId; +} + +inline void GPUProgram::setUniform1f(const std::string &uniformName,GLfloat v) { + glUniform1f(_uniformLocations[uniformName],v); +} + +inline void GPUProgram::setUniform2f(const std::string &uniformName,GLfloat v1,GLfloat v2) { + glUniform2f(_uniformLocations[uniformName],v1,v2); +} + +inline void GPUProgram::setUniform3f(const std::string &uniformName,GLfloat v1,GLfloat v2,GLfloat v3) { + glUniform3f(_uniformLocations[uniformName],v1,v2,v3); +} + +inline void GPUProgram::setUniform4f(const std::string &uniformName,GLfloat v1,GLfloat v2,GLfloat v3,GLfloat v4) { + glUniform4f(_uniformLocations[uniformName],v1,v2,v3,v4); +} + +inline void GPUProgram::setUniform1i(const std::string &uniformName,GLint v) { + glUniform1i(_uniformLocations[uniformName],v); +} + +inline void GPUProgram::setUniform2i(const std::string &uniformName,GLint v1,GLint v2) { + glUniform2i(_uniformLocations[uniformName],v1,v2); +} + +inline void GPUProgram::setUniform3i(const std::string &uniformName,GLint v1,GLint v2,GLint v3) { + glUniform3i(_uniformLocations[uniformName],v1,v2,v3); +} + +inline void GPUProgram::setUniform4i(const std::string &uniformName,GLint v1,GLint v2,GLint v3,GLint v4) { + glUniform4i(_uniformLocations[uniformName],v1,v2,v3,v4); +} + +inline void GPUProgram::setUniform1fv(const std::string &uniformName,GLfloat *v,GLsizei count) { + glUniform1fv(_uniformLocations[uniformName],count,v); +} + +inline void GPUProgram::setUniform2fv(const std::string &uniformName,GLfloat *v,GLsizei count) { + glUniform2fv(_uniformLocations[uniformName],count,v); +} + +inline void GPUProgram::setUniform3fv(const std::string &uniformName,GLfloat *v,GLsizei count) { + glUniform3fv(_uniformLocations[uniformName],count,v); +} + +inline void GPUProgram::setUniform4fv(const std::string &uniformName,GLfloat *v,GLsizei count) { + glUniform4fv(_uniformLocations[uniformName],count,v); +} + +inline void GPUProgram::setUniform1iv(const std::string &uniformName,GLint *v,GLsizei count) { + glUniform1iv(_uniformLocations[uniformName],count,v); +} + +inline void GPUProgram::setUniform2iv(const std::string &uniformName,GLint *v,GLsizei count) { + glUniform2iv(_uniformLocations[uniformName],count,v); +} + +inline void GPUProgram::setUniform3iv(const std::string &uniformName,GLint *v,GLsizei count) { + glUniform3iv(_uniformLocations[uniformName],count,v); +} + +inline void GPUProgram::setUniform4iv(const std::string &uniformName,GLint *v,GLsizei count) { + glUniform4iv(_uniformLocations[uniformName],count,v); +} + +inline void GPUProgram::setUniformMatrix2fv(const std::string &uniformName,GLfloat *v,GLsizei count,GLboolean transpose) { + glUniformMatrix2fv(_uniformLocations[uniformName],count,transpose,v); +} + +inline void GPUProgram::setUniformMatrix3fv(const std::string &uniformName,GLfloat *v,GLsizei count,GLboolean transpose) { + glUniformMatrix3fv(_uniformLocations[uniformName],count,transpose,v); +} + +inline void GPUProgram::setUniformMatrix4fv(const std::string &uniformName,GLfloat *v,GLsizei count,GLboolean transpose) { + glUniformMatrix4fv(_uniformLocations[uniformName],count,transpose,v); +} + +inline void GPUProgram::setUniformTexture(const std::string &uniformName,GLint num,GLenum type,GLuint textureName) { + GLenum textureNum; + + const std::map >::iterator it = _textures.find(textureName); + + if(it==_textures.end()) { + textureNum = GL_TEXTURE0+_textures.size(); + } else { + textureNum = (*it).second.first; + } + + glPushAttrib(GL_TEXTURE_BIT); + glActiveTexture(textureNum); + glBindTexture(type,textureName); + glEnable(type); + + glUniform1i(_uniformLocations[uniformName],num); + _textures[textureName] = std::pair(textureNum,type); + + glDisable(type); + glPopAttrib(); +} + +inline void GPUProgram::setUniform1f(GLint loc,GLfloat v) { + glUniform1f(loc,v); +} + +inline void GPUProgram::setUniform2f(GLint loc,GLfloat v1,GLfloat v2) { + glUniform2f(loc,v1,v2); +} + +inline void GPUProgram::setUniform3f(GLint loc,GLfloat v1,GLfloat v2,GLfloat v3) { + glUniform3f(loc,v1,v2,v3); +} + +inline void GPUProgram::setUniform4f(GLint loc,GLfloat v1,GLfloat v2,GLfloat v3,GLfloat v4) { + glUniform4f(loc,v1,v2,v3,v4); +} + +inline void GPUProgram::setUniform1i(GLint loc,GLint v) { + glUniform1i(loc,v); +} + +inline void GPUProgram::setUniform2i(GLint loc,GLint v1,GLint v2) { + glUniform2i(loc,v1,v2); +} + +inline void GPUProgram::setUniform3i(GLint loc,GLint v1,GLint v2,GLint v3) { + glUniform3i(loc,v1,v2,v3); +} + +inline void GPUProgram::setUniform4i(GLint loc,GLint v1,GLint v2,GLint v3,GLint v4) { + glUniform4i(loc,v1,v2,v3,v4); +} + +inline void GPUProgram::setUniform1fv(GLint loc,GLfloat *v,GLsizei count) { + glUniform1fv(loc,count,v); +} + +inline void GPUProgram::setUniform2fv(GLint loc,GLfloat *v,GLsizei count) { + glUniform2fv(loc,count,v); +} + +inline void GPUProgram::setUniform3fv(GLint loc,GLfloat *v,GLsizei count) { + glUniform3fv(loc,count,v); +} + +inline void GPUProgram::setUniform4fv(GLint loc,GLfloat *v,GLsizei count) { + glUniform4fv(loc,count,v); +} + +inline void GPUProgram::setUniform1iv(GLint loc,GLint *v,GLsizei count) { + glUniform1iv(loc,count,v); +} + +inline void GPUProgram::setUniform2iv(GLint loc,GLint *v,GLsizei count) { + glUniform2iv(loc,count,v); +} + +inline void GPUProgram::setUniform3iv(GLint loc,GLint *v,GLsizei count) { + glUniform3iv(loc,count,v); +} + +inline void GPUProgram::setUniform4iv(GLint loc,GLint *v,GLsizei count) { + glUniform4iv(loc,count,v); +} + +inline void GPUProgram::setUniformMatrix2fv(GLint loc,GLfloat *v,GLsizei count,GLboolean transpose) { + glUniformMatrix2fv(loc,count,transpose,v); +} + +inline void GPUProgram::setUniformMatrix3fv(GLint loc,GLfloat *v,GLsizei count,GLboolean transpose) { + glUniformMatrix3fv(loc,count,transpose,v); +} + +inline void GPUProgram::setUniformMatrix4fv(GLint loc,GLfloat *v,GLsizei count,GLboolean transpose) { + glUniformMatrix4fv(loc,count,transpose,v); +} + +inline void GPUProgram::setUniformTexture(GLint loc,GLint num,GLenum type,GLuint textureName) { + GLenum textureNum; + + const std::map >::iterator it = _textures.find(textureName); + + if(it==_textures.end()) { + textureNum = GL_TEXTURE0+_textures.size(); + } else { + textureNum = (*it).second.first; + } + + glPushAttrib(GL_TEXTURE_BIT); + glActiveTexture(textureNum); + glBindTexture(type,textureName); + glEnable(type); + + glUniform1i(loc,num); + _textures[textureName] = std::pair(textureNum,type); + + glDisable(type); + glPopAttrib(); +} + +inline GLint GPUProgram::getUniformLocation(const std::string &uniformName) { + return _uniformLocations[uniformName]; +} + +inline GLint GPUProgram::getAttributeLocation(const std::string &attributeName) { + return _attributeLocations[attributeName]; +} + +inline void GPUProgram::setUniformBuffer(const std::string &uniformName,GLuint buffer) { + glUniformBufferEXT(_programId,_uniformLocations[uniformName],buffer); +} + +inline void GPUProgram::setUniformBuffer(GLint loc,GLuint buffer) { + glUniformBufferEXT(_programId,loc,buffer); +} + +inline GLint GPUProgram::getUniformBufferSize(const std::string &uniformName) { + return glGetUniformBufferSizeEXT(_programId,_uniformLocations[uniformName]); +} + +inline GLint GPUProgram::getUniformBufferSize(GLint loc) { + return glGetUniformBufferSizeEXT(_programId,loc); +} + +static inline +void CheckErrorsGL(const char* location=NULL,std::ostream& ostr = std::cerr) { + + GLuint errnum; + const char *errstr; + while((errnum=glGetError())) { + ostr << " **************************************************** " << std::endl; + ostr << " Checking OpenGL Error " << std::endl; + + std::cout << " **************************************************** " << std::endl; + std::cout << " Checking OpenGL Error " << std::endl; + + errstr = reinterpret_cast(gluErrorString(errnum)); + ostr << errstr; + + if(location) ostr << " at " << location; + ostr << std::endl; + std::cout << " **************************************************** " << std::endl; + ostr << " **************************************************** " << std::endl; + } +} + +#endif // GPUPROGRAM_H diff --git a/src/meshlabplugins/render_radiance_scaling/gpuShader.cpp b/src/meshlabplugins/render_radiance_scaling/gpuShader.cpp new file mode 100644 index 000000000..ae78fbb6a --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/gpuShader.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "gpuShader.h" + +using namespace std; + +GPUShader::GPUShader(SHADER_TYPE type,const string &filename,bool printLog) + : _filename(filename), + _type(type), + _shaderId(0), + _printLog(printLog) { + _created = createShader(); + + loadAndCompile(); +} + +GPUShader::~GPUShader() { + if(_created){ + glDeleteShader(_shaderId); + } +} + +bool GPUShader::load() { + QString res; + QFile f(QString(_filename.c_str())); + + if (!f.open(QFile::ReadOnly)) { + std::cerr << "failed to load shader file " << _filename << "\n"; + return false; + } + + QTextStream stream(&f); + res = stream.readAll(); + f.close(); + + string tmp = res.toStdString(); + const char *s = tmp.c_str(); + + glShaderSource(_shaderId,1,&s,NULL); + + return true; +} + + +bool GPUShader::compile() { + glCompileShader(_shaderId); + + if(_printLog) + printInfoLog(); + + return true; +} + +void GPUShader::printInfoLog() { + int infologLength = 0; + int charsWritten = 0; + char* infolog; + + glGetObjectParameterivARB(_shaderId,GL_OBJECT_INFO_LOG_LENGTH_ARB,&infologLength); + + if(infologLength>0) { + infolog = (char*)malloc(infologLength); + glGetInfoLogARB(_shaderId,infologLength,&charsWritten,infolog); + if(infolog[0]!='\0') { + printf("InfoLog ---> %s\n",_filename.c_str()); + printf("%s",infolog); + } + free(infolog); + } +} + +bool GPUShader::loadAndCompile() { + return _created && load() && compile(); +} + +bool GPUShader::createShader() { + switch(_type) { + + case VERT: + if(GLEW_ARB_vertex_shader) + _shaderId = glCreateShader(GL_VERTEX_SHADER); + else { + cout << "Warning : vertex shader not supported !" << endl; + return false; + } + break; + + case FRAG: + if(GLEW_ARB_fragment_shader){ + _shaderId = glCreateShader(GL_FRAGMENT_SHADER); + } + else { + cout << "Warning : fragment shader not supported !" << endl; + return false; + } + break; + + case GEOM: +#ifdef GL_EXT_geometry_shader4 + if(GL_EXT_geometry_shader4){ + _shaderId = glCreateShader(GL_GEOMETRY_SHADER_EXT); + } + else { + cout << "Warning : geometry shader not supported !" << endl; + return false; + } +#else + cout << "Warning : geometry shader not supported !" << endl; + return false; +#endif + break; + + default: + cout << "Warning : unknown shader type !" << endl; + return false; + break; + } + + if(_shaderId==0) { + cout << "Warning : shader " << _filename << " is not created !" << endl; + return false; + } + + return true; +} diff --git a/src/meshlabplugins/render_radiance_scaling/gpuShader.h b/src/meshlabplugins/render_radiance_scaling/gpuShader.h new file mode 100644 index 000000000..4b687c97c --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/gpuShader.h @@ -0,0 +1,72 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#ifndef GPUSHADER_H +#define GPUSHADER_H + +#include +#include + +enum SHADER_TYPE {VERT,FRAG,GEOM}; + +class GPUShader { + + public: + + GPUShader(SHADER_TYPE type,const std::string &filename,bool printLog=true); + ~GPUShader(); + + bool load(); + bool compile(); + bool loadAndCompile(); + + inline GLuint id() const; + inline SHADER_TYPE type() const; + inline std::string filename() const; + + protected: + std::string _filename; + + private: + SHADER_TYPE _type; + + GLuint _shaderId; + bool _printLog; + bool _created; + + bool createShader(); + void printInfoLog(); +}; + +inline GLuint GPUShader::id() const { + return _shaderId; +} + +inline SHADER_TYPE GPUShader::type() const { + return _type; +} + +inline std::string GPUShader::filename() const { + return _filename; +} + +#endif // GPUSHADER diff --git a/src/meshlabplugins/render_radiance_scaling/litSpheres/ls01.png b/src/meshlabplugins/render_radiance_scaling/litSpheres/ls01.png new file mode 100644 index 0000000000000000000000000000000000000000..f4472fc9dec4f6dfda06b480ef60cece21fb7f7c G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evcLfXp{eY)dO24e2N?v9L-g8*^N%I`aQ1gKj!^Wg0G> zbt=L-^SWE95$=5+VqzJ~1{Jd5ptuc;Ov;5!T#Y#(gPY=oDfUh~H(w9N1c3hw7hS{< T9Yy0_00000NkvXXu0mjfIQ`~= literal 0 HcmV?d00001 diff --git a/src/meshlabplugins/render_radiance_scaling/litSpheres/ls02.png b/src/meshlabplugins/render_radiance_scaling/litSpheres/ls02.png new file mode 100644 index 0000000000000000000000000000000000000000..b11caf5be722ffccc7171d9434a7ff4cf2253cef GIT binary patch literal 12963 zcmV;UGF;7xP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXP~ z4=)jr_%byB000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}001BWNklq;E*^~Bo48WW{{mKhr|R(K>>1^N~Hq9 zAwR(nNQ##U;SUKe@(=SbMVaImiR}be3WHM#25j{3Lo(LWdW~kfd-~pU_F5}H_Isaw z?np*53QSd3_jKRBeeYRkt@W*MeQRwxb?TJjFa4i@sB>S5fQXtuXBC_}c|FdYIfq+b zcPrlg?sr3#uzT_Z&Ye34sDY}2h``JsB8a$WAR?%;`x<~TfU0}ziXMA=m+{~O_kl?9 z#AA=*w}1OT<6!>^?z`{4_$pKt#+cb_Bn32k$>BA)zu$U4FW*0UB^Xp;{1@!syu^#Q zy?X*@&wnd!x#br8lkfRn?Ck8|?D;zYbr%*eP_gNPYr3fJGsmwfyVxQEV@zQH_gVmS z21JCtgMB>s;DdPVk+0%+{>#U(fBAVl@Zf!bXl7i1NQ>uiH&6M!zg7k%>Y&OXQiupn zoVpHY&fS4`f6w>f+_^h&?(7`^0A^>LV3>H(go73RMN}wDWmv8LCLy@5WZyT&#K#)r z46CL?*LB$2+r#}|xF7%ZcRq#(9=H$p-T!%zx|=FDWbM)Q-~Ov_P#?0+oIQ_ocYX_g z_($%=+4FZo)rHJpFb(mOZTbIT7SY1c2Emw^8J8$CvUmeSp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F_Q1b+*R`WUJ$AD-L2!4yaeagoti0twvm)*im_8 zXI@#dLFNT9UoUCMH6XAGU{bv(aI%yWM~~zB<3}LO=%E-o4|w3ht09*oyDoX3Gj4~D zP#D+MtO<7?AAy!PI}iI6ZUBvUGN$PY^8HEb~rM$6$XgbvPYO}Ht1?Mg%#x)LO%P^`0lOEEu!0D6GQ=S=pB zMydA#A?a>8?%ad-L`vRn99_A#j7uw5uH+$AphNp7EXD?8eVxM zN;3losbay7>HS-)B$OvM;YKT(4Q}(Z!Bbp}aFf#D`xWfK4 zLE&=zUpa$9910G(Dr|-}AZ#7!as9Dl*dn0!XL^S+BN(!lS+sb~O+RmP(VKYcs24Wb zO+#5Yl#+Q;gS9HItjB1`KsPR_G5)_cXk4W44dVudJqKwB%7SA@x3GKcD2|F?t5Jg$ zdR`M$iMio|x}huiPE9~)hJK4R;z%pVvq^F%_vqr+xq++)KvyQ<>a@nB0%Q90T8&?S z{*80cmx@@pHVO`?Gn5PD75CxpU#%ysJObW5as=CbhogQYJgHL^l79|&ECxkl-i0*N z6k5kpfN1`jh>DBPsvtvd8MHVQYCvB8;l*>}dYgv=?5`)RL_D$5!}xVRWE3#nH#F3K zV?%D;A!zj^{jz*_V1V<6<9&~##$e~j0Haano2_J{V!3|@f>0`>lDCKgVscIUhEf;-G}8k6XK208Q@4~aHKOh>h}^3 z002ovPDHLkV1h*81u6gl literal 0 HcmV?d00001 diff --git a/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.cpp b/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.cpp new file mode 100644 index 000000000..37d100899 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.cpp @@ -0,0 +1,273 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#include "radianceScalingRenderer.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +#define GL_TEST_ERR \ + { \ + GLenum eCode; \ + if((eCode=glGetError())!=GL_NO_ERROR) \ + std::cerr << "OpenGL error : " << gluErrorString(eCode) << " in " << __FILE__ << " : " << __LINE__ << std::endl; \ + } + +RadianceScalingRendererPlugin::RadianceScalingRendererPlugin() + : _supported(false), + _sDialog(0), + _fbo(NULL), + _buffPass(NULL), + _rsPass(NULL), + _depthTex(NULL), + _gradTex(NULL), + _normTex(NULL), + _convexLS(NULL), + _concavLS(NULL) { + +} + +void RadianceScalingRendererPlugin::Init(QAction *, MeshDocument &, RenderMode &, QGLWidget *gla) { + if(_sDialog) { + _sDialog->close(); + delete _sDialog; + _sDialog=0; + } + + gla->makeCurrent(); + glewInit(); + + GL_TEST_ERR + + if(!GLEW_ARB_vertex_program || + !GLEW_ARB_fragment_program || + !GLEW_ARB_texture_float || + !GLEW_ARB_draw_buffers || + !GLEW_EXT_framebuffer_object) { + + _supported = false; + return; + } + + _supported = true; + _sDialog = new ShaderDialog(this,gla); + _sDialog->move(10,100); + _sDialog->show(); + + _sDialog->changeIcon(":/RadianceScalingRenderer/litSpheres/ls02.png",ShaderDialog::convex_icon); + _sDialog->changeIcon(":/RadianceScalingRenderer/litSpheres/ls01.png",ShaderDialog::concav_icon); + + createLit(":/RadianceScalingRenderer/litSpheres/ls02.png",0); + createLit(":/RadianceScalingRenderer/litSpheres/ls01.png",1); + + initFBOs(); + GL_TEST_ERR + + initShaders(); + GL_TEST_ERR +} + +void RadianceScalingRendererPlugin::Render(QAction *, MeshDocument &md, RenderMode &rm, QGLWidget *) { + checkViewport(); + + // first pass: buffers + _fbo->bind(); + glDrawBuffers(2,FramebufferObject::buffers(0)); + glClearColor(0.0,0.0,0.0,1.0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + _buffPass->enable(); + foreach(MeshModel *mp,md.meshList) { + if(mp->visible) mp->Render(rm.drawMode,rm.colorMode,rm.textureMode); + } + _buffPass->disable(); + + // second pass: descriptor, radiance scaling, lighting + FramebufferObject::unbind(); + swapToScreenMode(); + _rsPass->enable(); + drawQuad(); + _rsPass->disable(); + swapToWorldMode(); +} + +void RadianceScalingRendererPlugin::Finalize(QAction *, MeshDocument &, GLArea *) { + cleanShaders(); + cleanFBOs(); + + if(_sDialog) { + _sDialog->close(); + delete _sDialog; + _sDialog=0; + } + + if(_convexLS!=NULL) { + delete _convexLS; + _convexLS = NULL; + } + + if(_concavLS!=NULL) { + delete _concavLS; + _concavLS = NULL; + } +} + +void RadianceScalingRendererPlugin::initActionList() { + _actionList << new QAction("Radiance Scaling",this); +} + +void RadianceScalingRendererPlugin::createLit(const QString &filename,int type) { + QImage t; + QImage b; + + if(!b.load(filename)) { + return; + } + + t = QGLWidget::convertToGLFormat(b); + + if(type==0) { + if(_convexLS!=NULL) { + delete _convexLS; + _convexLS = NULL; + } + + _convexLS = new UbyteTexture2D(TextureFormat(GL_TEXTURE_2D,t.width(),t.height(),3,GL_RGBA,GL_UNSIGNED_BYTE),TextureParams(GL_LINEAR,GL_LINEAR),t.bits()); + } else { + + if(_concavLS!=NULL) { + delete _concavLS; + _concavLS = NULL; + } + + _concavLS = new UbyteTexture2D(TextureFormat(GL_TEXTURE_2D,t.width(),t.height(),3,GL_RGBA,GL_UNSIGNED_BYTE),TextureParams(GL_LINEAR,GL_LINEAR),t.bits()); + } +} + +void RadianceScalingRendererPlugin::initShaders(bool reload) { + + if(!reload) { + string path = ":/RadianceScalingRenderer/shaders/"; + _buffPass = new GPUProgram(path+"01_buffer.vs",path+"01_buffer.fs"); + _rsPass = new GPUProgram(path+"02_rs.vs" ,path+"02_rs.fs"); + GL_TEST_ERR + + _rsPass->enable(); + _rsPass->addUniform("sw"); + _rsPass->addUniform("sh"); + _rsPass->addUniform("enhancement"); + _rsPass->addUniform("transition"); + _rsPass->addUniform("enabled"); + _rsPass->addUniform("invert"); + _rsPass->addUniform("twoLS"); + _rsPass->addUniform("display"); + _rsPass->addUniform("grad"); + _rsPass->addUniform("norm"); + _rsPass->addUniform("convexLS"); + _rsPass->addUniform("concavLS"); + _rsPass->disable(); + + GL_TEST_ERR + } else { + _buffPass->reload(); + _rsPass->reload(); + GL_TEST_ERR + } + + float sw = 1.0f/(float)_w; + float sh = 1.0f/(float)_h; + + _rsPass->enable(); + _rsPass->setUniform1f("sw",sw); + _rsPass->setUniform1f("sh",sh); + _rsPass->setUniform1f("enhancement",_sDialog->getEnhancement()); + _rsPass->setUniform1f("transition",_sDialog->getTransition()); + _rsPass->setUniform1i("enabled",_sDialog->getEnable()); + _rsPass->setUniform1i("display",_sDialog->getDisplay()); + _rsPass->setUniform1i("invert",_sDialog->getInvert()); + _rsPass->setUniform1i("twoLS",_sDialog->getTwoLS()); + _rsPass->setUniformTexture("grad",0,_gradTex->format().target(),_gradTex->id()); + _rsPass->setUniformTexture("norm",1,_normTex->format().target(),_normTex->id()); + _rsPass->setUniformTexture("convexLS",2,_convexLS->format().target(),_convexLS->id()); + _rsPass->setUniformTexture("concavLS",3,_concavLS->format().target(),_concavLS->id()); + _rsPass->disable(); + GL_TEST_ERR +} + +void RadianceScalingRendererPlugin::initFBOs() { + int v[4]; + glGetIntegerv(GL_VIEWPORT,v); + _w = v[2]; + _h = v[3]; + + if(_fbo==NULL) { + GLenum filter = GL_LINEAR; + GLenum format = GL_RGBA16F_ARB; + _fbo = new FramebufferObject(); + _depthTex = new FloatTexture2D(TextureFormat(GL_TEXTURE_2D,_w,_h,GL_DEPTH_COMPONENT24,GL_DEPTH_COMPONENT,GL_FLOAT),TextureParams(filter,filter)); + _gradTex = new FloatTexture2D(TextureFormat(GL_TEXTURE_2D,_w,_h,format,GL_RGBA,GL_FLOAT),TextureParams(filter,filter)); + _normTex = new FloatTexture2D(_gradTex->format(),_gradTex->params()); + } + + _fbo->bind(); + _fbo->unattachAll(); + _depthTex->bind(); + _fbo->attachTexture(_depthTex->format().target(),_depthTex->id(),GL_DEPTH_ATTACHMENT_EXT); + _gradTex->bind(); + _fbo->attachTexture(_gradTex->format().target(),_gradTex->id(),GL_COLOR_ATTACHMENT0_EXT); + _normTex->bind(); + _fbo->attachTexture(_normTex->format().target(),_normTex->id(),GL_COLOR_ATTACHMENT1_EXT); + _fbo->isValid(); + + FramebufferObject::unbind(); +} + +void RadianceScalingRendererPlugin::cleanShaders() { + if(_buffPass!=NULL) { + delete _buffPass; + delete _rsPass; + + _buffPass = NULL; + _rsPass = NULL; + } +} + +void RadianceScalingRendererPlugin::cleanFBOs() { + if(_fbo!=NULL) { + delete _fbo; + delete _depthTex; + delete _gradTex; + delete _normTex; + + _fbo = NULL; + _depthTex = NULL; + _gradTex = NULL; + _normTex = NULL; + } +} + +Q_EXPORT_PLUGIN(RadianceScalingRendererPlugin) diff --git a/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.h b/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.h new file mode 100644 index 000000000..7fb67f0ee --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.h @@ -0,0 +1,192 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#ifndef RADIANCESCALINGRENDERER_H +#define RADIANCESCALINGRENDERER_H + +#include +#include +#include + +#include +#include +#include +#include + +#include "shaderDialog.h" +#include "gpuProgram.h" +#include "framebufferObject.h" +#include "texture2D.h" + +class RadianceScalingRendererPlugin : public QObject, public MeshRenderInterface { + Q_OBJECT + Q_INTERFACES(MeshRenderInterface) + + bool _supported; + QList _actionList; + ShaderDialog *_sDialog; + + public: + RadianceScalingRendererPlugin(); + + QList actions() { + if(_actionList.isEmpty()) initActionList(); + return _actionList; + } + + void initActionList(); + + virtual bool isSupported() {return _supported;} + virtual void Init(QAction *a, MeshDocument &m, RenderMode &rm, QGLWidget *gla); + virtual void Finalize(QAction *a, MeshDocument &m, GLArea * gla); + virtual void Render(QAction *a, MeshDocument &m, RenderMode &rm, QGLWidget *gla); + + inline void setEnable(bool enabled); + inline void setLit(bool lit); + inline void setInvert(int invert); + inline void setDisplay(int index); + inline void setEnhancement(float enhancement); + inline void setTransition(float transition); + inline void setConvexLit(const QString &filename); + inline void setConcavLit(const QString &filename); + + private: + FramebufferObject *_fbo; + GPUProgram *_buffPass; + GPUProgram *_rsPass; + FloatTexture2D *_depthTex; + FloatTexture2D *_gradTex; + FloatTexture2D *_normTex; + UbyteTexture2D *_convexLS; + UbyteTexture2D *_concavLS; + int _w,_h; + + void initShaders(bool reload=false); + void initFBOs(); + void cleanShaders(); + void cleanFBOs(); + + void createLit(const QString &filename,int type); + + inline void drawQuad(); + inline void swapToScreenMode(); + inline void swapToWorldMode(); + inline void checkViewport(); +}; + +inline void RadianceScalingRendererPlugin::swapToScreenMode() { + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glDepthMask(GL_FALSE); +} + +inline void RadianceScalingRendererPlugin::swapToWorldMode() { + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glDepthMask(GL_TRUE); +} + +inline void RadianceScalingRendererPlugin::drawQuad() { + glBegin(GL_QUADS); + + glTexCoord2f(0.0,0.0); glVertex2f(-1.0,-1.0); + glTexCoord2f(1.0,0.0); glVertex2f( 1.0,-1.0); + glTexCoord2f(1.0,1.0); glVertex2f( 1.0, 1.0); + glTexCoord2f(0.0,1.0); glVertex2f(-1.0, 1.0); + + glEnd(); +} + +inline void RadianceScalingRendererPlugin::checkViewport() { + int v[4]; + glGetIntegerv(GL_VIEWPORT,v); + + if(v[2]!=_w || v[3]!=_h) { + _w = v[2]; + _h = v[3]; + + cleanFBOs(); + initFBOs(); + initShaders(true); + } +} + +inline void RadianceScalingRendererPlugin::setEnable(bool enabled) { + _rsPass->enable(); + _rsPass->setUniform1i("enabled",enabled); + _rsPass->disable(); +} + +inline void RadianceScalingRendererPlugin::setLit(bool lit) { + _rsPass->enable(); + _rsPass->setUniform1i("lit",lit); + _rsPass->disable(); + + initShaders(false); +} + +inline void RadianceScalingRendererPlugin::setInvert(int invert) { + _rsPass->enable(); + _rsPass->setUniform1i("invert",invert); + _rsPass->disable(); +} + +inline void RadianceScalingRendererPlugin::setDisplay(int index) { + _rsPass->enable(); + _rsPass->setUniform1i("display",index); + _rsPass->disable(); + + if(index==1) { + initShaders(false); + } +} + +inline void RadianceScalingRendererPlugin::setEnhancement(float enhancement) { + _rsPass->enable(); + _rsPass->setUniform1f("enhancement",enhancement); + _rsPass->disable(); +} + +inline void RadianceScalingRendererPlugin::setTransition(float transition) { + _rsPass->enable(); + _rsPass->setUniform1f("transition",transition); + _rsPass->disable(); +} + +inline void RadianceScalingRendererPlugin::setConvexLit(const QString &filename) { + createLit(filename,0); + initShaders(false); +} + +inline void RadianceScalingRendererPlugin::setConcavLit(const QString &filename) { + createLit(filename,1); + initShaders(false); +} + +#endif + diff --git a/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.qrc b/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.qrc new file mode 100644 index 000000000..2d51674f4 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.qrc @@ -0,0 +1,10 @@ + + + shaders/01_buffer.vs + shaders/01_buffer.fs + shaders/02_rs.vs + shaders/02_rs.fs + litSpheres/ls01.png + litSpheres/ls02.png + + diff --git a/src/meshlabplugins/render_radiance_scaling/readme.txt b/src/meshlabplugins/render_radiance_scaling/readme.txt new file mode 100644 index 000000000..d670338b8 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/readme.txt @@ -0,0 +1,50 @@ +--- License Info --- + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2 of the License, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +(http://www.gnu.org/licenses/gpl.txt) for more details. + +--- References ---- + +Please, when using this tool, cite the following reference: + + +Render Radiance Scaling +Vergne Romain, Dumas Olivier +Inria +http://iparla.labri.fr/collaborations/animare + +@InProceedings{VPBGS10, + author = "Vergne, Romain and Pacanowski, Romain and Barla, Pascal and Granier, Xavier and Schlick, Christophe", + title = "Radiance Scaling for Versatile Surface Enhancement", + booktitle = "I3D '10: Proc. symposium on Interactive 3D graphics and games", + year = "2010", + publisher = "ACM", + keywords = "ANR SeARCH, ANR Animare", + url = "http://iparla.labri.fr/publications/2010/VPBGS10" +} + + + +MeshLab +Visual Computing Lab - ISTI - CNR +http://meshlab.sourceforge.net/ + +@misc{Meshlab + author = {Visual Computing Lab ISTI - CNR}, + title = {MeshLab}, + note = {http://meshlab.sourceforge.net/} +} + + +--- How To --- + +To use it lauch meshlab, open an .obj, go inside the render->shader menu and choose Radiance Scaling. +Do not forget to choose smooth shading display mode with the cylindrical icon. +That's all folks :) diff --git a/src/meshlabplugins/render_radiance_scaling/render_radiance_scaling.pro b/src/meshlabplugins/render_radiance_scaling/render_radiance_scaling.pro new file mode 100644 index 000000000..cd8887963 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/render_radiance_scaling.pro @@ -0,0 +1,13 @@ +include (../../shared.pri) + +HEADERS = textureParams.h textureFormat.h texture2D.h framebufferObject.h gpuShader.h gpuProgram.h radianceScalingRenderer.h shaderDialog.h +SOURCES = textureParams.cpp textureFormat.cpp framebufferObject.cpp gpuShader.cpp gpuProgram.cpp radianceScalingRenderer.cpp shaderDialog.cpp $$GLEWCODE + +TARGET = render_radiance_scaling +FORMS = shaderDialog.ui + +RESOURCES = radianceScalingRenderer.qrc + +QT += opengl + +# CONFIG += debug diff --git a/src/meshlabplugins/render_radiance_scaling/shaderDialog.cpp b/src/meshlabplugins/render_radiance_scaling/shaderDialog.cpp new file mode 100644 index 000000000..bedc09bf3 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/shaderDialog.cpp @@ -0,0 +1,187 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#include "shaderDialog.h" +#include "radianceScalingRenderer.h" + +using namespace std; + +ShaderDialog::ShaderDialog(RadianceScalingRendererPlugin* wrp,QGLWidget* gla,QWidget *parent) + : QDockWidget(parent), + _wrp(wrp), + _gla(gla) { + + _ui.setupUi(this); + this->setWidget(_ui.frame); + this->setFeatures(QDockWidget::AllDockWidgetFeatures); + this->setAllowedAreas(Qt::LeftDockWidgetArea); + this->setFloating(true); + + connect(_ui.enableCheckBox,SIGNAL(stateChanged(int)),this,SLOT(enableChanged(int))); + connect(_ui.invertCheckBox,SIGNAL(stateChanged(int)),this,SLOT(invertChanged(int))); + connect(_ui.displayBox,SIGNAL(currentIndexChanged(int)),this,SLOT(displayChanged(int))); + connect(_ui.enSlider,SIGNAL(valueChanged(int)),this,SLOT(enhancementChanged(int))); + connect(_ui.transitionSlider,SIGNAL(valueChanged(int)),this,SLOT(transitionChanged(int))); + connect(_ui.litCheckBox,SIGNAL(stateChanged(int)),this,SLOT(litChanged(int))); + connect(_ui.loadButton1,SIGNAL(clicked()),this,SLOT(load1Clicked())); + connect(_ui.loadButton2,SIGNAL(clicked()),this,SLOT(load2Clicked())); + + _ui.litCheckBox->hide(); + _ui.litIcon1->hide(); + _ui.litIcon2->hide(); + _ui.litLabel1->hide(); + _ui.litLabel2->hide(); + _ui.loadButton1->hide(); + _ui.loadButton2->hide(); + _ui.transitionTitle->hide(); + _ui.transitionSlider->hide(); + _ui.transitionLabel->hide(); +} + +ShaderDialog::~ShaderDialog() { + +} + +void ShaderDialog::enableChanged(int) { + bool enableChecked = (_ui.enableCheckBox->checkState()==Qt::Checked) ? true : false; + + _wrp->setEnable(enableChecked); + _gla->updateGL(); +} + +void ShaderDialog::invertChanged(int) { + (_ui.invertCheckBox->checkState()==Qt::Checked) ? _wrp->setInvert(true) : _wrp->setInvert(false); + _gla->updateGL(); +} + +void ShaderDialog::displayChanged(int index) { + if(index==1) { + // special case of lit sphere rendering + _ui.litCheckBox->show(); + _ui.litIcon1->show(); + _ui.litLabel1->show(); + _ui.loadButton1->show(); + litChanged(0); + } else { + // other cases + _ui.litCheckBox->hide(); + _ui.litIcon1->hide(); + _ui.litIcon2->hide(); + _ui.litLabel1->hide(); + _ui.litLabel2->hide(); + _ui.loadButton1->hide(); + _ui.loadButton2->hide(); + _ui.transitionTitle->hide(); + _ui.transitionSlider->hide(); + _ui.transitionLabel->hide(); + } + + _wrp->setDisplay(index); + _gla->updateGL(); +} + +void ShaderDialog::enhancementChanged(int value) { + const float scale = 100.0f; + float val = (float)value/scale; + QString s; + s.setNum(val,'f',2); + _ui.enLabel->setText(s); + _wrp->setEnhancement(val); + _gla->updateGL(); +} + +void ShaderDialog::transitionChanged(int value) { + const float scale = 100.0f; + float val = (float)value/scale; + QString s; + s.setNum(val,'f',2); + _ui.transitionLabel->setText(s); + _wrp->setTransition(val); + _gla->updateGL(); +} + +void ShaderDialog::litChanged(int) { + bool doubleLit = (_ui.litCheckBox->checkState()==Qt::Checked) ? true : false; + if(doubleLit) { + _ui.litIcon2->show(); + _ui.litLabel2->show(); + _ui.loadButton2->show(); + _ui.transitionTitle->show(); + _ui.transitionSlider->show(); + _ui.transitionLabel->show(); + _ui.litLabel1->setText("Convexities"); + } else { + _ui.litIcon2->hide(); + _ui.litLabel2->hide(); + _ui.loadButton2->hide(); + _ui.transitionTitle->hide(); + _ui.transitionSlider->hide(); + _ui.transitionLabel->hide(); + _ui.litLabel1->setText("Convexities and Concavities"); + } + + _wrp->setLit(doubleLit); + _gla->updateGL(); +} + +void ShaderDialog::changeIcon(QString path,int icon) { + if(icon!=convex_icon && icon!=concav_icon) + return; + + const int w = 128; + + QPixmap pix(path); + + pix = pix.scaledToWidth(w,Qt::SmoothTransformation); + + if(icon==convex_icon) { + _ui.litIcon1->setPixmap(pix); + } else if(icon==concav_icon) { + _ui.litIcon2->setPixmap(pix); + } +} + +void ShaderDialog::load1Clicked() { + QString filename = QFileDialog::getOpenFileName(0, QString(),QString(), + tr("Images (*.png *.xpm *.jpg *.bmp *.tif)")); + + if(filename.isNull()) + return; + + changeIcon(filename,convex_icon); + + _wrp->setConvexLit(filename); + _gla->updateGL(); +} + +void ShaderDialog::load2Clicked() { + QString filename = QFileDialog::getOpenFileName(0, QString(),QString(), + tr("Images (*.png *.xpm *.jpg *.bmp *.tif)")); + + if(filename.isNull()) + return; + + changeIcon(filename,concav_icon); + + _wrp->setConcavLit(filename); + _gla->updateGL(); +} diff --git a/src/meshlabplugins/render_radiance_scaling/shaderDialog.h b/src/meshlabplugins/render_radiance_scaling/shaderDialog.h new file mode 100644 index 000000000..d2bfc179b --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/shaderDialog.h @@ -0,0 +1,96 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#ifndef SHADERDIALOG_H +#define SHADERDIALOG_H + +#include +#include +#include +#include +#include "ui_shaderDialog.h" + +class RadianceScalingRendererPlugin; + +class ShaderDialog : public QDockWidget { + Q_OBJECT + + public: + ShaderDialog(RadianceScalingRendererPlugin* wrp,QGLWidget* gla,QWidget *parent = 0); + ~ShaderDialog(); + + void changeIcon(QString path,int icon); + + static const int convex_icon=0; + static const int concav_icon=1; + + private: + RadianceScalingRendererPlugin *_wrp; + Ui::ShaderDialogClass _ui; + QGLWidget *_gla; + + private slots: + void enableChanged(int); + void displayChanged(int); + void invertChanged(int); + void enhancementChanged(int); + void transitionChanged(int); + void litChanged(int); + void load1Clicked(); + void load2Clicked(); + + public: + inline bool getEnable() const; + inline int getDisplay() const; + inline float getEnhancement() const; + inline float getTransition() const; + inline bool getInvert() const; + inline bool getTwoLS() const; +}; + +inline bool ShaderDialog::getEnable() const { + return (_ui.enableCheckBox->checkState()==Qt::Checked); +} + +inline int ShaderDialog::getDisplay() const { + return _ui.displayBox->currentIndex(); +} + +inline float ShaderDialog::getEnhancement() const { + const float scale = 100.0f; + return (float)(_ui.enSlider->value())/scale; +} + +inline float ShaderDialog::getTransition() const { + const float scale = 100.0f; + return (float)(_ui.transitionSlider->value())/scale; +} + +inline bool ShaderDialog::getInvert() const { + return (_ui.invertCheckBox->checkState()==Qt::Checked); +} + +inline bool ShaderDialog::getTwoLS() const { + return (_ui.litCheckBox->checkState()==Qt::Checked); +} + +#endif // SHADERDIALOG_H diff --git a/src/meshlabplugins/render_radiance_scaling/shaderDialog.ui b/src/meshlabplugins/render_radiance_scaling/shaderDialog.ui new file mode 100644 index 000000000..61d3b9adc --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/shaderDialog.ui @@ -0,0 +1,257 @@ + + ShaderDialogClass + + + + 0 + 0 + 381 + 566 + + + + Form + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + Radiance Scaling parameters + + + + + + + + + Lambertian Radiance Scaling + + + + + Lit Sphere Radiance Scaling + + + + + Colored Descriptor + + + + + Grey Descriptor + + + + + + + + Display Mode: + + + + + + + Qt::LeftToRight + + + Enable Radiance Scaling + + + true + + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + Qt::LeftToRight + + + 0.5 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Enhancement: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Invert Effect + + + + + + + + + + + + + + Convexities + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + Concavities + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + Qt::LeftToRight + + + Use 2 Lit Spheres + + + true + + + + + + + Load + + + + + + + Load + + + + + + + + + + Qt::AlignCenter + + + + + + + + + + Qt::AlignCenter + + + + + + + + + + + Transition: + + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + + + + + 0.5 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + diff --git a/src/meshlabplugins/render_radiance_scaling/shaders/01_buffer.fs b/src/meshlabplugins/render_radiance_scaling/shaders/01_buffer.fs new file mode 100644 index 000000000..2b0746d31 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/shaders/01_buffer.fs @@ -0,0 +1,45 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#version 120 +#extension GL_ARB_draw_buffers : enable + +varying vec3 normal; +varying vec3 view; +varying float depth; + +void main(void) { + const float eps = 0.01; + const float foreshortening = 0.4; + + vec3 n = normalize(normal); + + float gs = n.zt) { + a = (c-t)/(1.0-t); + rgb = mix(convMin,convMax,a); + } else if(c<0.0) { + a = -c/t; + rgb = mix(plane,concMin,a); + } else { + a = c/t; + rgb = mix(plane,convMin,a); + } + + if(s<1.0) + rgb = vec3(0.2); + + return vec4(rgb,1.0); +} + +vec4 greyDescriptor(in float c, in float s) { + return vec4((c*0.5+0.5)-(1.0-s)); +} + +// **** LIT SPHERE FUNCTIONS **** +vec4 oneLitSphere(in vec3 n,in float c) { + vec4 color = texture2D(convexLS,(n.xy*0.5)+vec2(0.5)); + + return enabled ? color*warp(length(color),c) : color; +} + +vec4 twoLitSphere(in vec3 n,in float w,in vec3 h,in float c) { + const float eps = 0.2; + + vec2 coord = (n.xy*0.5)+vec2(0.5); + vec4 cconv = texture2D(convexLS,coord); + vec4 cconc = texture2D(concavLS,coord); + vec4 color = mix(cconc,cconv,smoothstep(0.5-eps,0.5+eps,curvature(w,h,transition)*0.5+0.5)); + + return enabled ? color*warp(length(color),c) : color; +} + +// **** LIGHTING COMPUTATION **** +void main(void) { + vec3 n = texture2D(norm,gl_TexCoord[0].st).xyz; + + if(n==vec3(0.0)) { + gl_FragColor = vec4(1.0); + return; + //discard; + } + + // data + loadValues(); + float w = weight(); + vec3 h = hessian(); + float c = curvature(w,h,enhancement); + vec3 l = normalize(gl_LightSource[0].position.xyz); + vec4 m = gl_FrontMaterial.diffuse; + + if(display==0) { + // lambertian lighting + float cosineTerm = max(dot(n,l),0.0); + float warpedTerm = enabled ? cosineTerm*warp(cosineTerm,c) : cosineTerm; + gl_FragColor = m*warpedTerm; + + } else if(display==1) { + // using lit spheres + if(twoLS) { + gl_FragColor = twoLitSphere(n,w,h,c); + } else { + gl_FragColor = oneLitSphere(n,c); + } + + } else if(display==2) { + // colored descriptor + gl_FragColor = coloredDescriptor(c,w); + + } else if(display==3) { + // grey descriptor + gl_FragColor = greyDescriptor(c,w); + + } +} diff --git a/src/meshlabplugins/render_radiance_scaling/shaders/02_rs.vs b/src/meshlabplugins/render_radiance_scaling/shaders/02_rs.vs new file mode 100644 index 000000000..8f4e34025 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/shaders/02_rs.vs @@ -0,0 +1,28 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#version 120 + +void main(void) { + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_Position = ftransform(); +} diff --git a/src/meshlabplugins/render_radiance_scaling/texture2D.h b/src/meshlabplugins/render_radiance_scaling/texture2D.h new file mode 100644 index 000000000..011a9616e --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/texture2D.h @@ -0,0 +1,149 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#ifndef TEXTURE_2D_H +#define TEXTURE_2D_H + +#include +#include +#include + +#include +#include "textureFormat.h" +#include "textureParams.h" + +template + class Texture2D { + public: + + Texture2D(const TextureFormat &tf=TextureFormat(), + const TextureParams &tp=TextureParams(), + T* map=NULL, + int id=-1); + + Texture2D(const Texture2D &tex); + + ~Texture2D(); + + inline GLuint id () const; + inline TextureFormat format() const; + inline TextureParams params() const; + inline void bind () const; + + protected: + GLuint _id; + TextureFormat _format; + TextureParams _params; +}; + +template +inline GLuint Texture2D::id() const { + return _id; +} + +template +inline TextureFormat Texture2D::format() const { + return _format; +} + +template +inline TextureParams Texture2D::params() const { + return _params; +} + +template +inline void Texture2D::bind() const { + + glBindTexture(_format.target(),_id); +} + +template +Texture2D::Texture2D(const Texture2D &tex) +: _id(tex.id()), + _format(tex.format()), + _params(tex.params()) { + +} + +template +Texture2D::Texture2D(const TextureFormat &tf,const TextureParams &tp,T* map,int id) +: _id(id), + _format(tf), + _params(tp) { + + assert(_format.target()==GL_TEXTURE_2D); + glEnable(GL_TEXTURE_2D); + + if(id<0 || glIsTexture(id)==GL_FALSE) { + glGenTextures(1,&_id); + } else { + _id = id; + } + + glBindTexture(_format.target(),_id); + + if(_format.mipmapmode()==TextureFormat::MIPMAP_GLU_AUTOM) { + + gluBuild2DMipmaps(_format.target(), + _format.internalformat(), + _format.width(), + _format.height(), + _format.format(), + _format.type(), + (const GLvoid *)map); + } else { + + glTexImage2D(_format.target(), + _format.level(), + _format.internalformat(), + _format.width(), + _format.height(), + _format.border(), + _format.format(), + _format.type(), + (const GLvoid *)map); + + if(_format.mipmapmode()==TextureFormat::MIPMAP_FBO_AUTOM) { + assert(map==NULL || map==0); + glGenerateMipmapEXT(_format.target()); + } + + } + + glTexParameteri(_format.target(),GL_TEXTURE_MIN_FILTER,_params.minfilter()); + glTexParameteri(_format.target(),GL_TEXTURE_MAG_FILTER,_params.maxfilter()); + glTexParameteri(_format.target(),GL_TEXTURE_WRAP_S,_params.wraps()); + glTexParameteri(_format.target(),GL_TEXTURE_WRAP_T,_params.wrapt()); + + //glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,_params.mode()); + } + +template +Texture2D::~Texture2D() { + glDeleteTextures(1,&_id); +} + +typedef Texture2D FloatTexture2D; +typedef Texture2D UbyteTexture2D; +typedef Texture2D UintTexture2D; + +#endif // TEXTURE_2D_H diff --git a/src/meshlabplugins/render_radiance_scaling/textureFormat.cpp b/src/meshlabplugins/render_radiance_scaling/textureFormat.cpp new file mode 100644 index 000000000..5c5dfbc2d --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/textureFormat.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#include "textureFormat.h" + + +TextureFormat::TextureFormat(GLenum target, + GLsizei width, + GLsizei height, + GLenum internalformat, + GLenum format, + GLenum type, + GLsizei depth, + int mipmapmode, + GLint level, + GLint border) + : _target(target), + _width(width), + _height(height), + _internalformat(internalformat), + _format(format), + _type(type), + _depth(depth), + _mipmapmode(mipmapmode), + _level(level), + _border(border) { + + + } + +TextureFormat::TextureFormat(const TextureFormat &tf) + : _target(tf.target()), + _width(tf.width()), + _height(tf.height()), + _internalformat(tf.internalformat()), + _format(tf.format()), + _type(tf.type()), + _depth(tf.depth()), + _mipmapmode(tf.mipmapmode()), + _level(tf.level()), + _border(tf.border()) { + +} + diff --git a/src/meshlabplugins/render_radiance_scaling/textureFormat.h b/src/meshlabplugins/render_radiance_scaling/textureFormat.h new file mode 100644 index 000000000..67e7189f5 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/textureFormat.h @@ -0,0 +1,85 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ + +#ifndef TEXTURE_FORMAT_H +#define TEXTURE_FORMAT_H + +#include +#include + +class TextureFormat { + public: + static const int MIPMAP_MANUAL = 0; + static const int MIPMAP_GLU_AUTOM = 1; + static const int MIPMAP_FBO_AUTOM = 2; + + TextureFormat(GLenum target = GL_TEXTURE_2D, + GLsizei width = 0, + GLsizei height = 0, + GLenum internalformat = GL_RGBA, + GLenum format = GL_RGBA, + GLenum type = GL_FLOAT, + GLsizei depth = 0, + int mipmapmode = MIPMAP_MANUAL, + GLint level = 0, + GLint border = 0); + + TextureFormat(const TextureFormat &tf); + + inline void setTarget (GLenum target ) {_target = target; } + inline void setWidth (GLsizei width ) {_width = width; } + inline void setHeight (GLsizei height ) {_height = height; } + inline void setInternalformat(GLenum internalformat) {_internalformat = internalformat;} + inline void setFormat (GLenum format ) {_format = format; } + inline void setType (GLenum type ) {_type = type; } + inline void setDepth (GLsizei depth ) {_depth = depth; } + inline void setmipmapmode (int mipmapmode ) {_mipmapmode = mipmapmode; } + inline void setLevel (GLint level ) {_level = level; } + inline void setBorder (GLint border ) {_border = border; } + + inline GLenum target () const {return _target; } + inline GLsizei width () const {return _width; } + inline GLsizei height () const {return _height; } + inline GLenum internalformat() const {return _internalformat;} + inline GLenum format () const {return _format; } + inline GLenum type () const {return _type; } + inline GLsizei depth () const {return _depth; } + inline int mipmapmode () const {return _mipmapmode; } + inline GLint level () const {return _level; } + inline GLint border () const {return _border; } + + protected: + GLenum _target; + GLsizei _width; + GLsizei _height; + GLenum _internalformat; + GLenum _format; + GLenum _type; + GLsizei _depth; + int _mipmapmode; + GLint _level; + GLint _border; +}; + + +#endif // TEXTURE_FORMAT_H diff --git a/src/meshlabplugins/render_radiance_scaling/textureParams.cpp b/src/meshlabplugins/render_radiance_scaling/textureParams.cpp new file mode 100644 index 000000000..7cf885674 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/textureParams.cpp @@ -0,0 +1,49 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#include "textureParams.h" + +TextureParams::TextureParams(GLint minfilter, + GLint maxfilter, + GLint wrapr, + GLint wraps, + GLint wrapt, + GLint mode) + : _minfilter(minfilter), + _maxfilter(maxfilter), + _wrapr(wrapr), + _wraps(wraps), + _wrapt(wrapt), + _mode(mode) { + + } + +TextureParams::TextureParams(const TextureParams &tp) + : _minfilter(tp.minfilter()), + _maxfilter(tp.maxfilter()), + _wrapr(tp.wrapr()), + _wraps(tp.wraps()), + _wrapt(tp.wrapt()), + _mode(tp.mode()) { + +} + diff --git a/src/meshlabplugins/render_radiance_scaling/textureParams.h b/src/meshlabplugins/render_radiance_scaling/textureParams.h new file mode 100644 index 000000000..92a888690 --- /dev/null +++ b/src/meshlabplugins/render_radiance_scaling/textureParams.h @@ -0,0 +1,65 @@ +/**************************************************************************** +* Render Radiance Scaling * +* Meshlab's plugin * +* * +* Copyright(C) 2010 * +* Vergne Romain, Dumas Olivier * +* INRIA - Institut Nationnal de Recherche en Informatique et Automatique * +* * +* All rights reserved. * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * +* for more details. * +* * +****************************************************************************/ +#ifndef TEXTURE_PARAMS_H +#define TEXTURE_PARAMS_H + +#include +#include + +class TextureParams { + public: + TextureParams(const TextureParams &tp); + TextureParams(GLint minfilter = GL_LINEAR, + GLint maxfilter = GL_LINEAR, + GLint wrapr = GL_CLAMP_TO_EDGE, + GLint wraps = GL_CLAMP_TO_EDGE, + GLint wrapt = GL_CLAMP_TO_EDGE, + GLint mode = GL_REPLACE); + + ~TextureParams() {} + + inline void setMinfilter(GLint minfilter) {_minfilter = minfilter;} + inline void setMaxfilter(GLint maxfilter) {_maxfilter = maxfilter;} + inline void setWrapr (GLint wrapr ) {_wrapr = wrapr; } + inline void setWraps (GLint wraps ) {_wraps = wraps; } + inline void setWrapt (GLint wrapt ) {_wrapt = wrapt; } + inline void setMode (GLint mode ) {_mode = mode; } + + inline GLint minfilter() const {return _minfilter;} + inline GLint maxfilter() const {return _maxfilter;} + inline GLint wrapr () const {return _wrapr; } + inline GLint wraps () const {return _wraps; } + inline GLint wrapt () const {return _wrapt; } + inline GLint mode () const {return _mode; } + + protected: + GLint _minfilter; + GLint _maxfilter; + GLint _wrapr; + GLint _wraps; + GLint _wrapt; + GLint _mode; +}; + + +#endif // TEXTURE_PARAMS_H