Showing posts with label Random-Idea. Show all posts
Showing posts with label Random-Idea. Show all posts

Wednesday, September 3, 2014

git merge drivers + multiple platforms / IDE's

One problem with working on multiple platforms is that each platform usually has it's own preferred IDE & it's own project file formats. A solution I often see in open source software is to use makefiles and generate the project files for different platforms. That works, but it's not very convenient that you have to manually add files to a makefile.

So I was wondering, what if each platform had it's own GIT merge driver that parses the project file format for the preferred IDE/text editor on that platform and then patches the project files for the other platforms?

You'd still need some way to make sure that other platforms don't end up compiling files platform specific files for another platform heh. In theory it could mean that you could just use any IDE you'd want on any platform and it would 'just work'..

Just a crazy random thought.

Monday, February 24, 2014

Voxelization meshes

Just a random thought;
If the future is going to be using voxelization to perform real time indirect lighting / glossy reflections etc. (using techniques such as voxel cone tracing). And for a moment ignoring that this might not be ready for prime time just yet. Wouldn't it then make sense to have lower resolution 'voxelization meshes', just like we have different meshes for collision detection? Since the voxelized world representation is an approximation anyway? It might save a lot of cycles (at the cost of memory) ..

On the other hand, the static meshes could probably be pre-voxelized, and the most dynamic meshes would be skinned meshes .. which would require you to skin the same character twice with two different meshes? Might still be worth it if the voxelization representation is simple enough ..

Friday, December 13, 2013

Screen orientated basis vectors

Just a random idea; what if light is cached in texture space using screen orientated vectors.
Basically just like the half life 2 "Basis for Radiosity Normal Mapping" vectors, only all vectors are orientated towards the screen to have more accuracy there.

The texture space cache would have to be updated eventually when the camera moves too much relative to the cached pixels, but since we're not storing a single direction we can interpolate (and slightly extrapolate) between the vectors to increase the time the specular reflections remain valid between motions. The further away pixels are, the longer they can remain cached. For 3D rendering both cameras can use the same data.

Tuesday, September 3, 2013

Variable eroded navigation meshes

Another random idea; what if navigation meshes where combined with distance fields to make them work well with entities of all kinds of varying sizes?
Instead of having an eroded navigation mesh that only works for one size entity, and presumably needing several copies for different sizes .. (unless there are some other tricks I don't know about)

Wednesday, August 28, 2013

Material masking in G-buffer?

Welp, went on a long vacation to California & Nevada with my family and when I came back a shitload of interesting papers where released at Siggraph 2013, Carmack has left iD (sort of) to start to work at Oculus, Balmer is going to leave Microsoft (to the relief of .. everyone), NiN is back (YES!) and .. Ben Affleck is the next Batman.

What??

I'm pretty sure I accidentally stepped through a wormhole there.
I can't leave you guys alone for a second, can I?

Bonus points for those who can tell me who's company's logo was based on this mountain:



Anyway, some random thoughts:

This paper had an interesting idea that was new to me .. take pre-defined materials (such as iron, aluminum, dust) and combine them together with masks. This works really well with physically based shading where your materials might very well be measured real world materials (or at least based on them).

So I couldn't help but wonder .. if materials are build up like this .. why not just store the masks together with a material id per mask. The masks are much easier to compress (especially if they don't need to be very precise and can be low resolution) and the final textures could be generated at run-time .. maybe even in the pixel shader if the base materials are not texture based (but quality might suffer too much)
Obviously this will only work if the number of material layers are within reason.

The base materials could have pre-generated mipmaps, avoiding the issue of needing to generate mipmaps for your final texture after combining the masks. Which is nice since you don't want to do the whole "turn normals into variance into roughness for a lower res mip" and "fixing up your transparency by estimating if your texture is still roughly as transparent as your higher res mip" for your mipmap chain at loading time.

So what if you could store the masks in your G-buffer instead of low quality specular / diffuse / normal / roughness? Still would make it hard to add fine details to your materials though, especially in the normal map. The surface normal would still need to be stored in the G-buffer, so perhaps normals could be stored directly and all other material properties would be done through masks? Roughness could probably still be stored per material .. Material id's would still need to be stored as well (one for each mask), so it might end up not being a win storage space wise.

Of course, if all the lighting would be rendered in (virtual) texture space then you wouldn't need a G-buffer and you could just combine your masks into a (virtual) texture cache when you need it.



Wednesday, September 12, 2012

Programming languages

Yesterday night, trying to sleep, I was thinking about next generation programming languages and how it would be nice to have a language that combined all kinds of features from C#, D, Intel Cilk, C++, support for both composition and inheritance architectures etc. etc.

Of course this magical new language would solve every single problem and bring about world peace. It wouldn't have garbage collection, but would require the user to manage memory manually like in C++, and wouldn't be managed to be able to get every bit of performance out of your computer. 

So this made me wonder, suppose you'd have this language and you'd have this standard library included with it like .Net does (but maybe a little more sparse) how would you handle situations like SomeContainer.ToArray()?

If you don't have garbage collection, and you allocate memory in this 'ToArray' method then the user would be responsible for freeing it later on. So this made me think is there a clever way to communicate this to the programmer beyond mere documentation?
This is what I came up with (syntax is just an example):
class SomeClass
{
  public allocator SomeOtherClass* MyMethod() 
    { return new SomeOtherClass(); }
}

void SomeOtherMethod()
{
  SomeOtherClass* myInstance = new SomeClassInstance.MyMethod();
  // ..
  delete myInstance;
}

The idea is that every method that returns allocated memory (which hasn't been stored somewhere else) MUST flag that method as an allocator. Then when an allocator method is used you MUST use the new keyword in front of it.

The advantage is that in the scope of 'SomeOtherMethod' you can clearly see that SomeClassInstance.MyMethod allocates memory and that the programmer is responsible to free this memory eventually. 

When a method isn't an allocator but still returns a pointer then the programmer can assume that this pointer doesn't need to be deleted and will be managed by some other piece of code somewhere else.

An additional advantage to this is that it should make it easier for the compiler to automatically detect certain types of memory leaks. The beauty about this is that it works hierarchically .. if a function calls an allocator and returns it's pointer it will need to be marked as an allocator as well (unless it stores the pointer somewhere).

Sunday, January 29, 2012

Physical Based Rendering

Lately I've been playing around with Physical Based Rendering (yes, I'm late to the party). It took me a while to get it working because I kept getting weird results that looked more like caustics than surface roughness. I checked the math again and again, looked up as many source materials I could find to compare them to my implementation (just in case there where some errors in some articles), but couldn't see what could cause these weird artifacts. The thing is, when I rendered the light on a sphere it looked perfect, but when I rendered it from the inside of a box it looked completely wrong! So I started to check all my inputs and they all seemed fine ... until I discovered that my lighting position was inverted. Wut? How the hell? It turned out that the wrong light position caused my half way vector to be, well, something else entitely. And that combination made it all look plausible most of the time and completely threw me off course.

I'm currently using the GGX microfacet distribution, from the Microfacet Models for Refraction through Rough Surfaces paper. Here's what it looks like with some random textures and lightwave models borrowed from Doom 3 (don't sue me!) for testing purposes.



Some random thoughts about gloss / roughness maps & normal maps

While I was working on all this I realized that while roughness maps describe surface detail at the micro level, normal maps describe surface detail at the macro level. This made me think that, when generating normal map mip-maps, that lost normal details at lower resolution could be put in the gloss map instead. Of course this probably would work better with an anisotropic BRDF (directional-roughness) compared to an isotropic BRDF (uniform-roughness). Since both of them seem to be connected, it may imply that there might be a way to combine the two in a single thing. ("anisotropic normal maps"? lol)

This would probably work a lot better (especially with isotropic BRDF's) if you generate normal your maps from heightmaps, and create the gloss and normal maps mip maps from the mip-maps of the heightfield. The roughness would be calculated from all the height variation within a lower resolution mip pixel (compared to the highest resolution mip), while the normal would simply be calculated from the lower resolution mip directly. Maybe some sort of min-max mipmap approach could be used for the roughness. Of course you'd still have to take into account that the further away you are from a gloss map, the smoother it'll look. (disclaimer; I haven't actually tried any of this)

Tuesday, August 16, 2011

Deferred rendering with virtual texturing

Just a random thought.

I had thought about a deferred rendering / virtual texturing approach before where instead of storing the normal, albedo etc. in a g-buffer you'd only store the texture coordinate + texture derivatives (+ z position & surface normal, unless you're storing normals in worldspace which is possible for static environments with virtual texturing). But I quickly dropped that idea back then because you'd store roughly the same amount of data so it wouldn't gain you much. But this morning I was thinking... If you have a lot of overdraw and/or if you render lots of small triangles (especially if a lot of them are smaller than 2x2 pixels) it might pay to have a really simple shader at the g-buffer phase, and then do the actual texture lookups later on, when you're just rendering a single full-screen triangle. It might work, it might make no difference, it might be worse. I should definitely try it some day.

Tuesday, May 24, 2011

Random thought

This morning I suddenly was thinking, would it be possible to have some sort of hive mind server-client architecture working on top of a peer to peer network?
Meaning that the hive-mind (all or clumps of clients) would act as a sort of referee when it comes to gameplay. I can imagine that it would be pretty complicated, but it would remove the need for dedicated servers and possibly help avoid cheating ...

Just another one of my random thoughts ...

Thursday, July 8, 2010

3rd person story telling

Just had an interesting thought about game storytelling ...

First person story telling never seems to work very well, this is because you are in control and you can't be directed to play your part in someone else's story.
The more control someone tries to assert over you, the less freedom you have.

When you watch a movie, you sympathize with the characters you're seeing on the screen.
When you play a traditional first person game, you don't sympathize with yourself in the same way, because even though you control your character, you are never truly him or her.
You don't share that made up history with the character, you are just you put in the shoes of someone else and everybody pretending that you are that other person.

The first person games that have the best stories always have their stories revolve *around* the player, always trying to put the player into the center of the story in a somewhat fake way.
Half life does this the best because it lets most of it's story be told by other characters, and acted out by other characters.

So I was thinking, perhaps the story shouldn't centered around the player, but around other characters, and the player is simply there to, sort of, witness it.
Certainly the player would participate in the puzzles and obstacles, but when it comes to the story, the player wouldn't actually be the focal point.
The player wouldn't be the main character.

This would allow much more interesting characters in the story, or maybe even switching between multiple characters, like they do in series.
You would simply be the faceless guy/girl who goes along for the ride, so to speak.

Which explains why freeman never speaking in half life works so well.

Monday, February 1, 2010

Random thought

Just had a random thought concerning game component object systems.

If the system is optimized to quickly add and remove components, then an event system could be realized by adding and removing components.
So instead of having a complex event system to send events between components, you would add a specialized component that performs or represents the event.
The component would then be removed when the event is processed.
Not entirely sure how flexible it would be, but it would sure be easier to optimize for cache and multiple threads.

Yes, this blog has been neglected lately, I'm going to give it some attention again soon (I hope).
Real life has simply thrown several projects my way which is taking all my time at the moment.