2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
// with the following modification; you may not use this file except in
|
|
|
|
// compliance with the Apache License and the following modification to it:
|
|
|
|
// Section 6. Trademarks. is deleted and replaced with:
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 6. Trademarks. This License does not grant permission to use the trade
|
|
|
|
// names, trademarks, service marks, or product names of the Licensor
|
|
|
|
// and its affiliates, except as required to comply with Section 4(c) of
|
|
|
|
// the License and to reproduce the content of the NOTICE file.
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the Apache License with the above modification is
|
|
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
// KIND, either express or implied. See the Apache License for the specific
|
|
|
|
// language governing permissions and limitations under the Apache License.
|
2012-08-04 02:51:27 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#ifndef OSD_GL_PTEX_TEXTURE_H
|
|
|
|
#define OSD_GL_PTEX_TEXTURE_H
|
2012-08-04 02:51:27 +00:00
|
|
|
|
|
|
|
#include "../version.h"
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#include "../osd/nonCopyable.h"
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2013-06-10 22:54:40 +00:00
|
|
|
#include "../osd/opengl.h"
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
class PtexTexture;
|
|
|
|
|
|
|
|
namespace OpenSubdiv {
|
|
|
|
namespace OPENSUBDIV_VERSION {
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
/// OsdGLPTexture : implements simple support for ptex textures
|
|
|
|
///
|
|
|
|
/// The current implementation declares _texels as a GL_TEXTURE_2D_ARRAY of
|
|
|
|
/// n pages of a resolution that matches that of the largest face in the PTex file.
|
|
|
|
///
|
|
|
|
/// Two GL_TEXTURE_BUFFER constructs are used
|
|
|
|
/// as lookup tables :
|
|
|
|
/// * _pages stores the array index in which a given face is located
|
|
|
|
/// * _layout stores 4 float coordinates : top-left corner and width/height for each face
|
|
|
|
///
|
|
|
|
/// GLSL fragments use gl_PrimitiveID and gl_TessCoords to access the _pages and _layout
|
|
|
|
/// indirection tables, which provide then texture coordinates for the texels stored in
|
|
|
|
/// the _texels texture array.
|
|
|
|
///
|
|
|
|
/// Hbr provides per-face support for a ptex face indexing scheme. OsdGLDrawContext
|
|
|
|
/// class provides ptex face index lookup table as a texture buffer object that
|
|
|
|
/// can be accessed by GLSL shaders.
|
|
|
|
///
|
|
|
|
class OsdGLPtexTexture : OsdNonCopyable<OsdGLPtexTexture> {
|
2012-08-04 02:51:27 +00:00
|
|
|
public:
|
2012-12-11 01:15:13 +00:00
|
|
|
static OsdGLPtexTexture * Create(PtexTexture * reader,
|
|
|
|
unsigned long int targetMemory = 0,
|
|
|
|
int gutterWidth = 0,
|
|
|
|
int pageMargin = 0);
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
/// Returns the texture buffer containing the lookup table associate each ptex
|
|
|
|
/// face index with its 3D texture page in the texels texture array.
|
2012-08-04 02:51:27 +00:00
|
|
|
GLuint GetPagesTextureBuffer() const { return _pages; }
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
/// Returns the texture buffer containing the layout of the ptex faces in the
|
|
|
|
/// texels texture array.
|
2012-08-04 02:51:27 +00:00
|
|
|
GLuint GetLayoutTextureBuffer() const { return _layout; }
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
/// Returns the texels texture array.
|
2012-08-04 02:51:27 +00:00
|
|
|
GLuint GetTexelsTexture() const { return _texels; }
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
~OsdGLPtexTexture();
|
2012-08-04 02:51:27 +00:00
|
|
|
|
|
|
|
private:
|
2012-12-11 01:15:13 +00:00
|
|
|
OsdGLPtexTexture();
|
2012-08-04 02:51:27 +00:00
|
|
|
|
|
|
|
GLsizei _width, // widht / height / depth of the 3D texel buffer
|
|
|
|
_height,
|
|
|
|
_depth;
|
|
|
|
|
|
|
|
GLint _format; // texel color format
|
|
|
|
|
|
|
|
GLuint _pages, // per-face page indices into the texel array
|
|
|
|
_layout, // per-face lookup table (vec4 : top-left corner & width / height)
|
|
|
|
_texels; // texel data
|
|
|
|
};
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
} // end namespace OPENSUBDIV_VERSION
|
2012-08-04 02:51:27 +00:00
|
|
|
using namespace OPENSUBDIV_VERSION;
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
} // end namespace OpenSubdiv
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
#endif // OSD_GL_PTEX_TEXTURE_H
|