I guess I'll start

The Partridge Family were neither partridges nor a family. Discuss.
MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: I guess I'll start

Post by MrGodin » May 20th, 2019, 11:06 pm

I did my lighting like so. Frag shader

Code: Select all

#version 330 core

layout (location = 0) out vec4 out_color;


uniform vec3 in_lightPos;

uniform float in_lightSize;

in Data
{
  vec4 position;
  vec4 normal;
  vec2 uv;
  float tex_id;
  vec4 color;
} fs_in;
uniform sampler2D texture_array[32];

void main()
{
 float intensity = 1.0f / length(in_lightPos - fs_in.position.xyz);
 out_color = fs_in.color * intensity * in_lightSize;;
 if(fs_in.tex_id > 0.0f)
  {
	int index = int(fs_in.tex_id - 0.5f);
	out_color = texture(texture_array[index],fs_in.uv)* (intensity) * in_lightSize;
	out_color.a >= 1.0f  ? out_color = texture(texture_array[index],fs_in.uv) : out_color = out_color;
  }
}
Curiosity killed the cat, satisfaction brought him back

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

Re: I guess I'll start

Post by MrGodin » May 20th, 2019, 11:08 pm

The way you want to render the images seems like a cool way to do it. I've never thought of it like that.
Curiosity killed the cat, satisfaction brought him back

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

Re: I guess I'll start

Post by albinopapa » May 21st, 2019, 5:41 am

Is that an OpenGL fragment shader? A lot of that stuff looks foreign to me. Didn't know you went on to OpenGL, or have forgotten.

From what I can tell, you are using an interpolated alpha value, which I have done many a time in 2D and will ultimately be similar to what I do in my current game. The difference being ray casted shadows. Hadn't thought about this part until now, but casting shadows from entities might be a bit too much unless I just use their bounding rectangles.

I have started the rework on the tile map. I think I'm actually about half way done. A lot of the code has been simplified because of this and that was what I was hoping for, well and maybe a little speed boost since I'm actually doing fewer calculations, but I'll just have to see once I'm finished. My goal is easier access to tiles for collision detection between entities and walls and I am definitely achieving that, if I get a boost in performance great. This is actually something that has held me back in the past is focusing too early on performance.

Right now I know that if my CPU can do the work at a somewhat playable frame rate, then I know moving it to GPU will be awesome.

Not much more to report on right now until I get the rework done and tested. The only thing of note is I saved the commit before the rework, so fingers crossed I don't mess this up and have to undo a couple of hours work.
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: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I guess I'll start

Post by albinopapa » May 21st, 2019, 4:18 pm

Got the rework finished, didn't test FPS before and after, so don't know how it affected things other than doing so fixed the collision issue as I had hoped it would.

I added an FPS counter to the HUD at the bottom. I still get around 60 fps ( 59 or 60 ) in Release, so time to move on to enemies.

I came up with a few ideas to further the games purpose.

My initial goal of the project is to use all the features I've added to the chili framework, but so far the main thing used has been the 2D algorithms and containers. I am using the Font and Sprite loader I made, I don't use GDI+, instead I use WIC for loading images and DirectWrite for loading fonts then Direct2D to create FontSheets during program start. I'm sure I'll be using some more features as I go, one will be my Text class which formats the text layout like line wrapping.

BTW, I've pushed the changes to GitHub should still be under the FeatureTest branch and the link and required dim2d headers are in the first post of this thread.
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: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: I guess I'll start

Post by MrGodin » May 22nd, 2019, 12:21 am

Yes I am doing OpenGL now (stated that when i posted images). I find it a lot simpler than Direct3D but obviously not as powerful. I'll take a look at what you're doing when i get a chance to. I am very interested if reviewing your code, always nice to find nuggets of information to make things simpler ;)
Curiosity killed the cat, satisfaction brought him back

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

Re: I guess I'll start

Post by albinopapa » May 22nd, 2019, 7:25 am

Well, shit, you sure did. After reading it again, I guess I stopped a line early last time.

If you check out my code, make sure to grab the zip file of headers as well. Read the first post on what the project is expecting.
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: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I guess I'll start

Post by albinopapa » May 23rd, 2019, 8:45 am

Sigh, looks like I am going to need to figure something out sooner rather than later. Just added a pseudo depth test to make sprites render in the correct order ( bottom == closer ) and it dropped frame rate on my machine to around 30 fps. At this rate, I can't imagine adding anything extra that will just increase frame time.

I've got ideas on where to go from here. I'll worry about graphics later.
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: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: I guess I'll start

Post by albinopapa » May 23rd, 2019, 6:10 pm

Image
This is the object clipping I want, but need to figure out a better way than per pixel pseudo depth buffering.

I know I said worry about it later, but it's bugging me lol.

After some searching, someone on the net suggested using sorted layers. I could probably get an idea from chili's "Project Twin", and I may end up doing that. I could also reduce the resolution, currently it's whatever size the desktop resolution is, so it will be different depending on what yours is. I'll probably start there actually. I want fullscreen and don't need 16:9 view, but I can use the extra space for user interface perhaps.
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: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: I guess I'll start

Post by MrGodin » May 23rd, 2019, 8:07 pm

Thats what I do, in my Application class i have a layerStack in which I push layers to. First layer is the map, second layer is entities. Also in 2D you can use a 3D positional vector where you set the z to be a render order variable.
Curiosity killed the cat, satisfaction brought him back

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

Re: I guess I'll start

Post by albinopapa » May 23rd, 2019, 11:17 pm

Yeah, I thought about that and that's where I came up with using the Y component from the bottom of the bounding rectangle as the test case.

I'm kind of torn about something though. I am currently treating each tile as it's own drawable entity which has state ( wall or floor ) and has a pointer to a sprite. The sprite is basically the same for the entire floor, but changes depending on if it's a wall and the wall's orientation ( north and east facing are darker than south and west facing ). I'm wondering if it would make a difference if I just made the floor one large quad and tile the floor texture on one layer, then have the walls on the next layer and draw them separately as I do now.

Either way, I have lowered the resolution to 1280x720x32 and made it full screen and it's back up to 50 fps. Anything I do, move to 3D software or hardware and such is going to take some work rewriting the project. I know I should decide now before I get too much further, but I don't want to delay progress either.
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