I guess I'll start

The Partridge Family were neither partridges nor a family. Discuss.
albinopapa
Posts: 3745
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I guess I'll start

Post by albinopapa » May 28th, 2019, 9:21 am

Little to no progress made, has been a busy few days. School is out and memorial day in the states had me spending time with the family. I just need to recover and I'll be back at it.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
chili
Site Admin
Posts: 3822
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: I guess I'll start

Post by chili » May 29th, 2019, 3:40 am

Yeah, generally you use coarse layers for sprites/tiles, and then within a layer you'd sort sprites by y-coordinate. Then you can dispense with z-buffering and use painter's.
Chili

albinopapa
Posts: 3745
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I guess I'll start

Post by albinopapa » June 2nd, 2019, 6:36 am

Sigh, well, it happened. The graphics stuff got to me and now I'm on a trip down 2D to 3D hell.

My mental gymnastics is terrible. Took me a few days before I realized what I was doing wrong.

The goal: Convert 2D to 3D coordinates the easy way...just add Z.
My thought process was to just make Z my height and since the maze was in the XY plane, Z would just be my height. Well, changing the camera to 3 dimensions then using it plus a rotation about the X axis to get that isometric look was really stumping me. I ended up figuring out that X and Y could literally be used in the same way it works in 2D just leaving the damned camera on the ground, like it's looking at a wall.

Anyway, I've almost gotten that part working the way I want it, I think there's something wrong though as rotation of the camera around the board/maze tends to cut off the image. It might be too close, I'm not sure yet. I'm setting up some stuff to move the camera freely so I can get some numbers that work.

I think my 2D algorithm library may have been the biggest bottleneck actually. Switching to the 3D Fundamentals Framework pipeline has already boosted the fps by 2-3 times. I'll have to remove all that and keep it simple. At least when I do, there won't be any more dependencies to worry about.

Something I've considered is to just return the iterator. This might help some since returning the index and the reference was doing twice the work and somewhat repetitive. Maybe something simple like

Code: Select all

template<typename T>
struct IteratorObject
{ 
   T& objref;
   int x, y; 
};
Momentum has slowed for sure. I've not been sleeping well and get up later and later each day. Part of it is because of the graphics issue, and part of it is distractions. My family has planned a trip to Chicago and planning for it and getting mentally prepared for a trip I didn't want to take in the first place has really been eating at me. Oh, plus the wife wants me to get off my ass and find a job. I'm kind of nervous and screwed on this one. I have been collecting disability for 11 years now so my resume isn't looking too hot.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 3745
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I guess I'll start

Post by albinopapa » June 4th, 2019, 1:57 am

I was a bit premature in stating that the framerate was better using the pipeline. I'm actually getting around the same, so it seems the biggest issue is the work per pixel being done in both instances. In other words, both the 3D fundamentals pipeline approach and using pseudo 3D approach and my library didn't have much of a difference between them. At 1280x720 I still get around 35 fps when the entire screen has to be filled.

I will still be using the pipeline approach though as this seems to be a tad more clean and flexible than my original approach. Especially since I needed to add triangle rasterization in anyway for sprite rotations.

I'm still getting use to 2D to 3D coordinate system. I was hoping to get an orthogonal projection working, but am having an issue with scale. I'm going to assume zooming out would be equivalent to scaling the view? What I am running into is without the perspective divide, the maze quad is so zoomed in and I can't tell if the camera is rotated to get that isometric look.

I'll be spending a couple days on getting back to where I was ( collisions, movement ) and trying my hand at writing down some ideas for the rest of the game for when I get back from Chicago.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 3745
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I guess I'll start

Post by albinopapa » June 9th, 2019, 8:51 pm

I wish I would have given it more thought, but I seem to be taking the long road.

Using the screen's coordinate system as the starting point and now switching to +Y is up is giving me a headache. If I had kept it as is and just subtracted position height from the world height or screen when sending everything to the rendering pipeline, I would have less to think about. Right now, I'm having to going through the code and swapping < or > signs and make sure the calculations are done using +Y is up and -Y is down. It's confusing me to think in two or three different coordinate systems.

The world coordinate system and the pipeline both have +Y going up, but I decided to keep the top left of the world at ( 0,0 ) so that I can just negate the Y to get the 2D coordinates of the tiles. All my rectangles originally had the top as a lower value than the bottom, that has now switched, which affects collision handling and comparisons.

Long story short, a little planning and foresight gets you far.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

MrGodin
Posts: 709
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: I guess I'll start

Post by MrGodin » June 10th, 2019, 12:46 pm

OpenGL is the same 0,0 is bottom left. What I did was use the Orthographic Matrix (for projection) and switched the top and bottom variables and then i had to flip the UV coords for texture mapping.

Code: Select all

m_proj = Math::mat4::Orthographic(left, right, top, bottom, _near, _far);
The Orthographic matrix wants to be initialized as lef,right,bottom,top,near,far.
...
m_columns = (unsigned int)(m_Width / (int)clipSize.width);
		m_rows = (unsigned int)(m_Height / (int)clipSize.height);
		m_scanInc.x = 1.0f / (float)m_columns;
		m_scanInc.y = 1.0f / (float)m_rows;
...
// Inverse UV Coordinates
std::vector<Math::vec2> TextureAtlas::getTextureCoords(const unsigned int & row, const unsigned int & column)
	{
		
		std::vector<Math::vec2> result;
		result.resize(4);
		unsigned int inverseRow =  (m_rows - 1) - row;

		result[3] = Math::vec2(m_scanInc.x * (float)column, m_scanInc.y *  (float)inverseRow);
		result[2] = Math::vec2(m_scanInc.x * (float)(column + 1), m_scanInc.y * (float)inverseRow);
		result[1] = Math::vec2(m_scanInc.x * (float)(column + 1), m_scanInc.y *  (float)(inverseRow + 1));
		result[0] = Math::vec2(m_scanInc.x * (float)(column), m_scanInc.y * (float)(inverseRow + 1));

		
		return std::move(result);
		
	}
Now everything is ok to assume 0,0 is top ,left
Curiosity killed the cat, satisfaction brought him back

albinopapa
Posts: 3745
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I guess I'll start

Post by albinopapa » June 10th, 2019, 7:10 pm

Hmm, I didn't think about swapping the texture coordinates.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

Post Reply