Auto-Enhancing Textures

Talk among developers, and propose and discuss general development planning/tackling/etc... feature in this forum.
Post Reply
pifactorial
Bounty Hunter
Bounty Hunter
Posts: 170
Joined: Mon Feb 21, 2005 7:04 am
Location: Pomona College
Contact:

Auto-Enhancing Textures

Post by pifactorial »

I love Vegastrike. Nonetheless, one of the things that really annoys me is how planets' textures get all pixellated and ugly when you fly close to them. I decided to find a solution to this problem.
I have written a small proof-of-concept program called Plazoom which uses a plasma fractal algorithm (cf. plasma plugin in gimp) to enhance textures. Here's how to use it:
  • Send the original texture image data to the plazoom function, and the coords of box (x1,y1)-(x2,y2)
  • The function returns an image 4x as large, with the image data from (x1,y1)-(x2,y2) enhanced, and the rest of the image as black.
I intend for it to be implemented like this:
  • Vegastrike detects when a planet's texture is about to start pixellating
  • it passes the planet's texture, and coords of the currently visible area, to plazoom
  • plazoom writes the enhanced texture file to /tmp/texture.png
  • Vegastrike applies the new texture to the planet, and no quality is lost

It is also safe to re-apply plazoom any number of times. Obviously implementing this into Vegastrike will be more complicated than what I wrote above, because you also have to account for zooming out and panning.

Lastly, plazoom, as I mentioned, is only a POC. It currently is written to use the ppm image format instead of png, so it is very inefficient. Also, I wrote it in <24 hours so I sure the code could be vastly optimized. I'm mostly wondering if any of the devs like my idea, and would like to help me implement it into Vegastrike.

I will post code and example images soon.
hellcatv
Developer
Developer
Posts: 3980
Joined: Fri Jan 03, 2003 4:53 am
Location: Stanford, CA
Contact:

Post by hellcatv »

it's definitely a cool idea...could be applied to geometry too... to make terrain....
I've not got a clear idea about how to do it...but I'm sure something could be figured out in the longterm... :-)
Vega Strike Lead Developer
http://vegastrike.sourceforge.net/
pifactorial
Bounty Hunter
Bounty Hunter
Posts: 170
Joined: Mon Feb 21, 2005 7:04 am
Location: Pomona College
Contact:

Post by pifactorial »

Here's a demo. I know that the enhanced images are noisy (I personally prefer noisy to blurry). I'm sure we can tweak this to make everyone happy.

NOTE: The images may be scaled down, therefore ugly. Click on them to view at full size.
You do not have the required permissions to view the files attached to this post.
pifactorial
Bounty Hunter
Bounty Hunter
Posts: 170
Joined: Mon Feb 21, 2005 7:04 am
Location: Pomona College
Contact:

Post by pifactorial »

Plus some code! Please don't criticize me for sloppiness or poor optimization, as I'm very new to C++ under linux (I'm a web developer). To try it out, just extract and run install.sh (as root)

Also, I'd like to stress that this has not yet been optimized for png (as you can see it still inputs/outputs ppm files). Every pixel is processed. Pass a large image to it at your own peril! It will eat up all your RAM!
You do not have the required permissions to view the files attached to this post.
pifactorial
Bounty Hunter
Bounty Hunter
Posts: 170
Joined: Mon Feb 21, 2005 7:04 am
Location: Pomona College
Contact:

Post by pifactorial »

I'm going to do some work to optimize this for use with libpng (and some general cleanup).

As far as implementation into Vegastrike, the fact that all planets are spheres (correct?) makes it just an issue of math. I think I can come up with some pseudocode for finding the pixel size and visible area of a planet's texture, based on:
  • Your position relative to the planet
  • Your rotation relative to the planet
  • The planet's size
  • The planet's texture size

Any input/assistance would be greatly appreciated.

Just one other issue, kinda off topic, but not worthy of its own thread. I assume that planets' rotation speed is randomly generated, because I've seen some planets rotating nausiatingly fast. It's kind of hard to believe that a planet with a day 10 seconds long could keep from flying apart, much less support life (or be landed on). Maybe we should use more realistic values for this? Where is it determined?
Anax
Bounty Hunter
Bounty Hunter
Posts: 243
Joined: Mon May 05, 2003 7:16 am
Location: Brisbane, Australia

Post by Anax »

pifactorial wrote:Just one other issue, kinda off topic, but not worthy of its own thread. I assume that planets' rotation speed is randomly generated, because I've seen some planets rotating nausiatingly fast. It's kind of hard to believe that a planet with a day 10 seconds long could keep from flying apart, much less support life (or be landed on). Maybe we should use more realistic values for this? Where is it determined?


Actually, depending on the size, it is VERY realistic. Think about it. Gravity vs Centrifical Force. BIG BIG planet has LOTS of gravity. ie lots of DOWN force. Fast spinning planet has lots of UP force. Make a big planet spin fast and you may be able to get it to even out! :)

Fast spinning is actually more likely to have effects on weather. In particular the fast heating/cooling cycle of each side would make for some serious storms and winds....
pincushionman
ISO Party Member
ISO Party Member
Posts: 467
Joined: Mon Jan 13, 2003 9:55 pm
Location: Big, flat Kansas
Contact:

Post by pincushionman »

Fast rotation speed is not out of the question. Jupiter makes a full rotation in just under 10 hours, and neutron stars are thought to rotate very quickly -- the pulsar in the Crab Nebula appears to rotate at about 30 rotations per second. Granted, information about pulsars is heavily theoretical, but I'm not aware of any other plausible explanation for how such a massive object could "pusle" with such regularity.
Conquer space!
-pincushionman

---------------------------------------

Kansas really is flatter than a pancake!
www.improbable.com/airchives/paperair/v ... ansas.html
Space Pirate
Mercenary
Mercenary
Posts: 118
Joined: Sun Sep 12, 2004 10:47 am
Location: Crucible/Enyo System

Post by Space Pirate »

pincushionman wrote:Fast rotation speed is not out of the question. Jupiter makes a full rotation in just under 10 hours, and neutron stars are thought to rotate very quickly -- the pulsar in the Crab Nebula appears to rotate at about 30 rotations per second. Granted, information about pulsars is heavily theoretical, but I'm not aware of any other plausible explanation for how such a massive object could "pusle" with such regularity.


Of course, that is a pulsar, but a planet could be different. Correct me if I'm wrong, but pulsars are very dense and strong gravitationally. (Much stronger than a planet, anyway).

Make a big planet spin fast and you may be able to get it to even out


That would make sense. It wouldn't necessarily need to even out... if the planet is large enough, the gravity COULD in effect be large enough to overpower the Centrifical force. But the planet would be weirldy shaped, because the planet would be slightly thicker than a perfect sphere at the equator due to all the centrificial force. (Actually this happens with the earth, but it's effect is very small).

And if landing a ship becomes a problem due to the force of the planet's rotation, you could just land at the poles where there wouldn't really be a problem since a planet goes around much more slowly at the poles.

Also, if the planet is a gas giant, fast moving clouds of gas COULD make it look like a planet is rotating a lot faster than it really is.

Of course, most people playing the game would find a really-fast rotating planet odd, distracting, or even a cause of simulator sickness...
st_jack
Merchant
Merchant
Posts: 35
Joined: Tue Feb 22, 2005 12:11 am

Post by st_jack »

pifactorial

I read this post, and I also got your note in the thread I had begun. I really like the direction you are taking this portion of the project, but I have to thoughts that I would like to offer as potential solutions. First I would like to state that I am an advocate for more realism in games. Now I have stated in another thread that an RPG element in VegaStrike would be pretty awesome, thus giving more reason to implement planetary landscapes and models. Now onto what I am thinking.

1) At the moment, the visual data used for planetary displays are raster images. This means that they are resolution dependent sets of data. Thus invariable without animation that has been pre assigned to them. (Thinking of ocean/desert currents and weather patterns)

2) If you choose to keep it raster based, why not have LOD images, and up to four or so. I have generated global images before using satellite photos of varying resolution. Its quite easy to get a quite realistic looking textures. With better detailed (higher resolution images) maps geared to be fractalized until you have reached the next level of distance where you need to load the next map. Of course the same should go for the Meshed used for the planets as well.

2a) Question: Is the code set for occlusion? Where the items not being rendered are not calculated. Is there also code for LOD meshes.

3) What about making the textures based on vector information which can be rasterized fairly quickly. Look at Macromedia’s Flash 4.0 to MX and Adobe Incorporated’s Illustrator 9.0 to CS. They “rasterizeâ€
==========================
I.am.a.desert.creature
==========================
Duality
Daredevil Venturer
Daredevil Venturer
Posts: 583
Joined: Sun Feb 16, 2003 12:58 am
Location: West Coast of USA
Contact:

Post by Duality »

The more realism you add in-game, the more unplayable it is.

Some realism aspects in vegastrike could be good as long as it's feasable and playable(example, modied newtonian phsyics with a drag factor I wonder if the devs has known about this).

However, the gameplay dynamics are a lot more important then trying to simulate real life in a sci-fi universe.

As for adding tons of realism, thats exactly what the Rylix mod is used for.

Anyways, the idea of making an algorithm to make planet textures more detailed would be pretty neat and acceptable in the main game itself.
pifactorial
Bounty Hunter
Bounty Hunter
Posts: 170
Joined: Mon Feb 21, 2005 7:04 am
Location: Pomona College
Contact:

Post by pifactorial »

[quote="st_jack"]1) At the moment, the visual data used for planetary displays are raster images. This means that they are resolution dependent sets of data. Thus invariable without animation that has been pre assigned to them. (Thinking of ocean/desert currents and weather patterns)

2) If you choose to keep it raster based, why not have LOD images, and up to four or so. I have generated global images before using satellite photos of varying resolution. Its quite easy to get a quite realistic looking textures. With better detailed (higher resolution images) maps geared to be fractalized until you have reached the next level of distance where you need to load the next map. Of course the same should go for the Meshed used for the planets as well.

2a) Question: Is the code set for occlusion? Where the items not being rendered are not calculated. Is there also code for LOD meshes.

3) What about making the textures based on vector information which can be rasterized fairly quickly. Look at Macromedia’s Flash 4.0 to MX and Adobe Incorporated’s Illustrator 9.0 to CS. They “rasterizeâ€
st_jack
Merchant
Merchant
Posts: 35
Joined: Tue Feb 22, 2005 12:11 am

Post by st_jack »

Wow, it seems that every post I read where realism is mentioned there are undoubtedly people who are adamantly against it. Is there something wrong with having a simulation that actually has realism in it? Really, if you take out realism you have "mario bros." or "fox fire". If I wanted an arcade game I would just play "pac man".

“The more realism you add in-game, the more unplayable it is.â€
==========================
I.am.a.desert.creature
==========================
Duality
Daredevil Venturer
Daredevil Venturer
Posts: 583
Joined: Sun Feb 16, 2003 12:58 am
Location: West Coast of USA
Contact:

Post by Duality »

Aaah sorry I misunderstood.

I thought someone mentoined making the gameplay 100% realistic.

I see now.
pincushionman
ISO Party Member
ISO Party Member
Posts: 467
Joined: Mon Jan 13, 2003 9:55 pm
Location: Big, flat Kansas
Contact:

Post by pincushionman »

st_jack wrote:Wow, it seems that every post I read where realism is mentioned there are undoubtedly people who are adamantly against it...

I've said it before and I will probably say it many times again before I die. Most people have confused the concepts of realism with that of believability. They are NOT the same thing. And I think those people who keep saying "I don't want realism because it isn't fun" may not necessarily know it, but they have a more accurate idea what term means what.

REALIM is bringing real-world concepts and processes into the world being created (in this case the game world, but it could also refer to a movie environment or a book). There is one big reason why realism is difficult to pull off, especially in games. We are immersed in reality all the time, and we know what is realistic, because we see it every day. You can tell a bad magician or a poorly-Photoshopped image immediately because it just doesn't look right. In games it's even more difficult because we're still short on computing power needed to properly simulate a realistic environment.

BELIEVABILITY is much more forgiving, and most of the time it's a hell of a lot more fun to be a part of. Concepts of realism can be incorporated into a believable environment, and often are, but only to the extent that they add to the immersion. Anything beyond that is superfluous and is thrown away, and new rules are written. This makes believability much easier to achieve, and at the same time, much more difficult to pull off properly.

If a person is shot in an action movie, the realistic result is he drops to the floor. But that's not fun to watch, so instead the bullet knocks them off into the water. To enhance the beliveabiltiy, that happens every time someone gets shot (except for the main character, of course, he just bleeds). In our world, we need to get to a planet far away. Realism would say we need 200,000 years and a fuel tank the size of the moon, but that's not any fun. So we make up a magic super-fast travel system, and use it all the time. And we make up fictional documentation to back up our absurd creation.

We still know it's not realistic, but we believe it anyway. Why? Because we want to, and we can belive it "exactly the same" every time. The real secret to making a believeable environment is to take advantage of just enough of what reality does give us to help our immersion, then make up stuff to keep people interested, and use that made-up stuff in a way that is consistent throughout the entire game experience, offer "believable" (again NOT realistic) explanations in case people DO question it, and use this made-up material in such a way that the people playing WANT TO BELEIVE IT.

It's called willing suspension of disbelief, people. That's the secret. NOT realism.

There's another big strike against realism and games -- real life is boring! people play games to get away from reality, not to become more immersed in it. If I want to have fun with reality, I'll go call my friends and we'll go outside and play football.
Conquer space!
-pincushionman

---------------------------------------

Kansas really is flatter than a pancake!
www.improbable.com/airchives/paperair/v ... ansas.html
jackS
Minister of Information
Minister of Information
Posts: 1895
Joined: Fri Jan 31, 2003 9:40 pm
Location: The land of tenure (and diaper changes)

Post by jackS »

And, to finish of the other side of that same thought, the key reason that people ask for realism (when looking for a consistent, immersive, and hence believable experience) is that, mundane as reality may often be, it is a consistent, immersive, and believable experience. Thus, what is more likely occurring (although there may be some who actually hunger for realism) is that, in expecting their experience to be like that of their normal reality, except in very particular ways, the discontinuities between the two sometimes become apparent, because of some artifact of modeling, or lack of experience with some particular phenomenon that is uncommon on dirtside. This then leaves them desiring some means for greater consistency, and they pull from the most consistent source they're familiar with.

Realism is useful - it's useful because anything we keep the same as what people expect it to be, is already consistent, immersive, and doesn't need to be explained. Reality, however, is just a starting point, like an archetypical makefile before being edited.
st_jack
Merchant
Merchant
Posts: 35
Joined: Tue Feb 22, 2005 12:11 am

Post by st_jack »

pincushionman,

I understand quite well the difference between the two, and I am suggesting more than just a believable simulation of reality in some respects. Like I mentioned in the post above, a social, political, economic system that reacts and changes as markets do. Laws that eventually mold themselves to the "will of the masses" whomever these fictitious or character driven players may be. Of course I am not saying that there needs to be a stock market computation running in the background, that would just eat up an unnecessary number of cycles. What I am suggesting, is that a market does exist, one that not only supports the backing story to VS, but one that will also allow you and perhaps persuade your decisions. If some products were to become illegal in the game, and there were in fact rumors and news broadcasts mentioning it; we might see a rise in price to purchase the item and even selling it. Or well may see a crash in that items value. What about local governorship or what have you? How do their politics play in the story or sway of the social environments. Are there struggles of power between government officials that somehow break into "war"? From what I have seen, it seems as though the VS universe is not persistent. It varies and continues to move in directions that show no predictability like real life does.

It easy to understand why the Russian Federation sells or loses its weapons to China; to offset the influence of the United States. It understandable that people will rise up in protest in Lebanon when they desire to see the pro Syrian president remain in power. It is foreseeable that the United States and the European Union will come to a head at one point in the near future it may erupt into some conflict, but more likely will diffuse as the French model the E.U.'s constitution more and more like the U.S. constitution. Mozambique, a troubled part of the African continent like Sudan, a place where many suffer while law and order are not altruistic or visible much of the time. These are real events happening today that influence the market, the social and political environments. Each with a range and frequency of their own. Some on a global scale and some on a smaller local scale. There are three factions that are known in the VS universe. Are there terrorists, religious zealots, special interest groups? Are there underground movements that are non violent, are there some that are?

Ultimately what makes a universe "believable" or set with some amount of "realism" are people, rather living beings that interact. Because we have no knowable experiences as a tree, a rock, or another kind of being- all we have is our social structure to compare it too.

What about specific cargo, like a particular product by Company A, or a particular meat, vegetable, or organic product. My game experience is very limited at the moment, I still have yet to be able to jump out of the beginning system, non of the wormholes are live.

Anyway, these are some things to consider.

P.S. I still want to make it clear, I am not saying that VS needs to be some hardcore reality simulator in a sci fi universe. That is what Rylix is supposed to become. Right?
==========================
I.am.a.desert.creature
==========================
Halleck
Elite
Elite
Posts: 1832
Joined: Sat Jan 15, 2005 10:21 pm
Location: State of Denial
Contact:

Post by Halleck »

Come to think of it, having a stock market in VS would be awesome! I can't recall any other game that has one. It would be an interesting way to make money, especially if you could influence how well a company is doing a little bit by ensuring their goods reach lucrative markets...
st_jack
Merchant
Merchant
Posts: 35
Joined: Tue Feb 22, 2005 12:11 am

Post by st_jack »

Halleck,

That wouold be funny, almost dirty. *lol*, then you would have to worry a lot about pirates or other merchants attempting to prevent you from making your route.
==========================
I.am.a.desert.creature
==========================
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Post by klauss »

Ah... Finally some people think as I do.

I got to VS through Privateer Remake. (I loved Privateer, that got my attention).

I proposed a Dynamic Economy and some believable politics. Nobody liked it. I now understand why: PR is devoted to recreate Privateer, not to enhance it. I would much like to see it enhanced, but other people don't.

Now, I find you who do want what I want. Well, I had some ideas as to how to make it. It's not that difficult, it can all be done in python I think. But does require a lot of research about how people interact, react to political changes, and that kind of stuff.

Anyway, now that I know you will appreciate it, as soon as I finish what I'm doing right now (sound system and planet textures - I was reading the thread because of that), I'll get working on it and try to propose an economic/political model. It'll be fun.

Back to planet textures: Interesting idea, the plazoom, but I think it could get too complicated. I would prefer a custom interpolator approach. I had thought of a similar idea when pifactorial showed me the thread:

When addressing a texel (in a pixel shader), access also the neighbour texels. Now, if an edge is detected (tweak this), use a fractal function to create a sharp, non-regular contour for it instead of the classic cubic interpolator. This would work well for planetary surfaces which always exhibit fractal-like shapes. If a continuous tone is detected (not an edge), use another kind of fractal (perhaps perlin noise) to create a parametric detail texture, and modulate the basic texture with it.

It would be a quite heavy pixel shader, but would only be required when rendering the planet up close, so it wouldn't impact on performance in other situations. And in those situations, it usually is just the planet showing, so it shouldn't be such an overwhelming task.

With careful tweaking, it could have the potential of eliminating pixelation entirely. What do you think?

PS: The contour thing is tricky, but I have some ideas of how to implement it best. Hardest problem is that I've never worked with fractals, so I can't code that. But I can use perlin noise instead and then replace that with fractals. Why not?

BTW: Impressive thread hijack given that this other issue was
kinda off topic, but not worthy of its own thread


:lol:
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
hellcatv
Developer
Developer
Posts: 3980
Joined: Fri Jan 03, 2003 4:53 am
Location: Stanford, CA
Contact:

Post by hellcatv »

cool ideas for sure
I'd recommend going for the python dynamic economy thing (see trading.py, especially in the privateer remake for how things are looking right now in the cutting edge of the economy--very simple tho) before going to the graphics
I'm planning on overhauling graphics in the summer to do some pixel shader stuff--then we can look into ideas you may have when the infrastructure is in place
Vega Strike Lead Developer
http://vegastrike.sourceforge.net/
mkruer
Site Administrator
Site Administrator
Posts: 1089
Joined: Thu Jan 02, 2003 10:07 am
Contact:

Post by mkruer »

On the Planet textures. I have acquired one of the original Fractal generation programs that is capable of reproducing planet textures consistently and in ever increasing quality.

It was always my intention to integrate the engine directly into the VS core for my Rylix Project, and adapt it so you could either generate textures on the fly or generate textures based upon original textures. This would allow for virtually unlimited texture depth. However I doubt I will get around to it anytime soon.

The original program was FractallPlant by Mark Santesson later adapted into PlanetGen by Chris Maunder. It’s a good system but the code it archaic by today’s standard.

At the very least I would like to see someone take ownership and produce a new up to date version of PlanetGen that includes more support for Bioshperes (this is also included) and have the ability to render gas giant textures and moon textures.

Have fun, and keep me informed
You do not have the required permissions to view the files attached to this post.
I know you believe you understand what you think I said.
But I am not sure you realize that what you heard is not what I meant.

Wing Commander Universe Forum | Wiki
Wing Commander: The Wasteland Incident
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Post by klauss »

I'll try to take a look at the code whenever I have the time. I'm right now more into painting planets by hand, because of the creativity options it allows. But PlanetGen can be a great offline utility for planet artists.

I don't think it can be used as it is right now, since:

a) The terrain follows no logic. It's random. No signal of: erosion, tectonic activity, civilizations, disasters (asteroid impacts?). It would be a too simplistic approach, which shows as artificial terrains - one knows they're not real.
b) The rendering lacks color detail. That's nothing that can't be fixed, though, but would be a lot of work. One should see the mountain's snowy peaks, glaciers, forests, deserts, etc. I think chuck_starchaser already had something to fix that.
c) It lacks fine customization.

Ok. By solving b) and c), it would already be useful. Because with c) solved, one can manually solve a): use the random terrain as starter, and adjust it so that it has fault lines, craters, define erosion characteristics in certain zones to reshape the terrain accordingly, etc. Basically, paint the terrain. So, by reapplying the process to the customly modified terrain, you could get pretty good textures.

But modifying this PlanetGen for that task would be a hell of a task, mainly because of the UI involved.

If I suddenly find myself without anything to do, I'll try playing with it. Hell, if I could make it work like this, I could save me a lot of work on the planet textures.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
mkruer
Site Administrator
Site Administrator
Posts: 1089
Joined: Thu Jan 02, 2003 10:07 am
Contact:

Post by mkruer »

Well if you have used PlanetGen but you are correct it is a little dated, but still the best “freeâ€
I know you believe you understand what you think I said.
But I am not sure you realize that what you heard is not what I meant.

Wing Commander Universe Forum | Wiki
Wing Commander: The Wasteland Incident
Post Reply