2010-11-06 02:34:34 +00:00
// Copyright (c) 2009-2011 Ignacio Castano <castano@gmail.com>
// Copyright (c) 2007-2009 NVIDIA Corporation -- Ignacio Castano <icastano@nvidia.com>
2007-05-17 00:11:38 +00:00
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
2010-03-16 22:37:25 +00:00
# pragma once
2010-05-31 08:13:23 +00:00
# ifndef NVTT_H
# define NVTT_H
2007-05-17 00:11:38 +00:00
// Function linkage
# if NVTT_SHARED
2008-01-07 19:08:17 +00:00
# if defined _WIN32 || defined WIN32 || defined __NT__ || defined __WIN32__ || defined __MINGW32__
2010-11-03 18:31:16 +00:00
# ifdef NVTT_EXPORTS
# define NVTT_API __declspec(dllexport)
# else
# define NVTT_API __declspec(dllimport)
# endif
2008-01-07 19:08:17 +00:00
# endif
# if defined __GNUC__ >= 4
2010-11-03 18:31:16 +00:00
# ifdef NVTT_EXPORTS
# define NVTT_API __attribute__((visibility("default")))
# endif
2007-05-17 00:11:38 +00:00
# endif
2008-01-07 19:08:17 +00:00
# endif // NVTT_SHARED
# if !defined NVTT_API
2010-11-03 18:31:16 +00:00
# define NVTT_API
2007-05-17 00:11:38 +00:00
# endif
2010-08-31 01:39:08 +00:00
# define NVTT_VERSION 20100
2008-02-05 00:28:13 +00:00
2009-01-05 10:17:06 +00:00
# define NVTT_FORBID_COPY(Class) \
2010-11-03 18:31:16 +00:00
private : \
Class ( const Class & ) ; \
void operator = ( const Class & ) ; \
public :
2009-01-05 10:17:06 +00:00
# define NVTT_DECLARE_PIMPL(Class) \
2010-11-03 18:31:16 +00:00
public : \
struct Private ; \
Private & m
2008-02-28 21:14:40 +00:00
2007-12-17 03:51:34 +00:00
2007-05-17 00:11:38 +00:00
// Public interface.
namespace nvtt
{
2010-11-03 18:31:16 +00:00
// Forward declarations.
2011-09-28 16:40:59 +00:00
struct Surface ;
struct CubeSurface ;
2010-11-03 18:31:16 +00:00
2011-09-28 18:44:18 +00:00
2011-09-29 23:14:18 +00:00
// Supported compression formats.
2011-09-28 18:44:18 +00:00
// @@ I wish I had distinguished between "formats" and compressors.
// That is, 'DXT1' is a format 'DXT1a' and 'DXT1n' are DXT1 compressors.
// That is, 'DXT3' is a format 'DXT3n' is a DXT3 compressor.
// Having multiple enums for the same ids only creates confusion. Clean this up.
2010-11-03 18:31:16 +00:00
enum Format
{
// No compression.
Format_RGB ,
Format_RGBA = Format_RGB ,
// DX9 formats.
Format_DXT1 ,
Format_DXT1a , // DXT1 with binary alpha.
Format_DXT3 ,
Format_DXT5 ,
Format_DXT5n , // Compressed HILO: R=1, G=y, B=0, A=x
// DX10 formats.
Format_BC1 = Format_DXT1 ,
Format_BC1a = Format_DXT1a ,
Format_BC2 = Format_DXT3 ,
Format_BC3 = Format_DXT5 ,
Format_BC3n = Format_DXT5n ,
Format_BC4 , // ATI1
Format_BC5 , // 3DC, ATI2
Format_DXT1n , // Not supported on CPU yet.
Format_CTX1 , // Not supported on CPU yet.
Format_BC6 , // Not supported yet.
Format_BC7 , // Not supported yet.
2012-04-30 23:03:44 +00:00
Format_DXT1_Luma ,
2010-11-03 18:31:16 +00:00
} ;
2011-09-29 23:14:18 +00:00
// Pixel types. These basically indicate how the output should be interpreted, but do not have any influence over the input. They are only relevant in RGBA mode.
2010-11-03 18:31:16 +00:00
enum PixelType
{
PixelType_UnsignedNorm = 0 ,
PixelType_SignedNorm = 1 , // Not supported yet.
PixelType_UnsignedInt = 2 , // Not supported yet.
PixelType_SignedInt = 3 , // Not supported yet.
PixelType_Float = 4 ,
PixelType_UnsignedFloat = 5 ,
} ;
2011-09-29 23:14:18 +00:00
// Quality modes.
2010-11-03 18:31:16 +00:00
enum Quality
{
Quality_Fastest ,
Quality_Normal ,
Quality_Production ,
Quality_Highest ,
} ;
2011-09-29 23:14:18 +00:00
// DXT decoder.
2011-02-28 08:27:24 +00:00
enum Decoder
{
Decoder_D3D10 ,
Decoder_D3D9 ,
Decoder_NV5x ,
2011-09-29 23:14:18 +00:00
//Decoder_RSX, // To take advantage of DXT5 bug.
2011-02-28 08:27:24 +00:00
} ;
2011-09-29 23:14:18 +00:00
// Compression options. This class describes the desired compression format and other compression settings.
2010-11-03 18:31:16 +00:00
struct CompressionOptions
{
NVTT_FORBID_COPY ( CompressionOptions ) ;
NVTT_DECLARE_PIMPL ( CompressionOptions ) ;
NVTT_API CompressionOptions ( ) ;
NVTT_API ~ CompressionOptions ( ) ;
NVTT_API void reset ( ) ;
NVTT_API void setFormat ( Format format ) ;
NVTT_API void setQuality ( Quality quality ) ;
NVTT_API void setColorWeights ( float red , float green , float blue , float alpha = 1.0f ) ;
NVTT_API void setExternalCompressor ( const char * name ) ;
// Set color mask to describe the RGB/RGBA format.
NVTT_API void setPixelFormat ( unsigned int bitcount , unsigned int rmask , unsigned int gmask , unsigned int bmask , unsigned int amask ) ;
NVTT_API void setPixelFormat ( unsigned char rsize , unsigned char gsize , unsigned char bsize , unsigned char asize ) ;
NVTT_API void setPixelType ( PixelType pixelType ) ;
2007-05-17 00:11:38 +00:00
2010-08-31 01:39:08 +00:00
NVTT_API void setPitchAlignment ( int pitchAlignment ) ;
2011-09-29 23:14:18 +00:00
// @@ I wish this wasn't part of the compression options. Quantization is applied before compression. We don't have compressors with error diffusion.
2010-11-03 18:31:16 +00:00
NVTT_API void setQuantization ( bool colorDithering , bool alphaDithering , bool binaryAlpha , int alphaThreshold = 127 ) ;
2011-01-08 04:54:06 +00:00
2011-02-28 08:27:24 +00:00
NVTT_API void setTargetDecoder ( Decoder decoder ) ;
2011-01-08 04:54:06 +00:00
// Translate to and from D3D formats.
NVTT_API unsigned int d3d9Format ( ) const ;
//NVTT_API bool setD3D9Format(unsigned int format);
//NVTT_API unsigned int dxgiFormat() const;
//NVTT_API bool setDxgiFormat(unsigned int format);
2010-11-03 18:31:16 +00:00
} ;
/*
// DXGI_FORMAT_R16G16_FLOAT
compressionOptions . setPixelType ( PixelType_Float ) ;
compressionOptions . setPixelFormat2 ( 16 , 16 , 0 , 0 ) ;
// DXGI_FORMAT_R32G32B32A32_FLOAT
compressionOptions . setPixelType ( PixelType_Float ) ;
compressionOptions . setPixelFormat2 ( 32 , 32 , 32 , 32 ) ;
*/
2011-09-29 23:14:18 +00:00
// Wrap modes.
2010-11-03 18:31:16 +00:00
enum WrapMode
{
WrapMode_Clamp ,
WrapMode_Repeat ,
WrapMode_Mirror ,
} ;
2011-09-29 23:14:18 +00:00
// Texture types.
2010-11-03 18:31:16 +00:00
enum TextureType
{
TextureType_2D ,
TextureType_Cube ,
2011-09-27 05:17:01 +00:00
TextureType_3D ,
2010-11-03 18:31:16 +00:00
} ;
2011-09-29 23:14:18 +00:00
// Input formats.
2010-11-03 18:31:16 +00:00
enum InputFormat
{
2011-09-29 23:14:18 +00:00
InputFormat_BGRA_8UB , // Normalized [0, 1] 8 bit fixed point.
InputFormat_RGBA_16F , // 16 bit floating point.
InputFormat_RGBA_32F , // 32 bit floating point.
2010-11-03 18:31:16 +00:00
} ;
2011-09-29 23:14:18 +00:00
// Mipmap downsampling filters.
2010-11-03 18:31:16 +00:00
enum MipmapFilter
{
2011-09-29 23:14:18 +00:00
MipmapFilter_Box , // Box filter is quite good and very fast.
MipmapFilter_Triangle , // Triangle filter blurs the results too much, but that might be what you want.
MipmapFilter_Kaiser , // Kaiser-windowed Sinc filter is the best downsampling filter.
2010-11-03 18:31:16 +00:00
} ;
2011-09-29 23:14:18 +00:00
// Texture resize filters.
2010-11-03 18:31:16 +00:00
enum ResizeFilter
{
ResizeFilter_Box ,
ResizeFilter_Triangle ,
ResizeFilter_Kaiser ,
ResizeFilter_Mitchell ,
} ;
2011-09-29 23:14:18 +00:00
// Extents rounding mode.
2010-11-03 18:31:16 +00:00
enum RoundMode
{
RoundMode_None ,
RoundMode_ToNextPowerOfTwo ,
RoundMode_ToNearestPowerOfTwo ,
RoundMode_ToPreviousPowerOfTwo ,
} ;
2011-09-29 23:14:18 +00:00
// Alpha mode.
2010-11-03 18:31:16 +00:00
enum AlphaMode
{
AlphaMode_None ,
AlphaMode_Transparency ,
AlphaMode_Premultiplied ,
} ;
2011-09-29 23:14:18 +00:00
// Input options. Specify format and layout of the input texture.
2010-11-03 18:31:16 +00:00
struct InputOptions
{
NVTT_FORBID_COPY ( InputOptions ) ;
NVTT_DECLARE_PIMPL ( InputOptions ) ;
NVTT_API InputOptions ( ) ;
NVTT_API ~ InputOptions ( ) ;
// Set default options.
NVTT_API void reset ( ) ;
// Setup input layout.
NVTT_API void setTextureLayout ( TextureType type , int w , int h , int d = 1 ) ;
NVTT_API void resetTextureLayout ( ) ;
// Set mipmap data. Copies the data.
NVTT_API bool setMipmapData ( const void * data , int w , int h , int d = 1 , int face = 0 , int mipmap = 0 ) ;
// Describe the format of the input.
NVTT_API void setFormat ( InputFormat format ) ;
// Set the way the input alpha channel is interpreted. @@ Not implemented!
NVTT_API void setAlphaMode ( AlphaMode alphaMode ) ;
// Set gamma settings.
NVTT_API void setGamma ( float inputGamma , float outputGamma ) ;
// Set texture wrapping mode.
NVTT_API void setWrapMode ( WrapMode mode ) ;
// Set mipmapping options.
NVTT_API void setMipmapFilter ( MipmapFilter filter ) ;
NVTT_API void setMipmapGeneration ( bool enabled , int maxLevel = - 1 ) ;
NVTT_API void setKaiserParameters ( float width , float alpha , float stretch ) ;
// Set normal map options.
NVTT_API void setNormalMap ( bool b ) ;
NVTT_API void setConvertToNormalMap ( bool convert ) ;
NVTT_API void setHeightEvaluation ( float redScale , float greenScale , float blueScale , float alphaScale ) ;
NVTT_API void setNormalFilter ( float sm , float medium , float big , float large ) ;
NVTT_API void setNormalizeMipmaps ( bool b ) ;
// Set resizing options.
NVTT_API void setMaxExtents ( int d ) ;
NVTT_API void setRoundMode ( RoundMode mode ) ;
} ;
2011-09-29 23:14:18 +00:00
// Output handler.
2010-11-03 18:31:16 +00:00
struct OutputHandler
{
virtual ~ OutputHandler ( ) { }
2011-09-29 23:14:18 +00:00
// Indicate the start of a new compressed image that's part of the final texture.
2010-11-03 18:31:16 +00:00
virtual void beginImage ( int size , int width , int height , int depth , int face , int miplevel ) = 0 ;
2011-09-29 23:14:18 +00:00
// Output data. Compressed data is output as soon as it's generated to minimize memory allocations.
2010-11-03 18:31:16 +00:00
virtual bool writeData ( const void * data , int size ) = 0 ;
2011-09-27 17:48:46 +00:00
2011-09-29 23:14:18 +00:00
// Indicate the end of a the compressed image.
2011-09-27 17:48:46 +00:00
virtual void endImage ( ) = 0 ;
2010-11-03 18:31:16 +00:00
} ;
2011-09-29 23:14:18 +00:00
// Error codes.
2010-11-03 18:31:16 +00:00
enum Error
{
Error_Unknown ,
Error_InvalidInput ,
Error_UnsupportedFeature ,
Error_CudaError ,
Error_FileOpen ,
Error_FileWrite ,
Error_UnsupportedOutputFormat ,
} ;
2011-09-29 23:14:18 +00:00
// Error handler.
2010-11-03 18:31:16 +00:00
struct ErrorHandler
{
virtual ~ ErrorHandler ( ) { }
// Signal error.
virtual void error ( Error e ) = 0 ;
} ;
2011-09-29 23:14:18 +00:00
// Container.
2010-11-03 18:31:16 +00:00
enum Container
{
Container_DDS ,
Container_DDS10 ,
2011-09-29 23:14:18 +00:00
// Container_KTX, // Khronos Texture: http://www.khronos.org/opengles/sdk/tools/KTX/
// Container_VTF, // Valve Texture Format: http://developer.valvesoftware.com/wiki/Valve_Texture_Format
2010-11-03 18:31:16 +00:00
} ;
2011-09-29 23:14:18 +00:00
// Output Options. This class holds pointers to the interfaces that are used to report the output of
// the compressor to the user.
2010-11-03 18:31:16 +00:00
struct OutputOptions
{
NVTT_FORBID_COPY ( OutputOptions ) ;
NVTT_DECLARE_PIMPL ( OutputOptions ) ;
NVTT_API OutputOptions ( ) ;
NVTT_API ~ OutputOptions ( ) ;
// Set default options.
NVTT_API void reset ( ) ;
NVTT_API void setFileName ( const char * fileName ) ;
2011-10-10 20:24:12 +00:00
NVTT_API void setFileHandle ( void * fp ) ;
2010-11-03 18:31:16 +00:00
NVTT_API void setOutputHandler ( OutputHandler * outputHandler ) ;
NVTT_API void setErrorHandler ( ErrorHandler * errorHandler ) ;
NVTT_API void setOutputHeader ( bool outputHeader ) ;
NVTT_API void setContainer ( Container container ) ;
2010-08-31 01:39:08 +00:00
NVTT_API void setUserVersion ( int version ) ;
2011-01-08 04:54:06 +00:00
NVTT_API void setSrgbFlag ( bool b ) ;
2010-11-03 18:31:16 +00:00
} ;
2010-12-10 10:29:04 +00:00
typedef void Task ( void * context , int id ) ;
2010-11-22 07:34:05 +00:00
struct TaskDispatcher
{
2010-12-10 10:29:04 +00:00
virtual void dispatch ( Task * task , void * context , int count ) = 0 ;
2010-11-22 07:34:05 +00:00
} ;
2010-11-03 18:31:16 +00:00
2011-09-29 23:14:18 +00:00
// Context.
2010-11-03 18:31:16 +00:00
struct Compressor
{
NVTT_FORBID_COPY ( Compressor ) ;
NVTT_DECLARE_PIMPL ( Compressor ) ;
NVTT_API Compressor ( ) ;
NVTT_API ~ Compressor ( ) ;
// Context settings.
NVTT_API void enableCudaAcceleration ( bool enable ) ;
NVTT_API bool isCudaAccelerationEnabled ( ) const ;
2010-11-22 07:34:05 +00:00
NVTT_API void setTaskDispatcher ( TaskDispatcher * disp ) ;
2010-11-03 18:31:16 +00:00
// InputOptions API.
NVTT_API bool process ( const InputOptions & inputOptions , const CompressionOptions & compressionOptions , const OutputOptions & outputOptions ) const ;
NVTT_API int estimateSize ( const InputOptions & inputOptions , const CompressionOptions & compressionOptions ) const ;
2011-09-28 16:40:59 +00:00
// Surface API.
NVTT_API bool outputHeader ( const Surface & img , int mipmapCount , const CompressionOptions & compressionOptions , const OutputOptions & outputOptions ) const ;
NVTT_API bool compress ( const Surface & img , int face , int mipmap , const CompressionOptions & compressionOptions , const OutputOptions & outputOptions ) const ;
NVTT_API int estimateSize ( const Surface & img , int mipmapCount , const CompressionOptions & compressionOptions ) const ;
2010-11-03 18:31:16 +00:00
2011-09-28 16:40:59 +00:00
// CubeSurface API.
NVTT_API bool outputHeader ( const CubeSurface & cube , int mipmapCount , const CompressionOptions & compressionOptions , const OutputOptions & outputOptions ) const ;
NVTT_API bool compress ( const CubeSurface & cube , int mipmap , const CompressionOptions & compressionOptions , const OutputOptions & outputOptions ) const ;
NVTT_API int estimateSize ( const CubeSurface & cube , int mipmapCount , const CompressionOptions & compressionOptions ) const ;
2011-09-28 01:45:08 +00:00
2010-11-03 18:31:16 +00:00
// Raw API.
2011-04-06 02:41:15 +00:00
NVTT_API bool outputHeader ( TextureType type , int w , int h , int d , int mipmapCount , bool isNormalMap , const CompressionOptions & compressionOptions , const OutputOptions & outputOptions ) const ;
2010-11-06 02:34:34 +00:00
NVTT_API bool compress ( int w , int h , int d , int face , int mipmap , const float * rgba , const CompressionOptions & compressionOptions , const OutputOptions & outputOptions ) const ;
2010-11-03 18:31:16 +00:00
NVTT_API int estimateSize ( int w , int h , int d , int mipmapCount , const CompressionOptions & compressionOptions ) const ;
} ;
// "Compressor" is deprecated. This should have been called "Context"
typedef Compressor Context ;
2011-02-28 09:05:28 +00:00
enum NormalTransform {
NormalTransform_Orthographic ,
NormalTransform_Stereographic ,
NormalTransform_Paraboloid ,
2011-09-29 23:14:18 +00:00
NormalTransform_Quartic
2011-03-06 22:23:24 +00:00
//NormalTransform_DualParaboloid,
2011-02-28 09:05:28 +00:00
} ;
2010-11-03 18:31:16 +00:00
2011-11-11 00:48:22 +00:00
enum ToneMapper {
ToneMapper_Linear ,
ToneMapper_Reindhart ,
ToneMapper_Halo ,
2011-11-11 02:02:58 +00:00
ToneMapper_Lightmap ,
2011-11-11 00:48:22 +00:00
} ;
2012-01-04 02:25:28 +00:00
/*enum ChannelMask {
R = 0x70000001 ,
G = 0x70000002 ,
B = 0x70000004 ,
A = 0x70000008 ,
} ; */
2011-09-28 16:40:59 +00:00
2011-09-29 23:14:18 +00:00
// A surface is one level of a 2D or 3D texture.
// @@ It would be nice to add support for texture borders for correct resizing of tiled textures and constrained DXT compression.
2011-09-28 16:40:59 +00:00
struct Surface
2010-11-03 18:31:16 +00:00
{
2011-09-28 16:40:59 +00:00
NVTT_API Surface ( ) ;
NVTT_API Surface ( const Surface & img ) ;
NVTT_API ~ Surface ( ) ;
2010-11-03 18:31:16 +00:00
2011-09-28 16:40:59 +00:00
NVTT_API void operator = ( const Surface & img ) ;
2010-11-03 18:31:16 +00:00
// Texture parameters.
NVTT_API void setWrapMode ( WrapMode mode ) ;
NVTT_API void setAlphaMode ( AlphaMode alphaMode ) ;
NVTT_API void setNormalMap ( bool isNormalMap ) ;
2010-11-05 00:36:50 +00:00
// Queries.
2011-01-08 04:54:06 +00:00
NVTT_API bool isNull ( ) const ;
2010-11-03 18:31:16 +00:00
NVTT_API int width ( ) const ;
NVTT_API int height ( ) const ;
NVTT_API int depth ( ) const ;
2011-09-27 05:17:01 +00:00
NVTT_API TextureType type ( ) const ;
2010-11-03 18:31:16 +00:00
NVTT_API WrapMode wrapMode ( ) const ;
NVTT_API AlphaMode alphaMode ( ) const ;
NVTT_API bool isNormalMap ( ) const ;
NVTT_API int countMipmaps ( ) const ;
2013-06-07 17:53:55 +00:00
NVTT_API int countMipmaps ( int min_size ) const ;
2010-05-27 00:37:15 +00:00
NVTT_API float alphaTestCoverage ( float alphaRef = 0.5 ) const ;
2011-04-06 02:41:15 +00:00
NVTT_API float average ( int channel , int alpha_channel = - 1 , float gamma = 2.2f ) const ;
2010-11-05 00:36:50 +00:00
NVTT_API const float * data ( ) const ;
2013-06-07 17:53:55 +00:00
NVTT_API const float * channel ( int i ) const ;
2010-11-09 03:38:03 +00:00
NVTT_API void histogram ( int channel , float rangeMin , float rangeMax , int binCount , int * binPtr ) const ;
2013-06-07 17:53:55 +00:00
NVTT_API void range ( int channel , float * rangeMin , float * rangeMax , int alpha_channel = - 1 , float alpha_ref = 0.f ) const ;
2009-03-16 08:37:07 +00:00
2010-11-03 18:31:16 +00:00
// Texture data.
2010-11-12 03:32:46 +00:00
NVTT_API bool load ( const char * fileName , bool * hasAlpha = 0 ) ;
2013-06-07 17:53:55 +00:00
NVTT_API bool save ( const char * fileName , bool hasAlpha = 0 , bool hdr = 0 ) const ;
NVTT_API bool setImage ( int w , int h , int d ) ;
2011-09-27 05:17:01 +00:00
NVTT_API bool setImage ( InputFormat format , int w , int h , int d , const void * data ) ;
NVTT_API bool setImage ( InputFormat format , int w , int h , int d , const void * r , const void * g , const void * b , const void * a ) ;
2010-11-05 00:36:50 +00:00
NVTT_API bool setImage2D ( Format format , Decoder decoder , int w , int h , const void * data ) ;
2010-11-03 18:31:16 +00:00
// Resizing methods.
2011-09-27 05:17:01 +00:00
NVTT_API void resize ( int w , int h , int d , ResizeFilter filter ) ;
NVTT_API void resize ( int w , int h , int d , ResizeFilter filter , float filterWidth , const float * params = 0 ) ;
2010-11-03 18:31:16 +00:00
NVTT_API void resize ( int maxExtent , RoundMode mode , ResizeFilter filter ) ;
NVTT_API void resize ( int maxExtent , RoundMode mode , ResizeFilter filter , float filterWidth , const float * params = 0 ) ;
2013-06-07 17:53:55 +00:00
NVTT_API void resize_make_square ( int maxExtent , RoundMode roundMode , ResizeFilter filter ) ;
NVTT_API bool buildNextMipmap ( MipmapFilter filter , int min_size = 1 ) ;
NVTT_API bool buildNextMipmap ( MipmapFilter filter , float filterWidth , const float * params = 0 , int min_size = 1 ) ;
NVTT_API bool buildNextMipmapSolidColor ( const float * const color_components ) ;
2011-09-27 17:48:46 +00:00
NVTT_API void canvasSize ( int w , int h , int d ) ;
2013-06-07 17:53:55 +00:00
// associated to resizing:
NVTT_API bool canMakeNextMipmap ( int min_size = 1 ) ;
2010-11-03 18:31:16 +00:00
// Color transforms.
NVTT_API void toLinear ( float gamma ) ;
NVTT_API void toGamma ( float gamma ) ;
2011-11-11 02:02:58 +00:00
NVTT_API void toLinear ( int channel , float gamma ) ;
NVTT_API void toGamma ( int channel , float gamma ) ;
2011-09-27 17:48:46 +00:00
NVTT_API void toSrgb ( ) ;
2011-10-10 20:24:12 +00:00
NVTT_API void toLinearFromSrgb ( ) ;
2011-09-27 17:48:46 +00:00
NVTT_API void toXenonSrgb ( ) ;
2010-11-03 18:31:16 +00:00
NVTT_API void transform ( const float w0 [ 4 ] , const float w1 [ 4 ] , const float w2 [ 4 ] , const float w3 [ 4 ] , const float offset [ 4 ] ) ;
NVTT_API void swizzle ( int r , int g , int b , int a ) ;
NVTT_API void scaleBias ( int channel , float scale , float bias ) ;
2010-08-31 01:39:08 +00:00
NVTT_API void clamp ( int channel , float low = 0.0f , float high = 1.0f ) ;
2010-11-03 18:31:16 +00:00
NVTT_API void blend ( float r , float g , float b , float a , float t ) ;
NVTT_API void premultiplyAlpha ( ) ;
NVTT_API void toGreyScale ( float redScale , float greenScale , float blueScale , float alphaScale ) ;
NVTT_API void setBorder ( float r , float g , float b , float a ) ;
NVTT_API void fill ( float r , float g , float b , float a ) ;
2010-05-27 00:37:15 +00:00
NVTT_API void scaleAlphaToCoverage ( float coverage , float alphaRef = 0.5f ) ;
2010-11-03 18:31:16 +00:00
NVTT_API void toRGBM ( float range = 1.0f , float threshold = 0.0f ) ;
2010-11-06 02:34:34 +00:00
NVTT_API void fromRGBM ( float range = 1.0f ) ;
2013-06-07 17:53:55 +00:00
NVTT_API void toLM ( float range = 1.0f , float threshold = 0.0f ) ;
2011-09-28 18:44:18 +00:00
NVTT_API void toRGBE ( int mantissaBits , int exponentBits ) ;
NVTT_API void fromRGBE ( int mantissaBits , int exponentBits ) ;
2010-11-03 18:31:16 +00:00
NVTT_API void toYCoCg ( ) ;
NVTT_API void blockScaleCoCg ( int bits = 5 , float threshold = 0.0f ) ;
2010-11-06 02:34:34 +00:00
NVTT_API void fromYCoCg ( ) ;
2010-11-08 19:03:20 +00:00
NVTT_API void toLUVW ( float range = 1.0f ) ;
NVTT_API void fromLUVW ( float range = 1.0f ) ;
2010-11-12 03:32:46 +00:00
NVTT_API void abs ( int channel ) ;
2011-09-27 18:41:02 +00:00
NVTT_API void convolve ( int channel , int kernelSize , float * kernelData ) ;
2012-01-04 02:25:28 +00:00
NVTT_API void toLogScale ( int channel , float base ) ;
NVTT_API void fromLogScale ( int channel , float base ) ;
2010-11-12 03:32:46 +00:00
2011-11-11 02:02:58 +00:00
NVTT_API void toneMap ( ToneMapper tm , float * parameters ) ;
2011-11-11 00:48:22 +00:00
2011-01-25 09:17:53 +00:00
//NVTT_API void blockLuminanceScale(float scale);
2010-11-03 18:31:16 +00:00
2010-11-03 18:53:51 +00:00
// Color quantization.
NVTT_API void binarize ( int channel , float threshold , bool dither ) ;
2011-01-25 09:17:53 +00:00
NVTT_API void quantize ( int channel , int bits , bool exactEndPoints , bool dither ) ;
2009-03-07 07:14:00 +00:00
2013-06-07 17:53:55 +00:00
// Normal map transforms.
2010-11-03 18:31:16 +00:00
NVTT_API void toNormalMap ( float sm , float medium , float big , float large ) ;
NVTT_API void normalizeNormalMap ( ) ;
2011-02-28 09:05:28 +00:00
NVTT_API void transformNormals ( NormalTransform xform ) ;
NVTT_API void reconstructNormals ( NormalTransform xform ) ;
2011-09-27 05:17:01 +00:00
NVTT_API void toCleanNormalMap ( ) ;
2013-06-07 17:53:55 +00:00
NVTT_API void packNormals ( float scale = 0.5f , float bias = 0.5f ) ; // [-1,1] -> [ 0,1]
NVTT_API void expandNormals ( float scale = 2.0f , float bias = - 1.0f ) ; // [ 0,1] -> [-1,1]
2011-11-11 02:02:58 +00:00
NVTT_API Surface createToksvigMap ( float power ) const ;
NVTT_API Surface createCleanMap ( ) const ;
2009-03-07 07:14:00 +00:00
2010-05-05 00:24:31 +00:00
// Geometric transforms.
2011-09-27 05:17:01 +00:00
NVTT_API void flipX ( ) ;
NVTT_API void flipY ( ) ;
NVTT_API void flipZ ( ) ;
2013-06-07 17:53:55 +00:00
NVTT_API Surface createSubImage ( int x0 , int x1 , int y0 , int y1 , int z0 , int z1 ) const ;
2010-05-05 00:24:31 +00:00
2010-11-03 18:31:16 +00:00
// Copy image data.
2011-09-28 16:40:59 +00:00
NVTT_API bool copyChannel ( const Surface & srcImage , int srcChannel ) ;
NVTT_API bool copyChannel ( const Surface & srcImage , int srcChannel , int dstChannel ) ;
2010-11-12 03:32:46 +00:00
2011-09-28 16:40:59 +00:00
NVTT_API bool addChannel ( const Surface & img , int srcChannel , int dstChannel , float scale ) ;
2010-11-06 02:34:34 +00:00
2013-06-07 17:53:55 +00:00
NVTT_API bool copy ( const Surface & src , int xsrc , int ysrc , int zsrc , int xsize , int ysize , int zsize , int xdst , int ydst , int zdst ) ;
2011-09-28 16:40:59 +00:00
//private:
2010-11-03 18:31:16 +00:00
void detach ( ) ;
2009-03-07 07:14:00 +00:00
2010-11-03 18:31:16 +00:00
struct Private ;
Private * m ;
} ;
2009-01-05 10:17:06 +00:00
2011-09-29 23:14:18 +00:00
// Cube layout formats.
2011-09-27 17:28:01 +00:00
enum CubeLayout {
CubeLayout_VerticalCross ,
CubeLayout_HorizontalCross ,
CubeLayout_Column ,
CubeLayout_Row ,
2011-09-29 23:14:18 +00:00
CubeLayout_LatitudeLongitude
2011-09-27 17:28:01 +00:00
} ;
2011-11-11 00:48:22 +00:00
enum EdgeFixup {
EdgeFixup_None ,
EdgeFixup_Stretch ,
EdgeFixup_Warp ,
EdgeFixup_Average ,
} ;
2011-09-29 23:14:18 +00:00
// A CubeSurface is one level of a cube map texture.
2011-09-28 16:40:59 +00:00
struct CubeSurface
2011-09-27 05:17:01 +00:00
{
2011-09-28 16:40:59 +00:00
NVTT_API CubeSurface ( ) ;
NVTT_API CubeSurface ( const CubeSurface & img ) ;
NVTT_API ~ CubeSurface ( ) ;
2011-09-27 05:17:01 +00:00
2011-09-28 16:40:59 +00:00
NVTT_API void operator = ( const CubeSurface & img ) ;
2011-09-27 05:17:01 +00:00
// Queries.
NVTT_API bool isNull ( ) const ;
2011-09-29 00:58:47 +00:00
NVTT_API int edgeLength ( ) const ;
2011-09-27 05:17:01 +00:00
NVTT_API int countMipmaps ( ) const ;
// Texture data.
2011-09-30 01:52:27 +00:00
NVTT_API bool load ( const char * fileName , int mipmap ) ;
2011-09-27 05:17:01 +00:00
NVTT_API bool save ( const char * fileName ) const ;
2011-09-30 01:52:27 +00:00
NVTT_API Surface & face ( int face ) ;
NVTT_API const Surface & face ( int face ) const ;
2011-09-27 05:17:01 +00:00
2011-09-29 23:14:18 +00:00
// Layout conversion. @@ Not implemented.
2011-09-30 01:52:27 +00:00
NVTT_API void fold ( const Surface & img , CubeLayout layout ) ;
NVTT_API Surface unfold ( CubeLayout layout ) const ;
2011-09-27 17:28:01 +00:00
// @@ Angular extent filtering.
2011-09-27 05:17:01 +00:00
// @@ Add resizing methods.
2011-09-27 17:28:01 +00:00
2011-09-29 23:14:18 +00:00
// @@ Add edge fixup methods.
2011-10-10 20:24:12 +00:00
NVTT_API float average ( int channel ) const ;
2011-11-11 02:02:58 +00:00
NVTT_API void range ( int channel , float * minimum_ptr , float * maximum_ptr ) const ;
2013-06-07 17:53:55 +00:00
NVTT_API void clamp ( int channel , float low = 0.0f , float high = 1.0f ) ;
2011-11-11 02:02:58 +00:00
2011-10-10 20:24:12 +00:00
2011-09-28 01:45:08 +00:00
// Filtering.
2011-11-11 00:48:22 +00:00
NVTT_API CubeSurface irradianceFilter ( int size , EdgeFixup fixupMethod ) const ;
NVTT_API CubeSurface cosinePowerFilter ( int size , float cosinePower , EdgeFixup fixupMethod ) const ;
2011-09-28 01:45:08 +00:00
2013-06-07 17:53:55 +00:00
NVTT_API CubeSurface fastResample ( int size , EdgeFixup fixupMethod ) const ;
2011-09-30 17:21:08 +00:00
2011-09-27 05:17:01 +00:00
/*
NVTT_API void resize ( int w , int h , ResizeFilter filter ) ;
NVTT_API void resize ( int w , int h , ResizeFilter filter , float filterWidth , const float * params = 0 ) ;
NVTT_API void resize ( int maxExtent , RoundMode mode , ResizeFilter filter ) ;
NVTT_API void resize ( int maxExtent , RoundMode mode , ResizeFilter filter , float filterWidth , const float * params = 0 ) ;
NVTT_API bool buildNextMipmap ( MipmapFilter filter ) ;
NVTT_API bool buildNextMipmap ( MipmapFilter filter , float filterWidth , const float * params = 0 ) ;
*/
// Color transforms.
NVTT_API void toLinear ( float gamma ) ;
NVTT_API void toGamma ( float gamma ) ;
2011-09-28 16:40:59 +00:00
//private:
2011-09-27 05:17:01 +00:00
void detach ( ) ;
struct Private ;
Private * m ;
} ;
2010-11-03 18:31:16 +00:00
// Return string for the given error code.
NVTT_API const char * errorString ( Error e ) ;
2007-05-17 00:11:38 +00:00
2010-11-03 18:31:16 +00:00
// Return NVTT version.
NVTT_API unsigned int version ( ) ;
2008-01-26 02:46:12 +00:00
2011-09-28 16:40:59 +00:00
NVTT_API float rmsError ( const Surface & reference , const Surface & img ) ;
NVTT_API float rmsAlphaError ( const Surface & reference , const Surface & img ) ;
NVTT_API float cieLabError ( const Surface & reference , const Surface & img ) ;
NVTT_API float angularError ( const Surface & reference , const Surface & img ) ;
NVTT_API Surface diff ( const Surface & reference , const Surface & img , float scale ) ;
2010-11-08 19:03:20 +00:00
2010-11-12 03:32:46 +00:00
2007-05-17 00:11:38 +00:00
} // nvtt namespace
2010-05-31 08:13:23 +00:00
# endif // NVTT_H