mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-16 17:44:36 +00:00
add a new radiance scaling render plugin
This commit is contained in:
parent
1ec060fd59
commit
b6d4cb42aa
237
src/meshlabplugins/render_radiance_scaling/framebufferObject.cpp
Normal file
237
src/meshlabplugins/render_radiance_scaling/framebufferObject.cpp
Normal file
@ -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 <iostream>
|
||||
#include <assert.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
std::vector<GLenum> _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<nb_attachments;i++)
|
||||
unattach(GL_COLOR_ATTACHMENT0_EXT+i);
|
||||
}
|
||||
|
||||
GLint FramebufferObject::getMaxColorAttachments() {
|
||||
GLint max_attach = 0;
|
||||
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_attach);
|
||||
return max_attach;
|
||||
}
|
||||
|
||||
void FramebufferObject::unbindCurrentBindThis() {
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT,¤t_fbo_id);
|
||||
if(fbo_id != (GLuint)current_fbo_id)
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,fbo_id);
|
||||
}
|
||||
|
||||
void FramebufferObject::unbindThisBindCurrent() {
|
||||
if(fbo_id != (GLuint)current_fbo_id)
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,(GLuint)current_fbo_id);
|
||||
}
|
||||
|
||||
bool FramebufferObject::isValid() {
|
||||
unbindCurrentBindThis();
|
||||
|
||||
bool res = false;
|
||||
|
||||
GLenum status;
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
switch(status){
|
||||
case GL_FRAMEBUFFER_COMPLETE_EXT: // Everything's OK
|
||||
res = true;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
|
||||
cerr << "glift::CheckFramebufferStatus() ERROR:\n\t"
|
||||
<< "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\n";
|
||||
res = false;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
|
||||
cerr << "glift::CheckFramebufferStatus() ERROR:\n\t"
|
||||
<< "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\n";
|
||||
res = false;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
|
||||
cerr << "glift::CheckFramebufferStatus() ERROR:\n\t"
|
||||
<< "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\n";
|
||||
res = false;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
|
||||
cerr << "glift::CheckFramebufferStatus() ERROR:\n\t"
|
||||
<< "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\n";
|
||||
res = false;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
|
||||
cerr << "glift::CheckFramebufferStatus() ERROR:\n\t"
|
||||
<< "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\n";
|
||||
res = false;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
|
||||
cerr << "glift::CheckFramebufferStatus() ERROR:\n\t"
|
||||
<< "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\n";
|
||||
res = false;
|
||||
break;
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
|
||||
cerr << "glift::CheckFramebufferStatus() ERROR:\n\t"
|
||||
<< "GL_FRAMEBUFFER_UNSUPPORTED_EXT\n";
|
||||
res = false;
|
||||
break;
|
||||
default:
|
||||
cerr << "glift::CheckFramebufferStatus() ERROR:\n\t"
|
||||
<< "Unknown ERROR\n";
|
||||
res = false;
|
||||
}
|
||||
|
||||
unbindThisBindCurrent();
|
||||
return res;
|
||||
}
|
||||
|
||||
GLenum FramebufferObject::getAttachedType(GLenum attachment) {
|
||||
// GL_RENDERBUFFER_EXT or GL_TEXTURE
|
||||
unbindCurrentBindThis();
|
||||
|
||||
GLint type = 0;
|
||||
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
|
||||
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT,
|
||||
&type);
|
||||
unbindThisBindCurrent();
|
||||
|
||||
return GLenum(type);
|
||||
}
|
||||
|
||||
GLuint FramebufferObject::getAttachedId(GLenum attachment) {
|
||||
unbindCurrentBindThis();
|
||||
|
||||
GLint id = 0;
|
||||
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
|
||||
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT,
|
||||
&id);
|
||||
unbindThisBindCurrent();
|
||||
|
||||
return GLuint(id);
|
||||
}
|
||||
|
||||
GLint FramebufferObject::getAttachedMipLevel(GLenum attachment) {
|
||||
unbindCurrentBindThis();
|
||||
|
||||
GLint level = 0;
|
||||
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
|
||||
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT,
|
||||
&level);
|
||||
unbindThisBindCurrent();
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
GLint FramebufferObject::getAttachedCubeFace(GLenum attachment) {
|
||||
unbindCurrentBindThis();
|
||||
|
||||
GLint level = 0;
|
||||
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
|
||||
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT,
|
||||
&level);
|
||||
unbindThisBindCurrent();
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
GLint FramebufferObject::getAttachedZSlice(GLenum attachment) {
|
||||
unbindCurrentBindThis();
|
||||
|
||||
GLint slice = 0;
|
||||
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
|
||||
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT,
|
||||
&slice);
|
||||
unbindThisBindCurrent();
|
||||
|
||||
return slice;
|
||||
}
|
||||
|
||||
GLenum *FramebufferObject::buffers(unsigned int i) {
|
||||
if(_buffers.empty()) {
|
||||
for(int j=0;j<getMaxColorAttachments();++j) {
|
||||
_buffers.push_back(GL_COLOR_ATTACHMENT0_EXT+j);
|
||||
}
|
||||
}
|
||||
|
||||
assert((int)i<getMaxColorAttachments());
|
||||
|
||||
return &(_buffers[i]);
|
||||
}
|
||||
|
||||
@ -0,0 +1,77 @@
|
||||
/****************************************************************************
|
||||
* 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 FRAMEBUFFER_OBJECT
|
||||
#define FRAMEBUFFER_OBJECT
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include <vector>
|
||||
|
||||
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
|
||||
340
src/meshlabplugins/render_radiance_scaling/gpl.txt
Normal file
340
src/meshlabplugins/render_radiance_scaling/gpl.txt
Normal file
@ -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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.
|
||||
|
||||
<signature of Ty Coon>, 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.
|
||||
224
src/meshlabplugins/render_radiance_scaling/gpuProgram.cpp
Normal file
224
src/meshlabplugins/render_radiance_scaling/gpuProgram.cpp
Normal file
@ -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 <iostream>
|
||||
|
||||
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<string,GLint>::iterator i=_uniformLocations.begin();i!=_uniformLocations.end();i++) {
|
||||
_uniformLocations[(*i).first] = glGetUniformLocation(_programId,(*i).first.c_str());
|
||||
}
|
||||
|
||||
// reload attributes
|
||||
for(map<string,GLint>::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 "";
|
||||
}
|
||||
404
src/meshlabplugins/render_radiance_scaling/gpuProgram.h
Normal file
404
src/meshlabplugins/render_radiance_scaling/gpuProgram.h
Normal file
@ -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 <GL/glew.h>
|
||||
#include <iostream>
|
||||
#include <gpuShader.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
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<std::string,GLint> _uniformLocations;
|
||||
std::map<std::string,GLint> _attributeLocations;
|
||||
std::map<GLuint,std::pair<GLenum,GLenum> > _textures;
|
||||
|
||||
int _inputGeometry;
|
||||
int _outputGeometry;
|
||||
int _outVertices;
|
||||
};
|
||||
|
||||
inline void GPUProgram::enable() {
|
||||
glUseProgramObjectARB(_programId);
|
||||
|
||||
for(std::map<GLuint,std::pair<GLenum,GLenum> >::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<GLuint,std::pair<GLenum,GLenum> >::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<GLuint,std::pair<GLenum,GLenum> >::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<GLenum,GLenum>(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<GLuint,std::pair<GLenum,GLenum> >::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<GLenum,GLenum>(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<const char *>(gluErrorString(errnum));
|
||||
ostr << errstr;
|
||||
|
||||
if(location) ostr << " at " << location;
|
||||
ostr << std::endl;
|
||||
std::cout << " **************************************************** " << std::endl;
|
||||
ostr << " **************************************************** " << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GPUPROGRAM_H
|
||||
156
src/meshlabplugins/render_radiance_scaling/gpuShader.cpp
Normal file
156
src/meshlabplugins/render_radiance_scaling/gpuShader.cpp
Normal file
@ -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 <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <QtGui>
|
||||
#include <QTextStream>
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
|
||||
#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;
|
||||
}
|
||||
72
src/meshlabplugins/render_radiance_scaling/gpuShader.h
Normal file
72
src/meshlabplugins/render_radiance_scaling/gpuShader.h
Normal file
@ -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 <GL/glew.h>
|
||||
#include <string>
|
||||
|
||||
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
|
||||
BIN
src/meshlabplugins/render_radiance_scaling/litSpheres/ls01.png
Normal file
BIN
src/meshlabplugins/render_radiance_scaling/litSpheres/ls01.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
src/meshlabplugins/render_radiance_scaling/litSpheres/ls02.png
Normal file
BIN
src/meshlabplugins/render_radiance_scaling/litSpheres/ls02.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@ -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 <QtGui>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <QGLWidget>
|
||||
#include <QTextStream>
|
||||
#include <QResource>
|
||||
|
||||
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)
|
||||
@ -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 <GL/glew.h>
|
||||
#include <common/meshmodel.h>
|
||||
#include <common/interfaces.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QAction>
|
||||
#include <QString>
|
||||
#include <map>
|
||||
|
||||
#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<QAction *> _actionList;
|
||||
ShaderDialog *_sDialog;
|
||||
|
||||
public:
|
||||
RadianceScalingRendererPlugin();
|
||||
|
||||
QList<QAction *> 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
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/RadianceScalingRenderer">
|
||||
<file>shaders/01_buffer.vs</file>
|
||||
<file>shaders/01_buffer.fs</file>
|
||||
<file>shaders/02_rs.vs</file>
|
||||
<file>shaders/02_rs.fs</file>
|
||||
<file>litSpheres/ls01.png</file>
|
||||
<file>litSpheres/ls02.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
50
src/meshlabplugins/render_radiance_scaling/readme.txt
Normal file
50
src/meshlabplugins/render_radiance_scaling/readme.txt
Normal file
@ -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 :)
|
||||
@ -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
|
||||
187
src/meshlabplugins/render_radiance_scaling/shaderDialog.cpp
Normal file
187
src/meshlabplugins/render_radiance_scaling/shaderDialog.cpp
Normal file
@ -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();
|
||||
}
|
||||
96
src/meshlabplugins/render_radiance_scaling/shaderDialog.h
Normal file
96
src/meshlabplugins/render_radiance_scaling/shaderDialog.h
Normal file
@ -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 <GL/glew.h>
|
||||
#include <QtGui>
|
||||
#include <QGLWidget>
|
||||
#include <QtGui/QDockWidget>
|
||||
#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
|
||||
257
src/meshlabplugins/render_radiance_scaling/shaderDialog.ui
Normal file
257
src/meshlabplugins/render_radiance_scaling/shaderDialog.ui
Normal file
@ -0,0 +1,257 @@
|
||||
<ui version="4.0" >
|
||||
<class>ShaderDialogClass</class>
|
||||
<widget class="QWidget" name="ShaderDialogClass" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>381</width>
|
||||
<height>566</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<item>
|
||||
<widget class="QFrame" name="frame" >
|
||||
<property name="frameShape" >
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow" >
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>Radiance Scaling parameters</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3" >
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="2" column="1" >
|
||||
<widget class="QComboBox" name="displayBox" >
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Lambertian Radiance Scaling</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Lit Sphere Radiance Scaling</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Colored Descriptor</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text" >
|
||||
<string>Grey Descriptor</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>Display Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QCheckBox" name="enableCheckBox" >
|
||||
<property name="layoutDirection" >
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Enable Radiance Scaling</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QSlider" name="enSlider" >
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2" >
|
||||
<widget class="QLabel" name="enLabel" >
|
||||
<property name="layoutDirection" >
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>0.5</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="label_2" >
|
||||
<property name="text" >
|
||||
<string>Enhancement:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" >
|
||||
<spacer name="horizontalSpacer_2" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QCheckBox" name="invertCheckBox" >
|
||||
<property name="text" >
|
||||
<string>Invert Effect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3" >
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="litLabel1" >
|
||||
<property name="text" >
|
||||
<string>Convexities</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLabel" name="litLabel2" >
|
||||
<property name="text" >
|
||||
<string>Concavities</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignHCenter|Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QCheckBox" name="litCheckBox" >
|
||||
<property name="layoutDirection" >
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Use 2 Lit Spheres</string>
|
||||
</property>
|
||||
<property name="checked" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QPushButton" name="loadButton1" >
|
||||
<property name="text" >
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QPushButton" name="loadButton2" >
|
||||
<property name="text" >
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="litIcon1" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLabel" name="litIcon2" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="transitionTitle" >
|
||||
<property name="text" >
|
||||
<string>Transition:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="transitionSlider" >
|
||||
<property name="maximum" >
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="transitionLabel" >
|
||||
<property name="text" >
|
||||
<string>0.5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -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.z<eps ? 1.0/eps : 1.0/n.z;
|
||||
|
||||
gs = pow(gs,foreshortening);
|
||||
|
||||
float gx = -n.x*gs;
|
||||
float gy = -n.y*gs;
|
||||
|
||||
gl_FragData[0] = vec4(gx,gy,depth,1.0);
|
||||
gl_FragData[1] = vec4(n,depth);
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
/****************************************************************************
|
||||
* 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
|
||||
|
||||
varying vec3 normal;
|
||||
varying vec3 view;
|
||||
varying float depth;
|
||||
|
||||
void main() {
|
||||
view = -(gl_ModelViewMatrix*gl_Vertex).xyz;
|
||||
normal = gl_NormalMatrix*gl_Normal;
|
||||
depth = log(-(gl_ModelViewMatrix*gl_Vertex).z);
|
||||
|
||||
gl_Position = ftransform();
|
||||
}
|
||||
231
src/meshlabplugins/render_radiance_scaling/shaders/02_rs.fs
Normal file
231
src/meshlabplugins/render_radiance_scaling/shaders/02_rs.fs
Normal file
@ -0,0 +1,231 @@
|
||||
/****************************************************************************
|
||||
* 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_EXT_gpu_shader4 : enable
|
||||
|
||||
uniform sampler2D grad; // (gx,gy,depth,1.0)
|
||||
uniform sampler2D norm; // (nx,ny,nz,depth)
|
||||
uniform float sw;
|
||||
uniform float sh;
|
||||
uniform float enhancement;
|
||||
uniform float transition;
|
||||
uniform bool enabled;
|
||||
uniform bool invert;
|
||||
uniform int display;
|
||||
uniform bool twoLS;
|
||||
uniform sampler2D convexLS;
|
||||
uniform sampler2D concavLS;
|
||||
|
||||
// **** GRADIENT DATA ****
|
||||
// |A|B|C|
|
||||
// |D|X|E|
|
||||
// |F|G|H|
|
||||
vec4 X,A,B,C,D,E,F,G,H;
|
||||
|
||||
// **** UTIL FUNCTIONS ****
|
||||
void loadValues() {
|
||||
float xc = gl_TexCoord[0].s;
|
||||
float xm = gl_TexCoord[0].s-sw;
|
||||
float xp = gl_TexCoord[0].s+sw;
|
||||
|
||||
float yc = gl_TexCoord[0].t;
|
||||
float ym = gl_TexCoord[0].t-sh;
|
||||
float yp = gl_TexCoord[0].t+sh;
|
||||
|
||||
X = texture2D(grad,vec2(xc,yc));
|
||||
A = texture2D(grad,vec2(xm,yp));
|
||||
B = texture2D(grad,vec2(xc,yp));
|
||||
C = texture2D(grad,vec2(xp,yp));
|
||||
D = texture2D(grad,vec2(xm,yc));
|
||||
E = texture2D(grad,vec2(xp,yc));
|
||||
F = texture2D(grad,vec2(xm,ym));
|
||||
G = texture2D(grad,vec2(xc,ym));
|
||||
H = texture2D(grad,vec2(xp,ym));
|
||||
}
|
||||
|
||||
vec3 hsvToRgb(in float h,in float s,in float v) {
|
||||
vec3 color;
|
||||
int hi = int(floor(h/60.0))%6;
|
||||
float f = h/60.0 - floor(h/60.0);
|
||||
float p = v*(1.0-s);
|
||||
float q = v*(1.0-f*s);
|
||||
float t = v*(1.0-(1.0-f)*s);
|
||||
|
||||
if(hi==0) color = vec3(v,t,p);
|
||||
else if(hi==1) color = vec3(q,v,p);
|
||||
else if(hi==2) color = vec3(p,v,t);
|
||||
else if(hi==3) color = vec3(p,q,v);
|
||||
else if(hi==4) color = vec3(t,p,v);
|
||||
else color = vec3(v,p,q);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
float tanh(in float c, in float en) {
|
||||
float cmax = en*15.0;
|
||||
const float tanhmax = 3.11622;
|
||||
|
||||
float x = ((c*cmax*1.0)/tanhmax);
|
||||
float e = exp(-2.0*x);
|
||||
float t = clamp((1.0-e)/(1.0+e),-1.0,1.0);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
// **** WARPING FUNCTION ****
|
||||
float warp(in float impfunc,in float beta) {
|
||||
const float alpha = 0.1;
|
||||
float expbeta = exp(-beta);
|
||||
return (alpha*expbeta+impfunc*(1.0-alpha-alpha*expbeta)) / (alpha+impfunc*(expbeta-alpha-alpha*expbeta));
|
||||
}
|
||||
|
||||
// **** WEIGHT FUNCTIONS ****
|
||||
float silhouetteWeight(in float s) {
|
||||
const float ts = 0.07;
|
||||
const float t2 = 0.9+ts;
|
||||
const float t1 = t2-0.01;
|
||||
|
||||
return smoothstep(t1,t2,max(1.0-s,0.9));
|
||||
}
|
||||
|
||||
float weight() {
|
||||
return (silhouetteWeight(abs(A.z-X.z)) +
|
||||
silhouetteWeight(abs(B.z-X.z)) +
|
||||
silhouetteWeight(abs(C.z-X.z)) +
|
||||
silhouetteWeight(abs(D.z-X.z)) +
|
||||
silhouetteWeight(abs(E.z-X.z)) +
|
||||
silhouetteWeight(abs(F.z-X.z)) +
|
||||
silhouetteWeight(abs(G.z-X.z)) +
|
||||
silhouetteWeight(abs(H.z-X.z)))/8.0;
|
||||
}
|
||||
|
||||
// **** CURVATURE FUNCTIONS ****
|
||||
vec3 hessian() {
|
||||
float xx = E.x-D.x;
|
||||
float xy = E.y-D.y;
|
||||
float yx = B.x-G.x;
|
||||
float yy = B.y-G.y;
|
||||
|
||||
return vec3(xx,yy,(xy+yx)/2.0);
|
||||
}
|
||||
|
||||
float curvature(in float w, in vec3 h, in float e) {
|
||||
float c = tanh(-(h.x+h.y)/2.0,e);
|
||||
return invert ? -c*max(w-0.5,0.0) : c*max(w-0.5,0.0);
|
||||
}
|
||||
|
||||
// **** DESCRIPTOR FUNCTIONS ****
|
||||
vec4 coloredDescriptor(in float c, in float s) {
|
||||
vec3 rgb;
|
||||
vec3 convMax = vec3(0.1,0.1,0.8);
|
||||
vec3 convMin = vec3(0.2,0.2,0.6);
|
||||
vec3 concMax = vec3(0.8,0.1,0.1);
|
||||
vec3 concMin = vec3(0.6,0.2,0.2);
|
||||
vec3 plane = vec3(0.7,0.7,0.2);
|
||||
float t = 0.02;
|
||||
float a;
|
||||
|
||||
if(c<-t) {
|
||||
a = (-c-t)/(1.0-t);
|
||||
rgb = mix(concMin,concMax,a);
|
||||
} else if(c>t) {
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
28
src/meshlabplugins/render_radiance_scaling/shaders/02_rs.vs
Normal file
28
src/meshlabplugins/render_radiance_scaling/shaders/02_rs.vs
Normal file
@ -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();
|
||||
}
|
||||
149
src/meshlabplugins/render_radiance_scaling/texture2D.h
Normal file
149
src/meshlabplugins/render_radiance_scaling/texture2D.h
Normal file
@ -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 <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
#include <string>
|
||||
#include "textureFormat.h"
|
||||
#include "textureParams.h"
|
||||
|
||||
template<typename T = float>
|
||||
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<typename T>
|
||||
inline GLuint Texture2D<T>::id() const {
|
||||
return _id;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline TextureFormat Texture2D<T>::format() const {
|
||||
return _format;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline TextureParams Texture2D<T>::params() const {
|
||||
return _params;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void Texture2D<T>::bind() const {
|
||||
|
||||
glBindTexture(_format.target(),_id);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Texture2D<T>::Texture2D(const Texture2D<T> &tex)
|
||||
: _id(tex.id()),
|
||||
_format(tex.format()),
|
||||
_params(tex.params()) {
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Texture2D<T>::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<typename T>
|
||||
Texture2D<T>::~Texture2D() {
|
||||
glDeleteTextures(1,&_id);
|
||||
}
|
||||
|
||||
typedef Texture2D<float> FloatTexture2D;
|
||||
typedef Texture2D<unsigned char> UbyteTexture2D;
|
||||
typedef Texture2D<unsigned int> UintTexture2D;
|
||||
|
||||
#endif // TEXTURE_2D_H
|
||||
63
src/meshlabplugins/render_radiance_scaling/textureFormat.cpp
Normal file
63
src/meshlabplugins/render_radiance_scaling/textureFormat.cpp
Normal file
@ -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()) {
|
||||
|
||||
}
|
||||
|
||||
85
src/meshlabplugins/render_radiance_scaling/textureFormat.h
Normal file
85
src/meshlabplugins/render_radiance_scaling/textureFormat.h
Normal file
@ -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 <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
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
|
||||
49
src/meshlabplugins/render_radiance_scaling/textureParams.cpp
Normal file
49
src/meshlabplugins/render_radiance_scaling/textureParams.cpp
Normal file
@ -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()) {
|
||||
|
||||
}
|
||||
|
||||
65
src/meshlabplugins/render_radiance_scaling/textureParams.h
Normal file
65
src/meshlabplugins/render_radiance_scaling/textureParams.h
Normal file
@ -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 <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
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
|
||||
Loading…
x
Reference in New Issue
Block a user