New Reply
Name
×
Email
Subject
Message
Files Max 5 files50MB total
Tegaki
Password
[New Reply]


519de92bb2e773a0b1f20e07ddf87d494ab3c92e7db7c1fd0bc26d26f1655573.png
[Hide] (5.3MB, 2048x2048)
Post what you're working on, won't you?

Previous thread: >>123
arbitrarily_long_stack.png
[Hide] (34.3KB, 1056x256)
round.png
[Hide] (66KB, 768x512)
I ran into a problem. I want to add decorations that are on the ground and can overlap (like a carpet with some trash or blood stains on top), but the problem is that you can't draw them in the correct order without knowing, across the whole map, which decoration was placed first.

One potential idea is that rather than drawing them as part of the floor grid, I could collect and sort all the decorations that are visible on screen, and draw them as-is. But then, a related question is how to store them since that affects how you find and sort them.
1. Store them similarly to furniture (each tile has the decoration's ID, and an offset that points to it's "origin tile") except each tile has a list of decorations. There's a potential performance cost, since you'd have to recursively search 9 lists every time you touch a 3x3 decoration, and every time need to check the render list to make sure you don't add a decoration to it twice.
2. Store them in a list per map chunk. This would automatically make them sorted, but then how do you sort them across chunks? I could use a layer value, which would allow problems to be fixed manually (assuming there's a building mechanic in the game), and any other situation will have undefined behavior.
3. Rather than a list per-chunk, have a global list of decorations, and each chunk has a list of indexes onto to it. This would make all the objects across the whole map sorted, which would certainly be the easiest. The main limiting factor would be that it's complicated to place a new decoration below another since you'd have to fix all the indices. May also have unnecessary problems with data locality: 2 decorations next to each other that don't overlap may be in completely different memory locations in the list.

The biggest advantage of having things in map tiles is that if I want them to have physical modifiers (splash sounds when you walk on a puddle of blood, conducting electricity, etc), you can find the decoration(s) directly from the tile. I could do a combination of 1 and 3: each tile has a list of indices that point to a global decoration list.

This would be a lot easier if the game wasn't rotated, since I could just draw the decorations as multiple small rectangles per-tile. I COULD programmatically cut the sprite into 1x1 tiles as part of the game's initialization, that would allow me to treat them exactly like floor tiles (except with rotation). I'm considering doing this since it's by far the simplest, and I may be able to merge the floor rendering and floor decoration rendering into some kind of tile renderer which will probably be super efficient too.
Replies: >>1613 >>1616
>>1612
If these are floor decals you should just be rendering them all once to a texture then draw that. For ordering just do near to far, left to right for consistent ordering.
Replies: >>1614 >>1615 >>1616
>>1613
Fug I mean far to near, not near to far.
conundrum.png
[Hide] (53.6KB, 768x512)
>>1613
>rendering them all once to a texture then draw that
I have been considering it because then I could add bullet shells and procedurally generate blood splatters and footsteps and explosion stains etc infinitely without affecting performance. I also want to allow the player to spray paint on the floors. I stopped thinking about it because I was too lazy to come up with a way to mask things into the correct region (so a blood splatter gets cut off at the edge of a chunk and continues on the next texture). May end up doing it though.

>left to right
If the order is based on position then some configurations like pic related would be impossible.
Replies: >>1616
dirt_roads_shitty.png
[Hide] (766.3KB, 1000x500)
ClipboardImage.png
[Hide] (1.1MB, 994x495)
>>1612
I think I posted about same exact problem multiple times. 
The simplest solution is to have 1 sprite per coordinate, and nothing goes outside of tile borders. And you dont need to sort anything, just render decorations on top of each other, in added order. And you can store "wide" sprites in the lowest part of the coordinate grid, so they are rendered the last, and that they are actually part of the floor layer. 
Ultimately it depends on the amount of stuff you need to render. If its 100 decals per map chunk, all of which are in the same RENDER order layer, you can store them as a simple array and sort it once. It all depends on number of tile variations you have.
Decorations are just a rendering order problem. 
You probably should just use the most simple approach. Background "skybox">Floor grid>Wall grid> few Decal layer grids1[x][y] drid2[x][y]>Shadow layer>Actor layer. When you start to think about it, it doesnt work perfectly, and shadows especially start fucking up, but its not that big of a deal. And most of these matrixes are empty, but its not a big deal, because you can always change it later, when you know how much data you have to worry about. 
 I spoke about it before, but in CNC2 shadows look in random directions, and in diablo 2 flames have shadows.
>player edited
>placing stuff below
Without proper Z level system, even with a few layers of decal grids, its too much to ask. The best you can do, is have your procedurally generated/loaded map, load as usual into memory, and have a list of player edits, to modify it, loaded afterwards. Yes, all of them at the same time, after each minor change. And its okay, because you dont know if it even will be a performance hit, you just theorize it will be slow because worrying about "but what if he made a million changes to the map" is pointless, before you even know how bad it is. You optimizing them, before you even have any of them. 
You trying to fit unknown number of tiles, with unknown shape, into unknown number of containers. 
>>1613
>rendering at once
Doesnt work, if you have lighting system, you cant render part of the image brighter or darker, without chopping it during rendering. You can make it "per room" system, but it overcomplicates things. 
>>1615
>impossible in this configuration
Normally people just pre-render all of literal edge cases.
Replies: >>1617
split.png
[Hide] (10.2KB, 579x194)
infinite_lights.webm
[Hide] (2.8MB, 1920x1080, 00:40)
>>1616
Those roads look pretty good. Why do you have so 14 variations of one of the straight road pieces though?

>1 sprite per coordinate, and nothing goes outside of tile borders
Programmatically splitting the decals into 1x1 sprites as I mentioned would have that exact effect, they even use the same amount of texture space (if you don't use a diagonal mesh). I'm the most likely to do this.

>if you have lighting system, you cant render part of the image brighter or darker
You can render lighting into a separate texture and draw it on top of all the floor sprites, that's how I made webm related. I plan to do the same for this game, although I'll have to rotate it into an isometric shape, and shade objects/walls separately.

You could also add the floor texture into a rotated grid mesh with a different color on each vertex.
Replies: >>1618 >>1620
>>1617
Neat light system, Anon!
RIP sleepychan's /agdg/ threads, killed by one mongoloid and retarded mods who won't do anything.
Replies: >>1621
25_tiles_roads1000x500.png
[Hide] (69KB, 1000x500)
>>1617
>14 variations of one of the straight road pieces though
One is to avoid identical tiling, but mostly to avoid "empty" tiles, might as well add regular straight variations. They are actually quite annoying to make. 
>>1617
>Programmatically splitting the decals into 1x1 sprites as I mentioned would have that exact effect, they even use the same amount of texture space (if you don't use a diagonal mesh). I'm the most likely to do this.
Yeah, but to store/pass rendering data its different. Rendering a grid and rendering overlapping shapes are different. You either have to make a complex tile rendering order system, or just ignore some problems.
>You could also add the floor texture into a rotated grid mesh with a different color on each vertex.
At this point you just making 3d engine, but intentionally avoiding using 3d. But honestly it might be the way to do anything. Real 2d engines are just too primitive, compared to modern 3d api. And if you dont go crazy, performance difference between real2d and 3d engines is below 1 frame.
Replies: >>1624
>>1619
What happened? I haven't been there in a while.
Replies: >>1623
Learning lua for love2d. Maybe I'll be done in a week.
>>1621
A literal retard shits the thread with nonsensical gibberish.
decal_layering.png
[Hide] (59.4KB, 1242x1040)
>>1620
>Rendering a grid and rendering overlapping shapes are different
>You either have to make a complex tile rendering order system, or just ignore some problems.
I'm pretty sure it just works though. All you need is an array of decal IDs and offsets on each tile (and maybe some flags like rotation), and then you just loop through the tiles and send the world position and texture position of each sprite to the GPU. It might(?) get messed up if you try to modify the layering after already placing things, but you can just move it fully on top or fully bottom to make sure it works.

>At this point you just making 3d engine, but intentionally avoiding using 3d
A sprite quad is 2 triangles too. Unless you're doing software rendering, you're just changing where you put vertices. You don't really even need to "rotate" it, you can just put the vertices where they need to be.
Replies: >>1625 >>1641
>>1624
Its mode due to storing/rendering map data, and being as simple as possible. 
map[layer][x][y] is easier to work with when only a single object(tile/actor) can be placed into array coordinate. 
Lets say you have floor[x][y] which is 80% filled with data. And you have decals[x][y] which is 5% filled. You can optimize decals rendering by storing them into a different storage, instead of mostly empty matrix, but that would require you to add additional rendering code, specific for them. And in that case, you might as well use this new code, to render floor as well. But its more complicated and likely doesnt improve anything in any meaningful way. 
So its better to keep everything as simple as possible. Non-overlaping sprites are always better than overlapping ones. Odds are its better to have floor>walls>actors rendering, with everything being backed into floor, or walls, without any furniture/decals/whatever as separate entities/layers. It will take more storage, but in reality its fucking nothing. How many variations of floor/furniture you going to have? 

But main point is simplicity.
I was having trouble with slopes and so I looked at another project that did it well.
Long story short, I'm very tempted to just lift the code.
Replies: >>1634
>>1633
>Long story short, I'm very tempted to just lift the code.
Ahh. The way of the mathematician, ehh?  :D

Well, join the club Anon. We've all been standing on the 'Shoulders of Giants' of those who have gone before us since time immemorial.

Good luck with your project, Anon. Cheers.  :)
piglet.jpg
[Hide] (86.3KB, 455x460)
As Oneko is classified as "game" on my system, here we go.
My gf is interested to go the Linux way so I like to teach her some things about the system, things as simple and cute as Oneko ie. She loved that little cat but she told me it would be awesome to have a little pig in place of it.
So, I found the source code (written, in C) and I'm trying to build my own fork with that cute piglet. For now I just spent the afternoon drawing the pig in a bitmap drawing online program (one with a canvas and you draw pixel by pixel because I have no idea how to do it with only code and I'm a bit lazy to do it this way. I'm more into drawing than coding anyway).
Once the drawing work would be finished I will look further into how to implement it. I never studied coding and the few I see when lurking on the code is a bit frigthening for me but I think it can be a fun project to learn a bit.
Replies: >>1637 >>1639
cake_cursor.png
[Hide] (509B, 133x134)
oneko.webm
[Hide] (2.6MB, 1280x720, 00:31)
>>1635
The funniest part was the bitmap drawing.
I used the default neko as a base and I'm qui pleased by the result, especially the pig noise movements (the funniest part of the pig).
I launch it with arguments
-bg ping -fg black for obvious piggish pink.

Rewriting the C code was less fun but interesting to do but when comes time to compile it was a mess.
I used the Debian source as a base (yes I use Debian btw) but the results were not good : the mascots are drawn on a white window and as I'm not enough qualified in C language to identify the problem I finally gave up.
I found the source elsewhere here https://github.com/tie/oneko and fortunately it cames with a functioning makefile, making the process very easy. And cherry on the cake : no damn white window on the piglet.

I even made a custom cursor that is supposed to be a cake in a plate yes I know it looks like a piece of turd xD but hey, it's a pig anyway, no ?
Replies: >>1639
Wow, your spriting might be better than mine.
>>1635
>>1637
I don't want to scare you but I recognized you on a non-anonymous space. Take care of yourself.
Replies: >>1640
>>1639
I'm sure I'll be fine :)
2024-08-13_inventory_qol.webm
[Hide] (218.3KB, 400x640, 00:25)
2024-08-13_decals.webm
[Hide] (663.4KB, 600x600, 00:16)
Wondering if I should post a demo in the demo day thread, I checked if everything's ok and noticed that my inventory doesn't work properly. I ended up just redoing the whole thing with all the QOL from my TODO list:
- You can no longer "pick up" an item, instead a ghost will remain where the item on your cursor is, and you can right click to cancel.
- Can't see it from the video but you can either click to grab an item, or drag-and-drop to move it quickly.
- You can move an item on top of a container to put it inside. Compatible containers will get a highlight.
- Hovering over an item will highlight all the cells under it, not just one.
- Items get "snapped" into the grid boundaries (easier to move large items).
The highlight no longer changes color though because the conditions are much more complicated and my previous "can_place_item_here" function is no longer viable. I'll fix that later.

Also implemented floor decals as shown here >>1624
I really need a better building UI. I have every individual thing on a different keyboard key because mouse interaction is hard coded for shooting a gun.
Replies: >>1655
ClipboardImage.png
[Hide] (4.1MB, 1902x932)
2024-08-19_11-44-42.webm
[Hide] (587KB, 860x354, 00:05)
fullanim.png
[Hide] (1.4MB, 2048x2048)
Everything is more or less working, except when it doesnt for no reason. 
        int _MiddleX,
        int _MiddleY,
        int _Width,
        int _Height,
        int _OffsetX,
        int _OffsetY,
        int _OriginOffsetX,
        int _OriginOffsetY,
That is too many fucking offsets, and scaling them up and down is fucking annoying.  So it looks "jacky" for some reason. And "separate parts" are half broken, which is worse than completely broken.  
Technically everything is generating automatically, but sometimes stuff just drops the texture for no reason.
Replies: >>1644
>>1643
Aren't there 2 extra values? What else do you need than size, position, and offset?
Replies: >>1645
>>1644
OffsetXY are practically the same as centerXY, and I dont really need them separately, yes.
ClipboardImage.png
[Hide] (4MB, 1902x932)
2024-08-21_14-49-04.webm
[Hide] (242.3KB, 914x396, 00:02)
ClipboardImage.png
[Hide] (599KB, 659x907)
ClipboardImage.png
[Hide] (402.5KB, 878x219)
It works, just like I wanted it too. The problem was with scaling, I can fix it in code, or I can just scale shit in gimp instead of doing it in my code, which is probably a good idea. It will leave a stupid error, but I dont really care at this point. Also shadows work as I wanted them to. 
tempanim.actions[0].aDirect[i].dFrames[tempanim.currentFrame].frame_order

Now I need to have an exporter for animations into data jsons, and generate proper part order as well, which should be relatively easy. But I would also need to separate a single spritesheet+texture into multiple data files (for example, arms from 1 texture, everything else from the other, or upper body from one direction, and legs from the other), which is quite annoying to do. 
I probably need to start with designing proper animation system, by designating rules for making them. 
Or instead I can just stop doing all of this, and start making the gameplay instead. I have animations for a character (walk, run, attack, get hit, idle), I have ground textures, I have trees. I have every placeholder I need.
Replies: >>1647
ClipboardImage.png
[Hide] (548.4KB, 894x255)
>>1646
With transparency. Overlapping parts are darker, but no one cares.
Chinese monke game became the most played game on Steam. You will translate your game for different languages, right?
Replies: >>1649
>>1648
I barely have english fonts support.
Replies: >>1651
>>1649
I'm planning to use GNU Unifont myself.
https://www.unifoundry.com/unifont/index.html
Seems like an easy drop-in solution for all languages that I don't have a better font for.
1661402989587538.jpg
[Hide] (567.8KB, 1920x1080)
I'm trying to write a server in C and it's like a grinder for learning how to manage data buffers. My end goal is to make a browser MMO, but I'll need a website to deliver the javascript and stuff anyway so I decided to try making a simple HTTP file server first. I kinda want to make some websites and imageboard too, so it would be nice to know how to make one that's super efficient.

Ideally I'd like the server to be able to handle 1 million simultaneous connections, but the server hardware requirements get complicated when you're talking about that much. So I'm making a list of idle sockets, and a separate list of I/O data buffers. Whenever a socket needs to send or receive data, it'll get one of those I/O buffers, but there's much less of them than there are sockets so only a fraction of the active sockets can send/receive data at the same time. That way the server can operate with much more reasonable RAM requirements.

For various reasons I figured that the best way to do a file server is to create a file cache. Files are loaded in 250kb chunks, anyone who's loading a file will increment a "demand" counter for the file and the chunk, that way anything with 0 demand can be discarded. Another purpose of the chunks is to allow an arbitrarily sized huge file to be uploaded easily without it clogging up the entire cache or using up all the RAM and blocking other sockets. There's also a least-recently-used linked list integrated into the chunks and files.

I haven't yet figured out how to handle POST messages, but I may do something similar. What if 1000 different people are trying to upload 100MB videos and their internet connections upload at 0.1kb/s?

This is complicated because I feel like I have to reinvent everything from scratch. Maybe I'm too hardcore about preparing for the worst cases, but I just don't know how servers typically work and what their limitations typically are. 99.9% of server related information on the internet is just retards installing PHP and MySQL and shit, it's impossible to find any kind of information about server memory management or something at that level.
Replies: >>1653 >>1654
874.webp
[Hide] (42KB, 600x400)
>>1652
>I'm trying to write a [web]server in C
Classic blunder. Much like getting involved in a land war in Asia.

If you're going to attempt this then why not use C++ instead. Things like managing data buffers are foolproof as long as you write in modern C++.

Regardless, it's big effort so steel yourself to some years of effort at it, I'd say (at least if you move at the 'typical' speed of a hobbyist dev). Good luck, Anon!
Replies: >>1655
chuckle.gif
[Hide] (463.3KB, 250x250)
>>1652
>I want to make a game
>lets start with "super efficient" webserver in C
> I'd like the server to be able to handle 1 million simultaneous connections
>What if 1000 different people are trying to upload 100MB videos
> I feel like I have to reinvent everything from scratch
>Maybe I'm too hardcore
>I just don't know how servers typically work
Replies: >>1655
>>1653
All the problems I have are with design, not with programming.

You need to pay monthly for a server. If for example I'm running a website and making 0 money from it, I don't want to pay a lot for it, as a result the server specs like RAM are going to be very limited and it probably uses a HDD instead of an SSD too. But the more limited the RAM is, the easier it is for some bad actor or even users with slow internet to just occupy all the available slots in the server and render it unusable. Did you know that when you go to a website, your browser will open multiple sockets to the server and load many files simultaneously, and then it leaves those socket connections open for a while? You don't even need to be downloading anything and you'll be occupying several of the available sockets from the server.

I'm thinking of having about 10k of those I/O objects, but that means that a bad actor only needs to open 10k sockets and start downloading files at 1 byte per second and he'll be able to completely prevent anyone else from using the website. How do servers typically deal with that? C++ isn't going to help me solve this.

There's a whole subject for handing a lot of sockets https://en.wikipedia.org/wiki/C10k_problem but the discussion mainly revolves around whether shitty OS socket APIs can handle it, it doesn't seem to go into memory management any deeper than the surface level. I know servers these days can handle 10s of millions of clients, but that's separated from server specs. If I rent a VPS with 2GB of RAM and 50GB hard drive, I have no clue whatsoever about how many clients I should expect it to be able to handle and in what way.

>>1654
I am >>1641 and that game is made with C without libraries (other than opening PNG/TTF) or graphics APIs, and I don't consider anything in it to have been particularly challenging to program. I'm not afraid of making things.
Replies: >>1657
And relatedly, if I want to make that browser MMO, what kind of server would I need to rent if I want it to handle 1k players? What about 10k?
ClipboardImage.png
[Hide] (170.3KB, 724x640)
>>1655
> I have no clue whatsoever
This is the main problem. You have no game, you have no players, probably not even a design document, and you try to measure up how it will hold up against a non-existant hacker.
Game doesnt exist, and you try to measure how much processing power it will take to run. It will take 0, because it doesnt exist and has 0 players. 

Enthusiasm and even stubbornness are a good thing, but you should be more realistic in your plans. Instead of starting a game by looking for a server to rent, which can hold 10k players, try by designing a game which will attract 10k players. Than you make a proof of concept demo, and measure how well it runs, and how much processing power it requires. And how long it will take you to make everything, since its unlikely you are an immortal.
Replies: >>1658
>>1657
>you should be more realistic in your plans
The way you become realistic is by understanding what you're working with, which is what I'm learning right now. I can't learn this without trying to do it and running into all the problems and questions first.

I also can't "measure how well it runs" because I don't have 100000 clones of myself to connect to the server from different computers simultaneously. The best I can do is try to theorycraft the requirements and limits in a hypothetical scenario. But I don't know what I should be expecting and whether a particular result is good or bad because I don't know how servers typically perform: I have no point of comparison.

The capabilities of your program can also be adjusted depending on hardware. If I make a game/website and it's userbase is low, I can just downgrade to a weaker server and make all my data buffers smaller. If it's super popular, I can do the inverse. There's no fixed requirements for a particular game or website, instead I need to understand hardware requirements relative to activity, or expected capabilities relative to hardware.

>non-existant hacker
Are you new to imageboards perhaps? Autists are constantly attacking them in various ways for various reasons. If someone wants to attack my server, I don't want it to just lock up immediately because I'm doing something totally wrong. You can't tell me to "be realistic in my plans" and then tell me to not care about attackers.
Replies: >>1659 >>1660
1721875425287634.jpg
[Hide] (161.8KB, 1000x1250)
>>1658
>I also can't "measure how well it runs" because I don't have 100000 clones of myself to connect to the server from different computers simultaneously
>>1658
>I also can't "measure how well it runs" because I don't have 100000 clones of myself to connect to the server from different computers simultaneously.
This is literally what virtual machines are for.
1724097513765479.jpg
[Hide] (98.8KB, 1024x990)
>encounter a crash
>I'm looking straight at it but it doesn't make any sense
>at least it's 100% reproducible
>put down some asserts to validate my assumptions
>crash no longer happens no matter what I do
>mfw
>in the middle of writing a response into a socket
>if web browser navigates somewhere else then the socket gives an error
>browser navigation gets blocked if you close the socket
I've reached a new height in useless search engine results when I try to figure out what the fuck I'm supposed to do here.

This reminds me of trying to get OpenGL to do something useful without having to do 80 backflips, so I just avoid it and do software rendering in order to enjoy programming. Maybe I can just forget about websites and browser MMOs and make a regular MMO instead so I can decide everything myself and don't have to deal with shitty browser technologies and shitty browser protocols. But the whole reason I wanted to make a browser MMO is because it would be so accessible that people might play it even if it's shit.
ClipboardImage.png
[Hide] (439.6KB, 625x347)
A story as old as time.
ClipboardImage.png
[Hide] (2.8MB, 1920x1040)
ClipboardImage.png
[Hide] (2.8MB, 1920x1040)
My retardation will kill me one day. 
>make sprites
>why cant they overlap properly?
>try random offsets
>turns out instead of rendering 1024*1024 images I used 1000*1000
>instead of 256*128 its 248*121 sprites
>I really should fix it
>instead of fixing it, I forget about it, and leave broken sprites around
I really should just switch to float coordinates, like everyone else for UV, to avoid this crap, and allow me easier scaling. But its still a problem for tile borders, and I dont see how I can solve it, other than using premade masks. But its whatever, who cares, at this point I am okay with visible seams. 

Still, it takes less time, since I can just edit txt files, and use console commands to process this crap.
ClipboardImage.png
[Hide] (3.1MB, 1920x1040)
Lazy way is the way. Stretched ground a little, by a pixel on each side. And "solid" walls are way easier to deal with (even if it just a few lines of code right now).
ClipboardImage.png
[Hide] (2.3MB, 1902x932)
ClipboardImage.png
[Hide] (2MB, 1920x1040)
A bit of a problem with flat ground and walls rendering , due to lights falling differently, and creating contrast, despite using same exact lights. But with lighting system, it should be fine, I think.
1a4dc5b4bc0863ad3dab470b6414da191062c27fa4c780c8a8a2f05155c07d75.webm
[Hide] (972.5KB, 1920x1080, 00:07)
>renamed a folder
>ok, but all these files are missing now
>renamed back
>cant rename because files are missing
>ok, maybe if I reload everything
>project cant be loaded because fuck you
>remade whole project
>doesnt compile anymore
A hour gone just like that. Stupid shit cant find filename.h in speficied folders, unless I did it myself, because reasons. 
On related not, when I renamed folder with .exe it worked, but weirdly. Instead of rendering entire map, it only rendered some tiles.
problem1.webm
[Hide] (62.5KB, 300x120, 00:03)
problem2.png
[Hide] (5.6KB, 268x308)
how1.png
[Hide] (45.8KB, 808x572)
how2.png
[Hide] (48.1KB, 924x659)
Every time I try to finish my OpenGL renderer I am reminded of why I didn't finish it any of the last times.

I want to render my UI into a separate texture, and then draw it on top of the game. This would allow me to scale the UI into any size without getting weird artifacts. The problem is that it's impossible to get semi-transparent pixels to work correctly when you're drawing on top of a transparent texture.

Problem 1 is that if you clear the background with transparent purple, and then draw 50% white on top, the resulting color will be 50% purple because of how GPU blending works. It doesn't matter what color you use because if you clear with black then white won't work, if you clear with white then black won't work. You can probably fix that by changing the blending function, but then you'll screw up your ability to draw that 50% white on top of other non-transparent pixels on the UI. Maybe there's a magic configuration that just works but I can't figure out what that would be. problem1.webm is a white rectangle with a fading opacity. I'm never using purple, it's getting it from the UI texture which is being cleared with RGBA[1,0,1,0] before every frame.

Problem 2 is that if you resize the UI texture in linear mode, the RGB values of the UI graphics will blend with the RGB values that are on empty pixels. So a white square will end up looking like a white square with a purple outline. You can kind-of fix that on an individual sprite by filling the empty pixels with the RGB values of adjacent pixels, but you can't do that on the UI because the pixels are drawn dynamically. Maybe you can first draw the UI texture onto a temporary texture with some kind of 3x3 blur and then zero out all the alpha values, but that seems weird. problem2.png shows the sprite with purple outline (the white gradient is purple because of problem 1).

I think Stardew Valley does exactly what I want to do, but I have no idea how they're accomplishing it. In these examples the game scaling is at 100% and UI at 95%. how2.png shouldn't be possible due to problem #2; either the gray pixels should fade into a darker edge when it gets more transparent, or the brown pixels should fade into a brighter edge, but both seem to fade out with the correct color. how1.png shouldn't be possible because of problem #1, they're somehow drawing a semi-transparent sprite that looks correct both on top and outside of the UI, the only way I can think of is that the cursor/item isn't part of the UI texture, and are drawn as a "third layer". However there's a lot of things that pop up on top of the UI including variably sized tooltips with text, and I doubt they pre-render every tooltip for every language.

I can kind-of fix problem #1 by never clearing the RGB colors of the UI texture (i.e. only clearing the alpha channel), it's hard to explain why but it causes the RGB values on the texture to be gradually dyed by semi-transparent pixels, and as a result the pixels that you draw blend with it's own color (instead of the purple that you originally cleared the texture with). It may not work well if the UI graphics move and change colors very rapidly though.
Replies: >>1682
blur.png
[Hide] (9KB, 400x208)
Not clearing the RGB values every frame makes problem 1 less bad, but it causes an effect like pic related. This white square is moving towards the right, and the right edge has a weird gradient because the UI texture's RGB values haven't been dyed white yet.
Replies: >>1681
purple.png
[Hide] (49.6KB, 760x584)
>>1680
Actually it's much easier to see if I clear the texture with purple at least once.
>>1679
I think the bigger problem is trying to make universal gui api, when you only need a few buttons. 
>Problem 1 is that if you clear the background with transparent purple
Why not with 0,0,0,0? And from what I read, you can just render things in reverse order, first non-transparent objects, than transparent, from the front to the back. Transparency is a pain in the ass, especially overlapping one, some engines just discard everything alpha<1 behind the first. 
>cursor 
Easy to set up with sdl. If print screen doesnt capture cursor, its probably using it, and its not part of opengl scene at all. Personally I would use sdl for all interface gui needs, it has a tool for text rendering as well. And I would not use bare opengl at all, you will reinvent too many things. There might be a specifically designed functions to render the UI. 
>scaling
There are no good scaling options for low res/pixelated textures to make them look good. The only option is to use the ones which look good enough, when scaled. if how1 how2.png are indication, it looks like they stretching instead of scaling down. 
>problem 2
I think there was an option to enforce strict alpha mask scaling, to avoid semi transparent pixels (or everyone has to write their own).
Replies: >>1683
clear_with_0,0,0,0,_draw_white_square.webm
[Hide] (61.6KB, 300x120, 00:03)
clear_with_1,1,1,0,_draw_black_square.webm
[Hide] (63.4KB, 300x120, 00:03)
what.png
[Hide] (56KB, 808x572)
scaling.png
[Hide] (39KB, 825x474)
>>1682
>universal gui api
I'm not even trying to make a GUI yet, I'm just trying to get graphics to render correctly.

>Why not with 0,0,0,0?
Like I said the color doesn't matter, see attached videos. The problem is how the colors are blended by the GPU, I could solve it trivially if I could do the blending myself but GPUs don't give you access to that part of rendering. I can change the blending equation into one that doesn't cause this, but there's no configuration I can see that both solves this and doesn't cause some weird ghost-like additive blending effect when drawing 2 sprites on top of each other. Stardew does it somehow but I don't know how, see what.png

>if how1 how2.png are indication, it looks like they stretching instead of scaling down.
I'm 99% sure that Stardew draws sprites at ~3x size with nearest-neighbor interpolation, and then resizes the final screen with linear interpolation. Pic related, when the zoom is at 100%, there isn't any blurriness but some pixels become uneven due to nearest-neighbor style resizing. The 95% version looks like the exact same result except downscaled with linear interpolation afterwards. I've also seen someone look at the rendering process and the UI was drawn separately.

I'm doing the same thing, except my pixels are getting mixed with the color that was inserted into transparent pixels during glClear(), and thus getting a colored outline (which would just change from purple into black/white if I changed the clear color). I don't know how Stardew resizes the UI texture without this happening.
Replies: >>1685
gradients.png
[Hide] (19.7KB, 474x185)
Here's another example: texture with 2 gradients drawn normally. There's no background color that will make this look correct.
Replies: >>1687
>>1683
Isnt glClear() a flush function which deletes all data from the buffer? What do you mean by "clear with white/black"? 
https://registry.khronos.org/OpenGL-Refpages/gl4/html/glClear.xhtml
Replies: >>1686
>>1685
It doesn't "clear data", it writes the given values (which you define with glClearColor()) to all pixels. https://registry.khronos.org/OpenGL-Refpages/gl4/html/glClearColor.xhtm

The problem is that even if you clear with a transparent color, the red green and blue channels are still there, and the GPU blends your colors with them.
Replies: >>1687
ClipboardImage.png
[Hide] (96.7KB, 486x260)
>>1686
Well, it sucks, and I can see the difference >>1684 here, but at the same time, its not really a big difference, and you probably will find a solution for it, so good luck.
How do you ever manage to find time to work on a project with a full-time job?
Replies: >>1690 >>1691
>>1689
8 hours work, 2 hours transit + bath, 2 hours food, 8 hours sleep = 20 hours.
You still have 4 hours left to work on your stuff, it is hard to adjust the times and mood for you to work again but it can be done.
Replies: >>1692
>>1689
I don't live in USA so I don't need to spend 6 hours per day on traffic.
>>1690
Anon you can't do something all the time when awake.
Replies: >>1693
>>1692
Why not?
Replies: >>1696
1256246123367.png
[Hide] (10.5KB, 429x410)
>>1693
Because I am now an old man.
Replies: >>1699 >>1700
>>1696
NTA.
>Because I am now an old man.
Lol, pls. Just crack the whip on yourself, Anon. Lots of great works have been accomplished by older men. In many ways, you have much more life-experience than young snot-nosed Anons.
>tl;dr
Get.Busy.  :^)
>>1696
So? If you have 2-4 hours of free time, what do you even do with it? Stare at a wall? Just work on your game instead.
ClipboardImage.png
[Hide] (218.4KB, 1902x932)
ClipboardImage.png
[Hide] (3.3MB, 1902x932)
>run exe
>works just fine
>run again
>barely anything is rendered
>run again
>works just fine
Dont you love when this shit happens for seemingly no reason? I assume its either some random io delay causing this or my hdd is dying. But textures are loading just fine, so who the fuck knows what is going on.
Replies: >>1702
6e0023572ff5ae633879ff5025a98b7f4c75f5a5b9859e6b0df54591d5c0a06b.png
[Hide] (125.3KB, 360x360)
>>1701
Fixed it. Also, now I can resize window, while keeping all the textures in gpu, despite the fact that it should drop them, due to directX bullshit. So it breaks for no reason, and it fixes other stuff for no reason, simply wonderful.
>1702
Programmers will argue about anything but they can all unite in hating graphics/rendering apis.
>get 999999999 error messages
>there's so many that my console can't display them all
>spend an hour trying to figure out what's causing it and looking for a way to see the whole error list
>add a struct typedef that I forgot
>compiled without errors
>the struct in question is only used in like 5 places
The magical world of forward declaration.
Replies: >>1705 >>1706
>>1704
>tired as fuck
>make a minor change
>999 errors start appearing everywhere, including standard libs
: instead of ;
>>1704
make 2>&1 | head -n 100
(or replace make with whatever snowflake build system you use)
Also consider using -j1 or similar to force using a single job, instead of throwing compile errors from zillions of parallel processes simultaneously.
If you compile with clang, you have -ferror-limit, consider decreasing that (I usually compile my code with -ferror-limit=5, if you have more errors they're generally the consequences of previous errors anyway)
Replies: >>1707
>>1706
It never occurred to me to check if there's a compiler option to limit errors, somehow I just assumed there isn't one.
VID_20240924_073805_204.mp4
[Hide] (1.3MB, 464x272, 00:11)
I am working on a gambling rpg inspired by Kaiji and my time trading gambling with crypto. It's 2D and transitions to 3D for the gambles, of which I've built out pachinko and plinko as of now. Done a bunch of work to make it so players can't abuse the gambles with saves/etc
Replies: >>1720
>>1713
Interesting mix, anon.
Replies: >>1722
image.gif
[Hide] (21.6KB, 220x123)
>>1720
Yeah I think people will like it. I'm just starting small for now, but I hope to eventually have pokemon but with gambling. AI has been very helpful with making my ideas possible where I was otherwise too dumb to figure some things out on my own.
I'm working on a simple Anki app that is fully cross-platform, but man, the deck format is insane.
I'm trying to decompress the .apkg file, but I'm encountering raw ZSTD streams (no headers or anything) inside the main ZIP package, and it seems it's impossible to uncompress this in Godot. I even tried some TINF GDScript implementation I found looking around and no dice. I'm about to give up.
I could just extract the decks I want to use, and use my own simplified deck format, but then the app would be worthless for anyone but myself.
Replies: >>1745
>>1744
Sounds like a challenge anon, I'm not up to snuff to help out, but have you tried using AI to help you with it? It might be able to help you with a workaround
One of the devs I follow mentioned this game jam which is taking place from Oct 21st to March 1st.
https://itch.io/jam/lsdjam-2024

Anyone planning to participate? The long deadline and open-ended theme seems like it could let you take an existing project and work towards something solid.
1724525716261188.png
[Hide] (206.5KB, 582x476)
I designed the ultimate moddable settings system. Mods can add new settings into the settings menu, and the user can configure them either globally or per-savegame. Any code that queries a setting value will get the savegame setting if it's set, global setting if it isn't, and the default value if neither is set. When you go to the settings menu you'll be able to see lights next to settings that have been modified both globally and in the savegame.

A moddable videogame where I could use this system? I don't have one.
Replies: >>1748
>>1747
Retrofit it into other moddable games.
Replies: >>1749
>>1748
It would take me longer to figure out how to do that than make my own game from scratch.
Replies: >>1751
Gamer_Misaka.webm
[Hide] (5MB, 854x480, 01:16)
>>1749
Sounds like you are going to be making your own game from scratch.
Not posted in ages, but it's been a busy month or so.
>Took part in LD56, wasn't great end result but had fun doing sprites and messing with boids
>Have working web builds now using Emscripten and WASM, after a bunch of suffering and needing to pull apart main loop to work in a non-blocking way
>Juice/damping lib for engine that acts on a pointer for a Vector2 along with a recipe for how the damping acts, so it's very easy to insert with minimal fuss and then just modify the target value as need be
>New iterators for object pools, so now they'll only yield objects marked alive and early exit
>Simple console benchmark lib where you can start/end different timers and get a consolidated list each second with averages and outliers
>Helpful little shorthand rand procs, so can do things like "if %50: ..." and "if %game.player.crit_chance: ..."
>Pathfinding lib with A*
>Color tags in dialog system so you can do "hello [red]world" to highlight 'world'
>Support for optionally inserting into multiple cells, based on size, in spatial grid lib
>Started on a settings lib that will handle constructing settings UI, inputs, saving, resetting, etc - instead of me having to hard code it all each project
Replies: >>1766
>set up a bunch of rendering stuff
>black screen
>can't find anything wrong
Everyone's favorite.
Replies: >>1762
>>1761
Open GL?
Replies: >>1763
>>1762
Yes. I figured it out though, I screwed up some buffer sizes.
hmm_yes.webm
[Hide] (2MB, 1910x1190, 00:22)
Somehow, I suspect that this is not correct.
Replies: >>1765
monke.png
[Hide] (302.8KB, 1920x1200)
I thought loading 3D models would be complicated, but .obj file is pretty much literally just a list of vertex positions/normals/uvs. Maybe it becomes more complicated if you want animations.

I'm really struggling to understand how perspective projection works. I assumed that the idea is to first do all other transformations, and then shrink the x/y positions more the further the vertex's z position is. Basically something like vert.xy *= 1-vert.z; However, although it seems to create weird pseudo-perspective as seen in >>1764 it just doesn't seem to do the right thing no matter how I slice it. Straight lines become curved, and objects appear to accelerate the further they get. I tried to multiply the vertex with a perspective projection matrix, but it doesn't seem to have any effect.

I could just copy paste all the transformation matrices from a tutorial and multiply them together and call it a day, but I want to calculate everything myself because it helps me understand how it works. I understand all other transformations except perspective projection, there's an article about it but my brain shuts off when I see my screen completely full of math equations: http://www.songho.ca/opengl/gl_projectionmatrix.html
I can't stop myself from thinking that this is way too complicated waste of time of an explanation and there's a much simpler way to understand it.
Replies: >>1767
>>1760
>>Helpful little shorthand rand procs, so can do things like "if %50: ..." and "if %game.player.crit_chance: ..."
How does that work? Are you using some weird scripting language?
Replies: >>1768
perspective.webm
[Hide] (3.7MB, 1910x1190, 00:17)
>>1765
>vec.w = vec.z
>it just works
So I was actually on the right track, I just had to divide instead of multiply. Apparently the 4th component of the vector will cause glsl to divide the other 3 components after the vertex shader, so if I do vec.w = 4.0, it's similar to vec.xyz /= 4.0. As far as I understand, the GPU does some special triangle clipping somewhere in-between, so if you do the division yourself, things behind you will be mirrored in front of you, which may be why I didn't find this solution before. There's an explanation here, it's a little confusing but I think I get it: https://stackoverflow.com/questions/41085117/why-does-gl-divide-gl-position-by-w-for-you-rather-than-letting-you-do-it-your

I also have to divide the z in a way that I don't fully understand. Here's how perspective works with the 4th component:
gl_Position = vec4(v.x, v.y, -1/v.z, v.z);

And here's how you can do the same manually (will cause the mirroring problem):
v.x = v.x / v.z;
v.y = v.y / v.z;
v.z = -1 / v.z / v.z;
gl_Position = vec4(v, 1.0);

I also have no idea what the FOV currently is, it's just a division and it happens to look about right, and I'm not controlling the near/far "clipping planes" either. I kinda stopped caring about understanding this since I can't do the division myself though, maybe I'll just switch to copypasting matrices.

Here's the full context in case anyone is curious:
#version 330

layout (location=0) in vec3 vertex_pos;

layout (location=3) in vec3 instance_translate;
layout (location=4) in vec3 instance_scale;
layout (location=5) in vec3 instance_center;
layout (location=6) in vec3 instance_rotate;

layout (std140) uniform global_info_block {
	vec2 window_size;
	vec3 camera_pos;
	vec3 camera_rotate;
};

vec3 rotate (vec3 v, vec3 rotation) {
	vec3 rotatesin = sin(rotation);
	vec3 rotatecos = cos(rotation);
	vec3 rz = v;
	v.x =  rz.x * rotatecos.z  + -rz.y * rotatesin.z;
	v.y =  rz.x * rotatesin.z  +  rz.y * rotatecos.z;
	vec3 ry = v;
	v.x =  ry.x * rotatecos.y  +  ry.z * rotatesin.y;
	v.z = -ry.x * rotatesin.y  +  ry.z * rotatecos.y;
	vec3 rx = v;
	v.y =  rx.y * rotatecos.x  + -rx.z * rotatesin.x;
	v.z =  rx.y * rotatesin.x  +  rx.z * rotatecos.x;
	return v;
}

void main () {
	vec3 v = vertex_pos;
	
	v += instance_center;
	v *= instance_scale;
	v = rotate(v, instance_rotate);
	v += instance_translate;
	
	v -= camera_pos;
	v = rotate(v, camera_rotate);
	v.xy /= window_size/window_size.y; // Aspect ratio.
	
	gl_Position = vec4(v.x, v.y, -1/v.z, v.z);
}
Replies: >>1769
>>1766
Nim lets you call functions in different syntaxes and parentheses can be left out in unambiguous cases. So foo x, foo(x) and x.foo() are all the same. % is just a proc that pops from RNG and compares the value to return a bool.
>>1767
Watching this is very disorienting.
distorted_zoom.webm
[Hide] (3MB, 1910x1190, 00:15)
I wonder if this would still work in a real environment. It might fuck up vertex normals, or cause weird triangle inconsistencies because this is a vertex shader.

In real life you can focus on a particular spot and squint or whatever to try to see more clearly, I've always hated how in 3D games you can't do the same and you're hugely limited by the pixel density of your monitor, you have the least detail at the center even though you'd want the most precision there, meanwhile everything at the sides of the screen are large and elongated and just waste all that detail. You can't squint to try and see what that small object in the distance is.

Games like DayZ allow you to "zoom in" to look further, usually by aiming a weapon, but I don't like how it just zooms in your entire vision, that kind of effect always feels too powerful to me, especially when it's a weapon scope with noticeable magnification that just causes your camera to fly forward into the distance. What I'd really want is the ability to focus in on the center of your vision and get more detail only there, and sacrifice detail/precision at the edges of the screen
noise.png
[Hide] (1.6MB, 1920x1200)
dithered.png
[Hide] (527.6KB, 1236x1236)
no_dithering.png
[Hide] (16.3KB, 1160x1272)
I've seen a lot of games where the sky has ugly color banding and shit, especially at night, but I just realized that it's very easy to do random numbers in the fragment shader. Pic 1 has all pixels replaced with random noise, all you have to do is divide this by about 100-200 and add it to the output color, and color banding will almost completely disappear.

It works because RGB values on the GPU are floats so shadows and gradients technically have super high precision, the banding only appears because that precision is rounded down when the pixels are put onto the screen. But if you randomize the brightness of each pixel by 0.0-1.0 or so, the high precision gradients start to create a dithered gradient when they get rounded. Pic 2 is a gray object, I increased the contrast in an image editor so you can see the "dithering". You could do monochrome dithering too but I assume multicolored would be smoother. Pic 3 is what it looks like without dithering, I could see the color banding before I even increased contrast.
shadedmonkes.png
[Hide] (1.7MB, 1914x1184)
I've been wondering why my lights aren't working properly, turns out I never called glEnableVertexAttribArray for vertex normals. Also the normals were exported with flat shading mode so it wouldn't have looked right anyway.
a0b45ee1f8c7853ecf82594f56da722084b47857b831ab47cc0a481d7da91720.jpg
[Hide] (134KB, 1280x720)
Why is art so complicated. I want to make a Rune Factory clone, but there doesn't seem to be a good way to do the art.

I want characters to be able to wear many clothing items (changes with season and location and maybe you can gift them some), but I think it would be stupid if the portrait doesn't show them. I also want half-body portraits because of reasons, Stardew Valley style head-in-a-box isn't enough. Problem is that if I want both of those things, it would be extremely laborous to edit all the character portraits for all poses of all characters for all clothes.

Option 1: All characters have the same poses like pic related, so you can draw clothing once and dynamically paste it on top of the character sprites. This is interesting because it allows you to add new characters without much cost since you don't need to adjust the clothing. It seems very boring though, and you'd have to make exceptions anyway for different body types (you can't put the same t-shirt sprite on a guy and a big boob lady).

Option 2: Each character has their own unique pose, and any piece of clothing has a separate sprite per character. This allows maximum compatibility with different body types and allows characters to be a bit more expressive. If I keep the amount of clothing small and only key characters can swap clothing, then it maybe wouldn't be too bad.

Option 3: Each character has completely unique sprites. This would make a much much better game than the other two, but the amount of characters and the amount of swappable clothing would have to be very restricted since adding new things to the game basically has an exponential art cost.

Option 4: Use 3D. The biggest problem is that I don't enjoy doing 3D art.

I want the game to have a big focus on NPCs, so I kind of want to try #3 even though it seems like a ridiculous amount of work. Maybe it's not that bad if you start out with a few things and slowly over time add one new thing at a time. You can probably also do some tricks, for example draw a hoody except the hood, strings, zipper, and front decoration are separate, and then use a shader to change the colors. That would allow you to have multiple shirts with the cost of 1.
Replies: >>1775
1668279773470546.png
[Hide] (3.8MB, 4800x2715)
>>1774
It gets even worse. One of the most disappointing parts of these games is the children, but I want that to be the most fun part of the game.

- I want children to look similar to the wife (maybe the eye/hair colors can change based on player character).
- Limiting your children to 2 (boy and girl) would be pretty lame, if you really like your wife then it feels like not enough.
- It would be strange if all of your children looked like clones of each other, so they should be at least slightly different.

So basically, on top of unique sprites for each NPC, you would also need unique sprites for 4 children for each wife. Maybe you could skirt around the issue by having twins, then it's fine if they kinda look like clones. If the game only had 1 marriageable girl, this still seems doable, but the game really should have at least 3 options to choose from. In any case, NPCs definitely cannot have swappable clothing because it just requires too much art, should be fine to have a couple variations like seasonal or work/casual clothes though.

BUT, that's assuming 4 children is enough in the first place. I can imagine wanting a really big family, but at some point it just becomes completely infeasible to have none of the children look like clones of each other. Maybe you could do it with 3D somehow by slightly altering the face/body proportions, and it would be easier to make universal poses and hair styles (that can be used by all characters) not to mention swappable clothes. So maybe this whole idea just doesn't work without 3D.
PIP_scope_wip.webm
[Hide] (2.9MB, 1310x780, 00:11)
It's been like 3 weeks since I messed around with this, but JUST realized that the same general idea could potentially be used to implement regular PIP scopes for weapons with almost 0 performance cost.

A lot of games just zoom in the whole camera when you aim through a scope, but if you want only the weapon scope to zoom (PIP aka "picture in picture" scopes, Escape From Tarkov has them for example), you'll have to render the game twice which obviously has a huge performance cost. This on the other hand can be implemented with just a tiny bit of vertex shader code.

Video related. I'm too dumb to do the math correctly so I can't get the edges to scale correctly (pic related has arbitrary hard coded calculations for the edge area), although it kinda looks like a glass distortion so maybe it's even desirable, and the edge of the scope would hide it anyway.

There's a couple potential problems:
- This may screw up certain calculations since it fakes the position of the vertices (for example maybe lights/shadows will appear in incorrect positions), but maybe you could fix that if you knew shaders well enough.
- There's slight artifacts/distortions at the edge even if you do the edge math correctly, smaller triangles will make it less visible and the physical weapon scope probably hide them anyway.
- Large triangles have more problems, for example a flat wall or a skybox or mist particles may be distorted strangely. Imagine a huge rectangle with 4 vertices, if one of the corners goes in and out of the scope, the whole rectangle will jump back and forth from a distorted and undistorted state.
- I don't know how hard it would be to mask out a part of this or move it. For example it may distort the scope of your gun too unless the gun is rendered with a different vertex shader. And when you're equipping/unequipping a weapon, how would you hide a portion of this circle as the scope comes into view?

I know Stalker modders for example have struggled with implementing PIP scopes, I wonder how hard it would be to do it with this trick.
zoom.png
[Hide] (11.4KB, 536x525)
Here's a rough explanation of what it does.
PIP_variable.webm
[Hide] (3.4MB, 1300x800, 00:16)
Also here's variable zoom level. The size of the edge "bulging" changes with zoom because my math is shit. You need to use some kind of curve/circular/exponential function to change how the edge area scales, it creates a weird spherical effect if you transition linearly from maximum to minimum zoom.
[New Reply]
98 replies | 69 files
Connecting...
Show Post Actions

Actions:

Captcha:

- news - rules - faq -
jschan 1.6.2