|
Modulate
#define BITMAP_OPERATION_MODE_MODULATE 4 multiply args together. The default mode
#define BITMAP_OPERATION_MODE_MODULATE2X 5 multiply and shift 1 bit
#define BITMAP_OPERATION_MODE_MODULATE4X 6 multiply and shift 2 bits
Add
#define BITMAP_OPERATION_MODE_ADD 7 add arguments together
#define BITMAP_OPERATION_MODE_ADDSIGNED 8 add with -0.5 bias
#define BITMAP_OPERATION_MODE_ADDSIGNED2X 9 as above but left 1 bit
#define BITMAP_OPERATION_MODE_SUBTRACT 10 Arg1 - Arg2, with no saturation
#define BITMAP_OPERATION_MODE_ADDSMOOTH 11 add 2 args, subtract product
Arg1 + Arg2 - Arg1*Arg2
= Arg1 + (1-Arg1)*Arg2
Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha)
#define BITMAP_OPERATION_MODE_BLENDDIFFUSEALPHA 12 iterated alpha
#define BITMAP_OPERATION_MODE_BLENDTEXTUREALPHA 13 texture alpha
#define BITMAP_OPERATION_MODE_BLENDFACTORALPHA 14 alpha from D3DRS_TEXTUREFACTOR
Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha)
#define BITMAP_OPERATION_MODE_BLENDTEXTUREALPHAPM 15 texture alpha
#define BITMAP_OPERATION_MODE_BLENDCURRENTALPHA 16 by alpha of current color
Specular mapping
#define BITMAP_OPERATION_MODE_PREMODULATE 17 modulate with next texture before use
#define BITMAP_OPERATION_MODE_MODULATEALPHA_ADDCOLOR 18 Arg1.RGB + Arg1.A*Arg2.RGB
COLOROP only
#define BITMAP_OPERATION_MODE_MODULATECOLOR_ADDALPHA 19 Arg1.RGB*Arg2.RGB + Arg1.A
COLOROP only
#define BITMAP_OPERATION_MODE_MODULATEINVALPHA_ADDCOLOR 20 (1-Arg1.A)*Arg2.RGB + Arg1.RGB
COLOROP only
#define BITMAP_OPERATION_MODE_MODULATEINVCOLOR_ADDALPHA 21 (1-Arg1.RGB)*Arg2.RGB + Arg1.A
COLOROP only
Bump mapping
#define BITMAP_OPERATION_MODE_BUMPENVMAP 22 per pixel env map perturbation
#define BITMAP_OPERATION_MODE_BUMPENVMAPLUMINANCE 23 with luminance channel
This can do either diffuse or specular bump mapping with correct input.
Performs the function (Arg1.R*Arg2.R + Arg1.G*Arg2.G + Arg1.B*Arg2.B)
where each component has been scaled and offset to make it signed.
The result is replicated into all four (including alpha) channels.
This is a valid COLOROP only.
#define BITMAP_OPERATION_MODE_DOTPRODUCT3 24
Triadic ops
#define BITMAP_OPERATION_MODE_MULTIPLYADD 25 Arg0 + Arg1*Arg2
#define BITMAP_OPERATION_MODE_LERP 26 (Arg0)*Arg1 + (1-Arg0)*Arg2
*** useful for advanced effects
A polygon can have a color/light (see STATE_polygon_set_light() or STATE_point_set_rgb())
and up to two bitmaps.
By default when the 3D card calculates the color of a pixel it multiplies all these "possessions" with each other.
STATE_bitmap_set_operation_mode() makes it possible to define a different operation for example: addition.
For example if a specific polygon has two bitmaps (See STATE_polygon_set_second_bitmap() )
one of the bitmaps is completly green and the other is completely red.
By default the result would be black ! this is becuase the 2 bitmaps are multiplied by each other
The pixels in the red bitmap have the color (1,0,0) and the pixels in the green bitmap have the color (0,1,0)
The result pixel is (1*0, 0*1, 0*0) = (0,0,0) = black !
Parameters:
operation_mode:
Any of the above constants (all those that start with BITMAP_OPERATION_MODE_ )
Example:
BYTE rgb[3]={0,0,0};
STATE_group_set_light(NULL, rgb); see remarks below
STATE_bitmap_set_operation_mode(my_bitmap, BITMAP_OPERATION_MODE_ADD);
Important remarks:
1. Not all the 3D cards support all the different operations
2. By default the rgb value of all the points is White = 255,255,255 (or (1,1,1) in 0-1 scale )
This is perfect for the BITMAP_OPERATION_MODE_MODULATE which is the default operation
but it is bad for operations like BITMAP_OPERATION_MODE_ADD
Because if the color already white and we add the texture color it will still be white
So when using BITMAP_OPERATION_MODE_ADD rember to call
BYTE rgb[3]={0,0,0};
STATE_group_set_light(NULL, rgb);
This will set the RGB values of all the points in the world to 0,0,0
|