Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
2.1 KiB
Common Lisp
Raw Normal View History

#include "calcfirstder.cl"
2018-07-06 09:29:14 +02:00
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
2018-07-04 14:27:41 +02:00
2018-07-04 18:55:54 +02:00
__kernel void processNineCellWindow( __global float *scanLine1,
__global float *scanLine2,
__global float *scanLine3,
__global float *resultLine,
__global float *rasterParams // mInputNodataValue, mOutputNodataValue, mZFactor, mCellSizeX, mCellSizeY, zenith_rad, azimuth_rad
)
{
2018-07-04 18:55:54 +02:00
// Get the index of the current element
const int i = get_global_id(0);
if ( scanLine2[i+1] == rasterParams[0] )
2018-07-04 18:55:54 +02:00
{
resultLine[i] = rasterParams[1];
2018-07-04 18:55:54 +02:00
}
else
{
float derX = calcFirstDer( scanLine1[i], scanLine1[i+1], scanLine1[i+2],
scanLine2[i], scanLine2[i+1], scanLine2[i+2],
scanLine3[i], scanLine3[i+1], scanLine3[i+2],
rasterParams[0], rasterParams[1], rasterParams[2], rasterParams[3] );
2018-07-06 09:29:14 +02:00
float derY = calcFirstDer( scanLine3[i], scanLine2[i], scanLine1[i],
scanLine3[i+1], scanLine2[i+1], scanLine1[i+1],
scanLine3[i+2], scanLine2[i+2], scanLine1[i+2],
rasterParams[0], rasterParams[1], rasterParams[2], rasterParams[4]);
2018-07-06 09:29:14 +02:00
if ( derX == rasterParams[1] || derY == rasterParams[1] )
{
resultLine[i] = rasterParams[1];
2018-07-06 09:29:14 +02:00
}
else
{
float slope_rad = sqrt( derX * derX + derY * derY );
slope_rad = atan( slope_rad );
float aspect_rad;
if ( derX == 0.0f && derY == 0.0f)
aspect_rad = rasterParams[7] / 2.0f;
else
aspect_rad = M_PI + atan2( derX, derY );
2018-07-04 18:55:54 +02:00
resultLine[i] = max(0.0f, 255.0f * ( ( rasterParams[5] * cos( slope_rad ) ) +
( rasterParams[6] * sin( slope_rad ) *
cos( rasterParams[7] - aspect_rad ) ) ) );
2018-07-04 18:55:54 +02:00
2018-07-06 09:29:14 +02:00
}
2018-07-04 18:55:54 +02:00
}
2018-07-04 14:27:41 +02:00
}