MagicaVoxel

Started by
34 comments, last by Geri 1 year, 6 months ago

Not sure if I want to mix shadows and something like SSAO. I have code working for both, but I don’t remember if I’ve combined them successfully.

I have another question. Right now I’m using a directional light and shadow mapping. Should I switch to using point lights? I notice that there are max 32 texture units on my nvidia GPU. So I can basically do up to 32 lights. Or, is there a way around this limitation?

Advertisement

taby said:
I notice that there are max 32 texture units on my nvidia GPU. So I can basically do up to 32 lights. Or, is there a way around this limitation?

Yes, e.g. you can use a shadow map atlas, so just one texture for all lights. There is a technique called ‘shadow map cache’, iirc. Which basically means to put nearby lights into such SM atlas. I think Doom 2016 used this.
But if you have many lights, the common way is to have most of them unshadowed.

The game Path of Exile is interesting, because it does not use shadow maps at all. All shadows are screen space shadows. For a top down game this can work.
(The dev is really exert with this stuff, see this realtime GI which is just screen space too.)

If you have complex scenes like interiors you may need some GI solution. Even 32 lights could not fake this.

But ideally you don't need any fancy realistic lighting at all, of course.

taby said:
Not sure if I want to mix shadows and something like SSAO. I have code working for both, but I don’t remember if I’ve combined them successfully.

That's a good example of what SSAO can do:

It can add depth to small scale details.
Character looks good. (They also do some other tricks like beveling edges, causing some nice highlights).
Such things are just eye candy, and do not really add depth to large scenes.

But for a top down game depth isn't that important, because it's basically 2D.
To keep it simple, you could use soft blob shadows per character. Good enough to ground them, and AO can refine and add some detail.
There might be no need for shadow maps at all. Hard shadows are often more distracting and ugly than helpful for such artsyle.

Do you know how I would go about implementing depth of field in OpenGL 4?

I don’t really need to know, because this renderer will be replaced by Godot 4, when it comes out.

taby said:
Do you know how I would go about implementing depth of field in OpenGL 4?

Well, the most recent thing i did with OGL was a mobile game using GLES 1.0, so i'm really not up to date.
I don't know about modern things like bindless or direct state access at all.

Tbh, i hate dealing with gfx APIs. Docs read like patents, you never know what you're missing, what's the best option, if your stuff works on any GPU, etc.
It's frustrating trial and error work with nothing to learn. So i can really understand people using engines.
What i don't like about engines is they are all in one packages, forcing you to adopt their ECS religion, their shitty physics simulations, their scripting languages, their editor, etc. Picking an engine is like voting for your dictator.

I wish there would be more open source libraries around that give you just a renderer, or just audio, just network, and whatever individual systems. So you can choose which things you want to adopt, and which you want to do yourself.
In the past there often was some disrespect against people gluing their custom engines together this way, by just combining various libraries. But why should a single person reinvent all wheels just to claim ‘i've done all by myself - now i'm over 60 and too old to make a serious game with it’?

I somehow feel that's the fate in front of me… ;D

taby said:
Do you know how I would go about implementing depth of field in OpenGL 4?

in opengl2 this is how you did it: convert the frame buffer to texture, convert the frame buffer z to a z texture image, bind them on two separate texturing pipelines and push them to your shader.

why are you using opengl 4? use the original opengl 1.x with extensions and then you can support a more wide variety of platforms, computers, video cards, making a more compatible solution.

taby said:
I don’t really need to know, because this renderer will be replaced by Godot 4, when it comes out.

stop using joke engines. you already know opengl.

Just saw a video of Minecraft Legends: (yes, i was bored)

So they use per object contours.
Looks pretty shitty to have detailed grass strands while heads are still just a box. But probably i just fail to understand how technical restrictions (or in this case, programmer art) become signature features.

@geri Funny enough, I finished a project using OpenGL 2 not long ago. I used shaders in conjunction with glBegin() / glEnd().

The problem that I have at this moment is that I do not know how to have the FBO render to a texture. I have a depth texture, but not a colour attachment texture. How would I render to texture?

I know how to blur the image and use the depth to apply depth of field. It's just OpenGL that stumps me.

Thanks for your advice.

@joej LOL – sorry, apparently I ripped them off. :P

P.s. Mac doesn't support OpenGL 4.3. No compute shaders. fuck em

taby said:
@geri Funny enough, I finished a project using OpenGL 2 not long ago. I used shaders in conjunction with glBegin() / glEnd(). The problem that I have at this moment is that I do not know how to have the FBO render to a texture. I have a depth texture, but not a colour attachment texture. How would I render to texture? I know how to blur the image and use the depth to apply depth of field. It's just OpenGL that stumps me.

I dont remember how to handle FBO-s, when i did, i did it only for depth buffer (because of shadow map). Maybe you have to render the scene twice, once with depth texture, and a new fbo to get the color.

BUT Alternatively, you dont need an FBO, you can just convert the frame buffer to texture without using FBOs at all... glCopyTexImage2D will copy your screen to a texture. Might will be slow with non power of two textures, if used on older video cards. Using gl_depth_component_32 you can copy the z buffer as well.

(I dont know if this function even exists in newer opengl contexts, so thats why i am suggesting not to waste your time on core profiles)

taby said:
P.s. Mac doesn't support OpenGL 4.3. No compute shaders. fuck em

What? I'm shocked.
Well, there is still a Vulkan→Metal emulation library i could use. But porting API calls to Metal shouldn't be that bad, and making a shader transpiler probably neither.

It looks short sighted and ignorant how Apple ignores cross platform APIs, but actually, the reality is the opposite of that impression:

Apple has highly efficient M1 CPU which competes PCs requiring 4 times more power. They already put the whole computer into a single chip, and realize consumers need no data center hardware.

Meanwhile in PC land: PC gamers buying new 1200W PSU and a larger case to overclock their 2000EUR RTX4090s so they can play ray traced Portal and Quake, plus 3 sponsored AAA games at psycho settings.
That's nonsense, but the sycophantic alliance made from enthusiast gamers, devs and tech journalists is unable to adapt to Moores Law being dead. They prefer to sink with their unaffordable power hungry titanic, over lowering their expectations on ever growing HW power. They have no interest in a low power PC gaming platform and rather commit suicide than imagining such future.

The old prejudges about Apple being expensive are no longer upright either. A Apple laptop does not really cost much more than a similar specced Windows device anymore.
Plus, Apples ecosystem has much more to offer. You can pay in the supermarket with your iPhone, have a Smart Home, managed your contacts across all devices, all easy to use with foolproof Apple one button software.
Once you're in, you won't leave the Apple ecosystem, because it just works.

If Apple decides to enter gaming seriously, they could easily wipe out the PC platform from consumer space within a decade, i'm sure. It feels just a matter of time until they decide to do this.

Now i don't like this. Windows sucks, but PC is still an open platform, and that's what i want.
So i hope things like Steam Deck and other APU gaming handhelds are successful enough to change the media landscape. People have to realize affordable low power HW is better for games than path tracing bullshit.
We need cheap APUs to replace dGPUs for mainstream gaming, otherwise the platform is outdated and subject to funeral within the next years.

This topic is closed to new replies.

Advertisement