Detailed Description
- See also:
- Class GBufReader, Class GBufWriter, Image (G-Buffer) Channels,
G-Buffer
Channel Types, Class Bitmap.
class GBuffer : public
InterfaceServer
New Methods in Max8
Global Methods
Member Functions
- Description:
- This class is available in release 3.0 and later only.
This class is used by Bitmaps to implement an enhanced G-Buffer
(providing more functionality than the 2.x G-Buffer). The new
G-Buffer stores multiple layers at each pixel. The Virtual Frame
Buffer includes a new spinner to the right of the "channels" drop
down which lets you look at the different layers. (It only appears
when there are G-Buffer channels present).
The multiple layers of the G-Buffer allow rendering effects to do
better antialiasing and handling of transparency. The frontmost
layer is still stored in the G-Buffer as full, screen-sized arrays,
one for each channel. The subsequent layers are stored in a
variable number of "layer records" all of which are the same size
(which depends on which channels have been requested via the
GBuffer::CreateChannels()
function). Even scenes with no transparency can have more than one
layer at a given pixel. This can occur along the edges of an
object, where the object partially covers some pixels, and another
object (or objects) is visible in the remaining part of the pixel.
Each visible face in the pixel will be represented by a fragment. A
given object will not always appear on the same layer. If it is the
only object in a pixel it will be in the frontmost layer, but where
it is partially occluded it will lie in a layer behind the
occluding object.
Another way multiple layers can occur (aside from transparency) is
when objects are given the "Render Occluded Objects" property in
the object properties dialog. When an object has this property, it
acts as if it were transparent, and objects behind it, though
invisible, are rendered and stored in the G-Buffer.
Another G-Buffer layer is added to contain the background color in
its color channel for any pixel which is not empty and on which the
background gets evaluated. This means the background layer will be
present behind transparent objects or objects with "render
occluded" turned on. It will also be present along the edges of
objects where the background is partially visible in the pixel.
Note: This does not depend at all on having the GB_BG flag
set. It is necessary to have the GB_COLOR channel,
however.
All methods of this class are implemented by the System.
Note on RPF files: The following information relates to the
layer storage scheme used in the 3ds Max RPF files.
The layer information for each scan line is stored as a series of
run-encoded channels, each containing the same number of data
elements, one per layer record. The first channel is a
"psuedo-channel" that contains the x value for each layer record.
If there are multiple layers for a given x, this will be reflected
as several identical x values in a row.
For instance, if the x channel contained
5,6,7,7,8,8,8,9,10
And the Z channel contained
100, 100, 100,200, 100,200,300, 100, 100
This would mean at pixel 7 there are 2 layers, and pixel 8 there
are 3 layers.
Pixel depths
5 100
6 100
7 100, 200
8 100, 200, 300
9 100
10 100
As an extra note regarding RPF files, a new data member was added
to class RenderInfo, which is saved with the
RPF (and RLA) files. In order to avoid getting out of sync with
previous file format implementations a "version" word preceding the
RenderInfo record
has been added into the format. The version is set to a value that
will distinguish it from the first word of the RenderInfo data, enabling it to
determine the version. If we make further additions to RenderInfo in the future,
the version will allow us to keep it straight. To load both older
and newer RPF and RLA files correctly, the code that loads the
RenderInfo been
modified, and therefore any plugins and 3rd party code that read
these files need to be changed. Here's my the code:
#define RENDINFO_VERS1 1000
int RLAReader::ReadRendInfo(RenderInfo *ri) {
short vers;
if (fread(&vers,sizeof(short),1,fd)!=1) return 0;
int size = sizeof(RenderInfo);
if (vers != RENDINFO_VERS1) {
// the old version didn't start with a version word,
but
// with projType which is 0 or 1.
size -= sizeof(Rect); // The old record didn't have the region
Rect.
fseek(fd,-sizeof(short),SEEK_CUR); // Undo the version
read
}
if (ri) {
if (fread(ri,size,1,fd)!=1) return 0;
}
else
fseek(fd, size, SEEK_CUR);
return 1;
}
#include <gbuf.h>
List of all
members.
Public Member Functions
|
virtual
void |
SetRasterSize
(int ww, int hh)=0 |
virtual
int |
Width
()=0 |
virtual
int |
Height
()=0 |
virtual
int |
InitBuffer
()=0 |
virtual
ULONG |
CreateChannels
(ULONG channelMask)=0 |
virtual
void |
DeleteChannels
(ULONG channelMask)=0 |
virtual
ULONG |
ChannelsPresent
()=0 |
virtual void
* |
GetChannel
(ULONG channelID, ULONG &chanType)=0 |
virtual
GBufReader
* |
CreateReader
()=0 |
virtual
void |
DestroyReader
(GBufReader
*pRdr)=0 |
virtual
GBufWriter
* |
CreateWriter
()=0 |
virtual
void |
DestroyWriter
(GBufWriter
*pRdr)=0 |
virtual
BOOL |
IsDefaultGBuffer
() |
virtual
void |
DeleteThis
()=0 |
virtual
void |
Copy
(GBuffer
*gbfrom)=0 |
virtual
void |
CopyScale
(GBuffer *gbfrom, int
cw=-1, int ch=-1)=0 |
virtual
void |
Position
(int srcy, int trgy, int srcx, int trgx, int trgw, int trgh)=0 |
virtual
int |
NumberLayerRecords
(int y)=0 |
virtual
int |
GetLayerChannel
(int y, int ichan, char *data)=0 |
virtual
int |
CreateLayerRecords
(int y, int num)=0 |
virtual
int |
SetLayerChannel
(int y, int ichan, char *data)=0 |
virtual
void |
UpdateChannelMinMax
()=0 |
virtual
BOOL |
GetChannelMin
(int chan, void *data)=0 |
virtual
BOOL |
GetChannelMax
(int chan, void *data)=0 |
virtual
NameTab
& |
NodeRenderIDNameTab
()=0 |
virtual
Tab< float >
& |
ImageBlurMultiplierTab
()=0 |
Static Public Member
Functions
|
static
CoreExport void |
ColorById
(int id, BMM_Color_24 &cOut) |
Member Function Documentation
virtual void SetRasterSize |
( |
int |
ww, |
|
|
int |
hh |
|
) |
|
[pure virtual] |
- Parameters:
- int ww
The width to set in pixels.
int hh
The height to set in pixels.
virtual int Width |
( |
|
) |
[pure virtual] |
virtual int Height |
( |
|
) |
[pure virtual] |
virtual int InitBuffer |
( |
|
) |
[pure virtual] |
- Returns:
- Nonzero on success; otherwise zero.
- Sample Code:
-
virtual ULONG CreateChannels |
( |
ULONG |
channelMask |
) |
[pure virtual] |
- Parameters:
- ULONG channelMask
Specifies the channels to create. See Image (G-Buffer)
Channels.
- Returns:
- The channels that are currently present.
virtual void DeleteChannels |
( |
ULONG |
channelMask |
) |
[pure virtual] |
- Parameters:
- ULONG channelMask
Specifies the channels to create. See Image (G-Buffer)
Channels.
- Returns:
- The channels that are currently present.
virtual ULONG ChannelsPresent |
( |
|
) |
[pure virtual] |
virtual void* GetChannel |
( |
ULONG |
channelID, |
|
|
ULONG & |
chanType |
|
) |
|
[pure virtual] |
virtual GBufReader* CreateReader |
( |
|
) |
[pure virtual] |
virtual void DestroyReader |
( |
GBufReader * |
pRdr |
) |
[pure virtual] |
- Parameters:
- GBufReader
*pRdr
Points to the reader to delete.
virtual GBufWriter* CreateWriter |
( |
|
) |
[pure virtual] |
virtual void DestroyWriter |
( |
GBufWriter * |
pRdr |
) |
[pure virtual] |
- Parameters:
- GBufWriter
*pRdr
Points to the writer to delete.
virtual BOOL IsDefaultGBuffer |
( |
|
) |
[inline, virtual] |
virtual void DeleteThis |
( |
|
) |
[pure virtual] |
virtual void Copy |
( |
GBuffer * |
gbfrom |
) |
[pure virtual] |
- Parameters:
- GBuffer
*gbfrom
Points to the source of the copy.
virtual void CopyScale |
( |
GBuffer * |
gbfrom, |
|
|
int |
cw = -1 , |
|
|
int |
ch = -1 |
|
) |
|
[pure virtual] |
- Parameters:
- GBuffer
*gbfrom
Points to the source of the copy.
int cw=-1
The width for the copy. If -1 is specified the copy is the same
size as the original.
int ch=-1
The height for the copy. If -1 is specified the copy is the same
size as the original.
virtual void Position |
( |
int |
srcy, |
|
|
int |
trgy, |
|
|
int |
srcx, |
|
|
int |
trgx, |
|
|
int |
trgw, |
|
|
int |
trgh |
|
) |
|
[pure virtual] |
- Parameters:
- int srcy
The source y location.
int trgy
The target y location.
int srcx
The source x location.
int trgx
The target x location.
int trgw
The target width.
int trgh
The target height.
virtual int NumberLayerRecords |
( |
int |
y |
) |
[pure virtual] |
- Parameters:
- int y
The zero based index of the scan line.
virtual int GetLayerChannel |
( |
int |
y, |
|
|
int |
ichan, |
|
|
char * |
data |
|
) |
|
[pure virtual] |
- Parameters:
- int y
The zero based index of the scan line.
int ichan
The channel to check. See G-Buffer Channel Indices.
When ichan=-1, it gives an array of the x values from each
of the layer records.
char *data
Points to storage for the layer data.
- Returns:
- TRUE on success; otherwise FALSE.
virtual int CreateLayerRecords |
( |
int |
y, |
|
|
int |
num |
|
) |
|
[pure virtual] |
- Parameters:
- int y
The zero based index of the scan line.
int num
The number of records to create.
- Returns:
- TRUE on success; otherwise FALSE.
virtual int SetLayerChannel |
( |
int |
y, |
|
|
int |
ichan, |
|
|
char * |
data |
|
) |
|
[pure virtual] |
- Parameters:
- int y
The zero based index of the scan line.
int ichan
The channel to set. See G-Buffer Channel Indices.
When ichan=-1, it sets an array of the x values from each of
the layer records.
char *data
Points to storage for the layer data.
- Returns:
- TRUE on success; otherwise FALSE.
virtual void UpdateChannelMinMax |
( |
|
) |
[pure virtual] |
virtual BOOL GetChannelMin |
( |
int |
chan, |
|
|
void * |
data |
|
) |
|
[pure virtual] |
- Parameters:
- int chan
The channel to check. One of the following (the other channels are
not supported):
GB_Z
Z-Buffer depth - float
GB_UV
UV coordinates - Point2
GB_VELOC
Velocity - Point2
void *data
Points to storage for the value to get.
- Returns:
- TRUE if chan was valid and the value could be stored in
data; otherwise FALSE.
virtual BOOL GetChannelMax |
( |
int |
chan, |
|
|
void * |
data |
|
) |
|
[pure virtual] |
- Parameters:
- int chan
The channel to check. One of the following (the other channels are
not supported):
GB_Z
Z-Buffer depth - float
GB_UV
UV coordinates - Point2
GB_VELOC
Velocity - Point2
void *data
Points to storage for the value to get.
- Returns:
- TRUE if chan was valid and the value could be stored in
data; otherwise FALSE.
virtual NameTab& NodeRenderIDNameTab |
( |
|
) |
[pure virtual] |
virtual Tab<float>&
ImageBlurMultiplierTab |
( |
|
) |
[pure virtual] |
static CoreExport void ColorById |
( |
int |
id, |
|
|
BMM_Color_24 & |
cOut |
|
) |
|
[static] |
- Parameters:
- id
The material or object id for which the color is wanted
cOut
The output color BMM_Color_24
type.