procedure TfrmDLGPerlin.GenerateSphere;
var
Phong: TPhongShading;
Light : TPoint;
begin
if not assigned(bgraView) then BgraView := TBGRABitmap.Create(seWidth.value, seHeight.value, BGRAPixelTransparent)
else BgraView.SetSize(seWidth.value, seHeight.value);
// Clear background
BgraView.Rectangle(0, 0, seWidth.value, seHeight.value, BGRAPixelTransparent, BGRAPixelTransparent);
phong := TPhongShading.Create;
try
phong.LightPositionZ := 150;
phong.SpecularIndex := 20;
phong.AmbientFactor := 0.4;
phong.LightSourceIntensity := 250;
phong.LightSourceDistanceTerm := (seWidth.value div 2);
Light.x := (seWidth.value div 2);
Light.y := (seHeight.value div 2);
phong.LightPosition := Light;
phong.DrawSphere(BgraView, rect(0, 0, seWidth.value, seHeight.value), (seWidth.value div 2), ColorToBgra(ColorToRGB(cb01.ButtonColor)));
finally
Phong.free;
end;
rst.x := bgraView.width;
rst.y := BgraView.Height;
end;