Changeset 472 for GraphicTest/Packages/bgrabitmap/phongdraw.inc
- Timestamp:
- Apr 9, 2015, 9:58:36 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/bgrabitmap/phongdraw.inc
r452 r472 73 73 x,y : integer; // Coordinates of point in height map. 74 74 vS1,vS2: TPoint3D_128; // surface vectors (plane) 75 deltaDown: Int32or64; 76 IsLineUp,IsLineDown: boolean; 75 77 76 78 begin 79 if map = nil then exit; 77 80 {$ifndef PARAM_SIMPLECOLOR} 78 81 {$ifndef PARAM_SCANNER} … … 106 109 LightPosition.Y-ofsY, 107 110 LightPositionZ); 108 {$ifdef PARAM_PHONGSSE}109 asm110 movups xmm1, vLS111 end;112 LightDestFactor4 := Point3D_128(LightDestFactor,LightDestFactor,LightDestFactor,LightDestFactor);113 {$endif}114 111 115 112 //surface vectors … … 119 116 vV := Point3D_128(0,0,1); 120 117 121 122 118 dist := 0; 123 119 LdotN := 0; 124 120 NnH := 0; 125 121 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); 126 130 for y := miny to maxy do 127 131 begin … … 138 142 {$endif} 139 143 {$endif} 144 IsLineUp := y > 0; 145 IsLineDown := y < map.Height-1; 146 mcTop := BGRAPixelTransparent; 147 mcBottom := BGRAPixelTransparent; 140 148 for x := minx to maxx do 141 149 begin 142 150 mcLeft := mc; 143 151 mc := mcRight; 144 inc(pmap);145 152 if x < map.width-1 then 146 mcRight := pmap^ else153 mcRight := (pmap+1)^ else 147 154 mcRight := BGRAPixelTransparent; 148 155 if mc.alpha = 0 then … … 156 163 {$endif} 157 164 inc(pdest); 165 inc(pmap); 158 166 continue; 159 167 end; 160 168 161 169 //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 164 174 z := MapHeight(mc)*mapAltitude; 165 175 if mcLeft.alpha = 0 then … … 196 206 begin 197 207 {$DEFINE PARAM_USESSE3} 208 asm 209 movups xmm1, vLS 210 end; 198 211 {$i phongdrawsse.inc} 199 212 {$UNDEF PARAM_USESSE3} 200 213 end else 201 214 begin 215 asm 216 movups xmm1, vLS 217 end; 202 218 {$i phongdrawsse.inc} 203 219 end; … … 221 237 222 238 NH := DotProduct3D_128(vH,vN); 223 if NH <= 0 then224 NnH := 0225 else226 NnH := exp(SpecularIndex*ln(NH));227 239 {$endif} 228 240 … … 230 242 NnH := 0 231 243 else 232 NnH := exp(SpecularIndex*ln(NH)); 244 NnH := exp(SpecularIndex*ln(NH)); //to be optimized 233 245 234 246 distfactor := LightSourceIntensity / (dist*LightSourceDistanceFactor + LightSourceDistanceTerm);
Note:
See TracChangeset
for help on using the changeset viewer.