Class TPhongShading
Unit
Declaration
type TPhongShading = class(TCustomPhongShading)
Description
Renders shape and height maps using Phong shading.
Phong shading consist in adding an ambiant light, a diffuse light (angle between light and object), and a specular light (angle between light, object and observer, i.e. reflected light).
Height maps are grayscale images or a precise bitmaps filled with MapHeightToBGRA. They are used to determine orientation and position of the surface.
See tutorial on Phong shading.
Hierarchy
- TObject
- TCustomPhongShading
- TPhongShading
Overview
Fields
AmbientFactor: Single; |
|
DiffuseSaturation: Boolean; |
|
DiffusionFactor: Single; |
|
LightColor: TBGRAPixel; |
|
LightDestFactor: Single; |
|
LightSourceDistanceFactor: Single; |
|
LightSourceDistanceTerm: Single; |
|
LightSourceIntensity: Single; |
|
NegativeDiffusionFactor: Single; |
|
SpecularFactor: Single; |
|
SpecularIndex: Single; |
Methods
constructor Create; |
|
procedure Draw(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; ColorMap : TBGRACustomBitmap); override; |
|
procedure Draw(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; Color : TBGRAPixel); override; |
|
procedure DrawCone(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); overload; |
|
procedure DrawCone(dest: TBGRACustomBitmap; X,Y,Size: Integer; Altitude: Single; Color: TBGRAPixel); overload; |
|
procedure DrawHorizontalCylinder(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); |
|
procedure DrawRectangle(dest: TBGRACustomBitmap; bounds: TRect; Border: Integer; Altitude: Single; Color: TBGRAPixel; RoundCorners: Boolean; Options: TRectangleMapOptions); |
|
procedure DrawScan(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; ColorScan : IBGRAScanner); override; |
|
procedure DrawSphere(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); |
|
procedure DrawVerticalCone(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); |
|
procedure DrawVerticalCylinder(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); |
|
procedure DrawColorNormal(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; Color : TBGRAPixel); |
|
procedure DrawMapNormal(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; ColorMap : TBGRACustomBitmap); |
|
procedure DrawScannerNormal(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; ColorScan : IBGRAScanner); |
Description
Fields
AmbientFactor: Single; |
|
how concentrated reflected light is (positive value) |
DiffuseSaturation: Boolean; |
|
how much hidden surface are darkened (0..1) |
DiffusionFactor: Single; |
|
ambiant lighting whereever the point is (0..1) |
LightColor: TBGRAPixel; |
|
how much the location of the lightened pixel is taken into account (usually 0 or 1) |
LightDestFactor: Single; |
|
how much actual distance is taken into account (usually 0 or 1) |
LightSourceDistanceFactor: Single; |
|
minimum distance always added (positive value) |
LightSourceDistanceTerm: Single; |
|
global intensity of the light |
LightSourceIntensity: Single; |
|
This item has no description. |
NegativeDiffusionFactor: Single; |
|
diffusion, i.e. how much pixels are lightened by light source (0..1) |
SpecularFactor: Single; |
|
color of the light reflection |
SpecularIndex: Single; |
|
how much light is reflected (0..1) |
Methods
constructor Create; |
|
when diffusion saturates, use light color to show it |
procedure Draw(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; ColorMap : TBGRACustomBitmap); override; |
|
Render with a color map of the same size as the height map. Map altitude indicate the global height of the map. |
procedure Draw(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; Color : TBGRAPixel); override; |
|
Render the specified map on the destination bitmap with one solid color. Map altitude indicate the global height of the map. |
procedure DrawCone(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); overload; |
|
This item has no description. |
procedure DrawCone(dest: TBGRACustomBitmap; X,Y,Size: Integer; Altitude: Single; Color: TBGRAPixel); overload; |
|
Draw a cone of the specified color |
procedure DrawHorizontalCylinder(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); |
|
Draw an horizontal cylinder of the specified color |
procedure DrawRectangle(dest: TBGRACustomBitmap; bounds: TRect; Border: Integer; Altitude: Single; Color: TBGRAPixel; RoundCorners: Boolean; Options: TRectangleMapOptions); |
|
Draw a rectangle of the specified color |
procedure DrawScan(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; ColorScan : IBGRAScanner); override; |
|
Render with a color scanner. Map altitude indicate the global height of the map. |
procedure DrawSphere(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); |
|
Draw a hemisphere of the specified color.
Example drawing a red sphere on a form:
procedure TForm1.FormPaint(Sender: TObject); var image: TBGRABitmap; phong: TPhongShading; begin phong := TPhongShading.Create; phong.LightPosition := Point(100, 100); phong.LightPositionZ := 150; phong.SpecularIndex := 20; phong.AmbientFactor := 0.4; phong.LightSourceIntensity := 250; phong.LightSourceDistanceTerm := 200; image := TBGRABitmap.Create(ClientWidth,ClientHeight,ColorToBGRA(ColorToRGB(clBtnFace))); phong.DrawSphere(image,rect(20,20,120,120),50,BGRA(255,0,0)); image.Draw(Canvas,0,0,True); image.free; end; |
procedure DrawVerticalCone(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); |
|
Draw a vertical cone of the specified color |
procedure DrawVerticalCylinder(dest: TBGRACustomBitmap; bounds: TRect; Altitude: Single; Color: TBGRAPixel); |
|
Draw a vertical cylinder of the specified color |
procedure DrawColorNormal(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; Color : TBGRAPixel); |
|
This item has no description. |
procedure DrawMapNormal(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; ColorMap : TBGRACustomBitmap); |
|
This item has no description. |
procedure DrawScannerNormal(dest: TBGRACustomBitmap; map: TBGRACustomBitmap; mapAltitude: single; ofsX,ofsY: integer; ColorScan : IBGRAScanner); |
|
This item has no description. |