Ignore:
Timestamp:
Apr 9, 2015, 9:58:36 PM (9 years ago)
Author:
chronos
Message:
  • Fixed: Use csOpaque control style also to Image, PaintBox and OpenGLControl.
  • Modified: Change size of test frame with SpinEdits as delayed using timer.
  • Updated: BRGABitmap package to version 8.1.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/Packages/bgrabitmap/phongdraw.inc

    r452 r472  
    7373  x,y : integer;      // Coordinates of point in height map.
    7474  vS1,vS2: TPoint3D_128; // surface vectors (plane)
     75  deltaDown: Int32or64;
     76  IsLineUp,IsLineDown: boolean;
    7577
    7678begin
     79  if map = nil then exit;
    7780  {$ifndef PARAM_SIMPLECOLOR}
    7881    {$ifndef PARAM_SCANNER}
     
    106109                  LightPosition.Y-ofsY,
    107110                  LightPositionZ);
    108   {$ifdef PARAM_PHONGSSE}
    109   asm
    110     movups xmm1, vLS
    111   end;
    112   LightDestFactor4 := Point3D_128(LightDestFactor,LightDestFactor,LightDestFactor,LightDestFactor);
    113   {$endif}
    114111
    115112  //surface vectors
     
    119116  vV := Point3D_128(0,0,1);
    120117
    121 
    122118  dist := 0;
    123119  LdotN := 0;
    124120  NnH := 0;
    125121
     122  {$ifdef PARAM_PHONGSSE}
     123  LightDestFactor4 := Point3D_128(LightDestFactor,LightDestFactor,LightDestFactor,LightDestFactor);
     124  {$endif}
     125
     126  if map.LineOrder = riloTopToBottom then
     127    deltaDown := map.Width*sizeof(TBGRAPixel)
     128  else
     129    deltaDown := -map.Width*sizeof(TBGRAPixel);
    126130  for y := miny to maxy do
    127131  begin
     
    138142      {$endif}
    139143    {$endif}
     144    IsLineUp := y > 0;
     145    IsLineDown := y < map.Height-1;
     146    mcTop := BGRAPixelTransparent;
     147    mcBottom := BGRAPixelTransparent;
    140148    for x := minx to maxx do
    141149    begin
    142150      mcLeft := mc;
    143151      mc := mcRight;
    144       inc(pmap);
    145152      if x < map.width-1 then
    146         mcRight := pmap^ else
     153        mcRight := (pmap+1)^ else
    147154        mcRight := BGRAPixelTransparent;
    148155      if mc.alpha = 0 then
     
    156163        {$endif}
    157164        inc(pdest);
     165        inc(pmap);
    158166        continue;
    159167      end;
    160168
    161169      //compute surface vectors
    162       mcTop := map.GetPixel(x,y-1);
    163       mcBottom := map.GetPixel(x,y+1);
     170      if IsLineUp then mcTop := pbgrapixel(pbyte(pmap)-deltaDown)^;
     171      if IsLineDown then mcBottom := pbgrapixel(pbyte(pmap)+deltaDown)^;
     172      inc(pmap);
     173
    164174      z := MapHeight(mc)*mapAltitude;
    165175      if mcLeft.alpha = 0 then
     
    196206      begin
    197207        {$DEFINE PARAM_USESSE3}
     208        asm
     209          movups xmm1, vLS
     210        end;
    198211        {$i phongdrawsse.inc}
    199212        {$UNDEF PARAM_USESSE3}
    200213      end else
    201214      begin
     215        asm
     216          movups xmm1, vLS
     217        end;
    202218        {$i phongdrawsse.inc}
    203219      end;
     
    221237
    222238        NH := DotProduct3D_128(vH,vN);
    223         if NH <= 0 then
    224           NnH := 0
    225         else
    226           NnH := exp(SpecularIndex*ln(NH));
    227239      {$endif}
    228240
     
    230242        NnH := 0
    231243      else
    232         NnH := exp(SpecularIndex*ln(NH));
     244        NnH := exp(SpecularIndex*ln(NH));  //to be optimized
    233245
    234246      distfactor := LightSourceIntensity / (dist*LightSourceDistanceFactor + LightSourceDistanceTerm);
Note: See TracChangeset for help on using the changeset viewer.