-
-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Planet texturing #4554
base: master
Are you sure you want to change the base?
Planet texturing #4554
Conversation
Oh hey, it actually looks like a planet and not a giant ball of vomit. Imagine that. In other news, I could not be happier that this is finally getting done. For suggestions, I'd throw in distance-dependent detail texturing, e.g. having a high-res texture blend in when you're close to the ground. That'd reduce the tiling-pattern effect of having a higher-res texture at long distances, and mitigate the previous problem of textures being 1:1 pixels to meters. |
Neat! |
@nozmajner I've added a zip of the textures, they're currently horrible :) They're all 1024x1024 and DDS DXT1 compressed, I think that there might need to be some other changes in the future such as adding specular & normal map support but that starts to get very texture heavy so for now they're just diffuse. One option might be to bake the specular data into the alpha channel, that will need some thought and possibly custom art process or code tooling. There are 16 textures + 1 LUT, that plus the two detail texture maps that were already there bring the total number of texture channels used to 19 textures total. It doesn't have to be that many, we could have just two or three for a planet (barren, airless... like the Moon for example) but for now it's 16 total for a planet. The LUT is made of 16 shades, starting at black through to 255. NB: I need to double check this next part but I think that it's correct ;) |
Well that took a LOT longer than I'd hoped. There's still a bug when building Saturns texture that I cannot claim to even begin to understand yet but I'll figure it out eventually. |
Nice to see you back! Let us know when you need testing |
Having used LFS at work on 2 projects now I think I can safely say... I'd really rather use a submodule or another repository instead. LFS works but we've had issues with it. |
Haven't tested the gas giants yet (and I just realized I haven't tested the new textures), but planet texturing appears to be improved. I'm noticing a few issues: You can see in the upper right of this screenshot that there's noticable pop-in where two patches have different UV scale instead of smoothly blending - this might only be a problem with the existing terrain rendering, but ideally we want a consistent UV scaling that blends in the 'detail' UV scale smoothly over distance instead of a binary switch per-patch. EDIT: haven't tried the new textures on Earth, apparently vertex-based coloration is a fallback or something. |
@Web-eWorks that's the existing terrain, it's vertex based colouring, there's already a couple of detail textures. What does this have to do with this PR? |
I pulled the PR and tested it (albeit accidentally without the new texture files) and wanted to point out the issues I saw under what I thought was the new texturing method... On taking a second look, I apparently forgot to change branches before compiling. Please disregard. |
Something you might want to look into (assuming you haven't already) is this post on derivative-based surface normals - from the looks of it, it could help improve the quality of terrain texturing even further than this PR already does. |
@Web-eWorks
yes, I wasn't expecting anyone to try and contribute to the branch so things aren't as well documented as they should be!
it's all work in progress, the LUT is supposed to be one of a selection of LUTs, and this one isn't very good yet, just for testing
yes, it's supposed to be variable eventually
probably should, just used it as-is to get it working
splatting would be ideal I think, use N textures with weighting and blend between them, not figured out how yet
this is just dealing with how it works currently so as not to break things, hopefully it gets simpler because there's only one code path after this is done and it will always use a texture, but development is messy
No Man's Sky did something interesting with this, they defined a palette for each world, the textures were palettised and the palette was simply replaced with this worlds new palette!
There's other formats which support texture arrays but fuck trying to use anything standard from DDS, and it has to be pre-generated DDS due to Intel DDS generation issues on some linux versions with some GPUs
yeah, it's got bugs, lots of bugs
Any source that suits our needs is good by me, I'm just using some textures from... actually I don't even remember but they might not be open source!
ugh, the project I'm on that uses it drives me insane!
horribly, if you look in GeoSphere::SetUpMaterials you'll see at the bottom a height sampling loop. |
4c6372a
to
8d49324
Compare
@fluffyfreak: I've left quite a few links to implementation papers in IRC, most of which are from Frostbite. I've taken another stab at UV scale, and I'm currently doing debug visualizations to track down a few bugs.
|
In case anyone else wants to mess with this, unzip this into pioneer/data which will overwrite some of the files from this PR and the zip that fluffyfreak attached above: I think it's a decent start for EarthLikeHeightMapped: The textures aren't great, but I created them from scratch so there are no issues with licenses. And, more importantly, they can serve as placeholders until something better is created. I approached this by defining terrain types and creating textures for those types: water, light-grass, green-brush, forest, snow and stone (mountains). So in this setup, Earth and Mars are currently using 7 layers of the 16 available. With that, the 'atlas' for a profile contains a layer for each type of terrain. The order doesn't strictly matter, but the LUT will reference the layers by index:
As described above, the LUT texture maps the terrain's height (y) and slope (x) to the layer. It looks like only the red channel is used, so I created a reference table like this to help when modifying the LUT:
It's important to note that even though the profile only has 7 layers, you still index the LUT as if there were 16 (obviously don't use the ones that don't exist). The bright red dot in the top left is water (last layer, it's the brightest). The basic idea is that as slope increases (farther right), less vegetation can grow, so it goes from forest, to brush, to grass and then finally to stone. Similar for height (top to bottom): there's water at sea level, followed by a little bit of sand, grass, brush, forest, then stone and finally snow. |
@The-EG this is exactly what I HOPED would happen with this PR, I've really struggled to pull togethher the textures and visuals but you've done a great job! |
@fluffyfreak Thanks! My intent is that this might help get others started with this. I also created 2 test profiles, one for height and one for slope, that show how the terrain is actually mapped out and allows one to see what's interesting about the terrain. Here's the height (left) and slope (right) test for the moon (red is min , green is max): So, most of the interesting variation is within the height. The changes in slope mostly occur within the first layer (so using slope won't in the LUT won't do much). To get something interesting looking (for the moon at least), we'll probably need at least 7-8 textures of varying shades, most likely darker shades to lower heights, with most of the variation centered towards the max height. A similar approach might work for something like Pluto (Rock) (this is the height test, red=min, green=max): |
@The-EG The ctrl+F10 shortcut might be handy for this, it views the selected nav target, so you don't need to fly to it. Works for planets and ships as well. |
I've added it to my very ugly first draft of development tricks/tools that have, so far, been un-documented: (please add/say if there's any more cool stuff missing from there that is only "documented" in the source code itself) |
Here are the test profiles I created. Just replace the profile you want to test out (ie. EarthLikeHeightMapped.json) with one of the profiles (testHeight.json or testSlope.json): |
Also, I put together a page on the Wiki showing how to create some basic textures from scratch: https://pioneerwiki.com/wiki/Creating_Simple_Pattern_Textures_in_GIMP |
In case it's helpful to anyone: here's a branch where I was able to get the conflicts resolved and merged with master a month or two ago. I have no idea if my choices on the conflicts were right, but it did compile, run and display the planet texturing stuff properly. |
@The-EG thank you for the rebased branch; I wound up rebasing this one instead (and did a fair amount of cleanup along the way). I've been doing some exploratory work into texture blending, so far I have this: In this image, a transition between horizontal LUT texels driven by slope is shown as a transition from bright red to black; you can think of it as a contour map as used in orienteering, except it shows the change in slope, not in height. The green indicates (artificially scaled by 8x) actual slope value. Once I get blending between two different textures working correctly, I'm going to merge this branch into a work branch here on the main repository for you, myself, and @zesterer to work on terrain generation and rendering; I'd like to be able to replace all existing generation and texturing code before we merge it into master, but also be able to collaborate. |
HEADS UP: this branch is going to be force-pushed with the newly rebased branch. To make up for the work you'll have to do locally, have some nice terrain texture blending: I think we're almost to the stage where we can merge this to a work branch and start building out the "procedural" aspect of the texturing; I'll take a look at the TODO before evaluating that, so please let me know if there's anything left to implement or fix @fluffyfreak! |
Make all string representations of the views follow the same pattern, and give views which did not have a name a name. Following this, use that string representation in the Lua side as well instead of using a separate string. This allows for unique and easy referencing of views across the entire codebsae using 'grep' or Visual Studio Code's search function. This also allowed for some simplification of getting/setting views.
Use the new 'onViewChanged' event parameters to only add/remove the radar input frame if the view changes to/from "WorldView".
- Replace GetSamples() with GetMusicFiles().
MusicEvent differs from Event by only one line and is replaced by an Event::PlayMusic method.
This cleans up lots of VolumeAnimate/SetOp calls and allows for future optimizations (such as eliminating one mutex lock operation).
Consolidating all the stop/play/fade operations will allow the number of mutex locks to be reduced in the future.
Fixing the icons.svg I provided for the radar PR, I put the new icons for that onto an older version of the file. The nice thing is that the free space is similar in both, so there's no need to do anything in the theme, if I'm reading it correct.
By placing all of the radar drawing routines into a window, the mouse wheel is captured and is not passed back to the world view. The original implementation failed to get this to work properly as the wrong API was used for setting the center of the 3D radar. Using 'setCursorScreenPops()' instead of 'setCursorPos()' has the 3D radar background showing up in the correct location even when placed inside a window.
Radar buttons are now aligned properly with the other buttons on the screen. Also fix the 2D radar being slightly clipped by taking into account its line thickness.
Use the zoom mode indicator to also toggle between automatic and manual zoom modes for the 3D radar.
- Remove color from GeoSphere/Patch/Jobs/etc - Add support for UV1 attribute - Initial JSON support for terrains
Get the LUT and texture names from the terrain colours config
- wide impacts - remove EnableGPUJobs config option, everything supports shaders! - remove GetColor from all terrain colour templates - fix GasGiant and GeoPatch jobs
- add extra textures - add a_uv1 - add texture sampling code
TextureBuilder Array mangles the filenames that are passed in if vector isn't included. Bizarre bug because it compiles just fine.
6845347
to
654b777
Compare
Urgh, I'd ask what I fucked up with that commit history but it's after midnight and I'm going to bed. Anyway, hopefully some Git wizard can help me fix that later with rebasing or something magical involving history rewriting. It's compiles, builds, runs, it's generally glorious! I've attached a zip with the original textures and LUT, plus the lovely work that @The-EG did. |
- delete all TerrainColorFractal classes - move names to enum, string and surface effect lookups - rework InstanceTerrain method
The removal of TerrainColorFractal, and the deletion of the vector3d color arrays reduces the size of the Terrain class from 2800 bytes to 512. |
I need to work out how to actually Suggestions welcome. Also I'm not sure if the choice of slope & height is really useful for the UV coordinates of the LUT texture. They can be based on anything and I went with them as it seemed logical at the time. However as people have pointed out above slope isn't great and perhaps we could derive some other value to range from 0..1 to replace it? Maybe the pairing could be height and Again suggestions welcome as I'm making this up as I go along. @bszlrd more textures will be very welcome, but I don't have a single coherent answer for what's needed yet thanks 👍 |
NB: This is hilariosuly WIP but there's reasons for making it a draft PR now.
Add texturing to planets based on a Look-Up-Table (aka LUT) and Texture Arrays (aka Atlas)
Here are two shots of Mars with the current code for example:
Work still to do:
GetColor
system fromTerrain
classes (maybe re-use colourisation if viable)HueShift
fromgen-gas-giant-colour.frag
shader can be used to add varietyQuestions, suggestions, thrashing and screaming all welcome.
The textures used for this test so anyone can have a go.
Contained in the ZIP file is a folder with textures, extract it into
/data/textures/
so that you have/data/textures/terrain/
terrain.zip
<impaktor> So how many textures would one need to create an infinite universe?
<impaktor> Something there I don't understand, unless textures are randomly generated.... which I guess counteracts the idea of using a texture.
<fluffyfreak> a finite number of textures, but with a variety of combinations, plus there's the possibility of some hue shifting at runtime
<fluffyfreak> basically you've got a pool of textures... lets say 128 of them in total which is about 80MiB of textures given the sizes etc used so far
<fluffyfreak> you pick upto 16 for a single planet
<fluffyfreak> and those are chosen/blended in the terrain shader using a LUT table
<impaktor> OK.
<fluffyfreak> we may want to do some stuff like use the Git LFS stuff to manage these textures