Animation system of climb on shelfs that allows the main character to use various climb animation depending on the sytuation. For now there is 7 different sytuations of collision with a shelf:
- jump on/drop with knees at the height of a shelf (23 sec)
- jump on with hips at the height of a shelf (59 sec, it will be improv)
- drop with hips at the height of a shelf (29 sec, 36 sec)
- jump on with chest at the height of a shelf (53 sec)
- drop with chest at the heights of a shelf (38 sec)
- jump on with the head under a shelf (9 sec, 43 sec)
- jump up with the head under a shelf (0 sec)
The jump up/foward animation is also done. Every of these animations you can see on a video below:
Second issue I want to share is a glare filter for image postprocessing. I cant find anywhere the algorithm of this effect so I tried to make my own and it's work fine as you can see on a video below:
If someone want to use it in your game, you can do it on CC0 licence. Algorithm can be easily improved, becouse I use in it a few constant integers, but they can be repleced by variables dynamicly changing during game.
The glare algorithm as OpenCL-C kernel:
kernel void GlareKernel(global const int* pixels, int width, int height, int numDataElements, global int* newpixels, int maxDataSize, float glare, int r, int smoth) {
int idx = get_global_id(0);
if (idx >= maxDataSize) {
return;
}
newpixels[idx] = pixels[idx];
if ((idx & 3) == 3) {
int i = idx / numDataElements;
int yl_ = (i + 1) / width;
int xl = i + 1 - yl_ * width;
int yl = xl > 0 ? yl_ + 1 : yl_;
float glareSum = 0;
for (int k = xl - r; k <= xl + r; k++) {
for (int j = yl - r; j <= yl + r; j++) {
int X = k - xl;
int Y = j - yl;
int d = (int)abs((int)abs(X) - (int)abs(Y));
int s = (int)(((float)abs(X) + (float)abs(Y))/(float)(r/2));
if (d+s < smoth) {
int idx = (j * width + k - 1) * numDataElements - 1;
if (idx >= 0 && idx < width*height*numDataElements) {
int A = pixels[idx];
int B = pixels[idx - 1];
int G = pixels[idx - 2];
int R = pixels[idx - 3];
if (A > 250 && R + G + B > 600) {
float D = sqrt((float)(X*X+Y*Y));
float dk = 3*(float)r;
float sg = (dk - D)/dk;
float SG = (float)(smoth - d-s)/(float)smoth;
glareSum += glare*sg*SG;
}
}
}
}
}
int GS = (int)glareSum;
newpixels[idx] = max(0, min(255, newpixels[idx] + GS));
newpixels[idx - 1] = max(0, min(255, newpixels[idx - 1] + GS));
newpixels[idx - 2] = max(0, min(255, newpixels[idx - 2] + GS));
newpixels[idx - 3] = max(0, min(255, newpixels[idx - 3] + GS));
}
}