hadbadge2019_fpgasoc icon indicating copy to clipboard operation
hadbadge2019_fpgasoc copied to clipboard

Visual artifacts visible in scaling operation

Open Roger-random opened this issue 6 years ago • 2 comments

While working on the "Xbox One" style splash screen, I substituted the flying white 3D ball by scaling a white 2D circle. For scaling I copied gfx_set_xslate_val() from soc/ipl/main.c without zero understanding of how GFX_REG works.

When running at the desired full speed, the result is acceptable, but some people's eyes are fast enough to perceive "something is wrong" even if they can't perceive details of what.

When I slow the animation down with a delay of 100 instead of just 1, we can see visual artifacts including the following:

  • The X/Y position is shifting instead of staying on (xcenter,ycenter)
  • Tearing
  • Sometimes, for just a flash, the tiles are in completely incorrect places. (~12s mark)

https://youtu.be/u6LBOS6nGJ4

In case there have been multiple versions, this is the version of gfx_set_xslate_val() I copied/pasted.

void gfx_set_xlate_val(int layer, int xcenter, int ycenter, float scale, float rot) {
	float scale_inv=(1.0/scale);
	float dx_x=cos(rot)*scale_inv;
	float dx_y=-sin(rot)*scale_inv;
	float dy_x=sin(rot)*scale_inv;
	float dy_y=cos(rot)*scale_inv;
	float start_x=-xcenter;
	float start_y=-ycenter;
	
	int i_dx_x=64.0*dx_x;
	int i_dx_y=64.0*dx_y;
	int i_dy_x=64.0*dy_x;
	int i_dy_y=64.0*dy_y;
	int i_start_x=(-start_x+start_x*dx_x-start_y*dx_y)*64.0;
	int i_start_y=(-start_y+start_y*dy_y-start_x*dy_x)*64.0;
	
	GFX_REG(GFX_TILEA_OFF)=(i_start_y<<16)+(i_start_x&0xffff);
	GFX_REG(GFX_TILEA_INC_COL)=(i_dx_y<<16)+(i_dx_x&0xffff);
	GFX_REG(GFX_TILEA_INC_ROW)=(i_dy_y<<16)+(i_dy_x&0xffff);
}

Roger-random avatar Nov 05 '19 18:11 Roger-random

Code is at https://github.com/Roger-random/hadbadge2019_fpgasoc/tree/master/app-xbox

Roger-random avatar Nov 05 '19 18:11 Roger-random

Update: Code has been folded into app-autoexec

Roger-random avatar Nov 06 '19 06:11 Roger-random