Jump to content

[1.12.x] Parallax - PBR Terrain and Surface Objects [2.0.2]


Gameslinx

Recommended Posts

Now that I'm back on windows (I suck @ linux) and can install mods correctly again, I can't say enough about how incredible this mod is. But I'm currently experiencing a thing where only a large circle of the surface of the Mun is visible from low orbit (under 40km). 


https://youtu.be/EHG3z73m3Yc

 

As far as I can tell it only is happening on the Mun.  Something similar is happening on Kerbin, where the textures dissapear beyond a certain radius, but the planet is still visible.

Any ideas?

log file: https://www.dropbox.com/s/j05p12fnk2m7p6p/KSPlog326.txt?dl=0

Edited by Invaderdave
trying to figure out how to embed video & added Kerbin footage & added log file link
Link to comment
Share on other sites

Development Update - Performance

VRAM

Hey all, I've been spending some time working on the features I outlined in the last update (https://forum.kerbalspaceprogram.com/index.php?/topic/209714-112x-parallax-pbr-terrain-and-surface-objects-202/&do=findComment&comment=4257019).

Essentially I am rewriting a core portion of the mod responsible for object placement in order to switch from world space to local space in order to fix many key positioning issues that can arise in the mod, such as the floating trees. I have also made an estimated reduction in VRAM usage of 56%. At least, this is the VRAM usage of the generated objects on all built quads within range before they are evaluated by the culling compute shader.

Before, I would compute the localToWorld matrix immediately and store these ready for the culling shader to process them and output the objects in range. This matrix is 16* 4 bytes. Now that the system works in local space, I only need to store the local position, rotation and scale as a float3, float and float3 (7 * 4 bytes). The culling shader now does a little extra work to construct the localToWorld matrix every frame, but this isn't too expensive to do. More testing - and in-game - will tell me more. But for now, this is looking promising.

FPS

I am able to make an approx 4x reduction in performance impact with shadows enabled. A fun drawback of Unity's DrawMeshInstancedIndirect function is that it draws the mesh in all shader passes in all shadow cascades. A shadow cascade is a region of shadow based on distance from the camera of varying quality. Further away objects will use a lower quality shadow map - a higher shadow cascade. With 4 shadow cascades, each object is rendered once for the scene and one additional time for each shadow cascade. This leads to rendering the object 4 times when it only lies in one shadow cascade. 

I have some preliminary but not perfect code in place to differentiate Parallax objects into 4 regions based on which shadow cascade those objects lie in. Each set of objects are drawn using a command buffer before each relevant shadow cascade renders. This means that most objects will be drawn just once for the shadow pass, and very few will be drawn twice if it lies within two cascades.

Quick note - This technique will reduce the number of vertices rendered by around 75%. 

In a unity test scene with this code and a lot of objects, frame time changed from 17ms (58fps) to 4.4ms (227 fps) which is roughly a 4x increase in performance.

I am looking forward to sharing more with you all soon!

Link to comment
Share on other sites

1 hour ago, ShadowDr said:

Huh, does it mean that Unity's own code is somewhat cheeks shaped?

It could be. But DrawMeshInstancedIndirect appears to be a much lower-level command in that it's very specific and very direct "draw this here now".

I am really struggling to figure out how to correctly identify which shadow cascade an object is. I assumed it was camera distance based, but it's not in world space coordinates. Anyone with the know-how would be much appreciated, lol

Link to comment
Share on other sites

I am curious if this new update will improve the performance and density on rescaled systems?

Right now on a 10x rescale, I'm having to increase the densityMultiplier to 100 (according to other posts) to get the same density as normal. Though any value higher than 40 or so will just crash my game, presumably because of running out of ram. Also increases load times by a large factor and seems to cause microstutters.

Edited by UltraJohn
Link to comment
Share on other sites

45 minutes ago, UltraJohn said:

I am curious if this new update will improve the performance and density on rescaled systems?

Right now on a 10x rescale, I'm having to increase the densityMultiplier to 100 (according to other posts) to get the same density as normal. Though any value higher than 40 or so will just crash my game, presumably because of running out of ram. Also increases load times by a large factor and seems to cause microstutters.

Absolutely. Although I haven't yet to test ingame, the on-paper benefits are pretty big.

Some things may be unavoidable. KSP wasn't designed to work well at large scales and I am trying to add cool new tech to a very old and technically inefficient game. I'll see what I can do but no promises! I imagine you will realistically be able to achieve a higher density before running out of memory, but who knows.

Link to comment
Share on other sites

1 minute ago, Gameslinx said:

Absolutely. Although I haven't yet to test ingame, the on-paper benefits are pretty big.

Some things may be unavoidable. KSP wasn't designed to work well at large scales and I am trying to add cool new tech to a very old and technically inefficient game. I'll see what I can do but no promises! I imagine you will realistically be able to achieve a higher density before running out of memory, but who knows.

Sounds great and I can't wait to try it out. Thanks for the work you're doing!

Link to comment
Share on other sites

5 hours ago, UltraJohn said:

I am curious if this new update will improve the performance and density on rescaled systems?

Right now on a 10x rescale, I'm having to increase the densityMultiplier to 100 (according to other posts) to get the same density as normal. Though any value higher than 40 or so will just crash my game, presumably because of running out of ram. Also increases load times by a large factor and seems to cause microstutters.

Helo there.
Other posts did a derp. Try decreasing rangeMultiplier instead, and leave the rest alone.
Range defines how far from you scatters appear, Density - how many of them appear in that range. In rescaled systems, range stretches with the planet and becomes gigantic. By increasing density, you fill all that gigantic range with dense scatters and it dies. What you want is to scale the range back down to intended level. Works and looks just as stock then.
But there's a caviat, apparently KSC area is meant to not have any trees in it, and on rescale it remains tree-free, so you'll only see the forests way out on horison
 

Edited by ShadowDr
Link to comment
Share on other sites

8 hours ago, ShadowDr said:

Helo there.
Other posts did a derp. Try decreasing rangeMultiplier instead, and leave the rest alone.
Range defines how far from you scatters appear, Density - how many of them appear in that range. In rescaled systems, range stretches with the planet and becomes gigantic. By increasing density, you fill all that gigantic range with dense scatters and it dies. What you want is to scale the range back down to intended level. Works and looks just as stock then.
But there's a caviat, apparently KSC area is meant to not have any trees in it, and on rescale it remains tree-free, so you'll only see the forests way out on horison
 

Ah, I was wondering if that was the case about stretching further out, but seeing as they didn't mention it I thought it wasn't the case. Although I feel like the scatter range still looks normal at 10x rescale. I tried 0.1x range multiplier and trees literally spawn right in front of me, so I don't think that was the right value.

What would I need to set the values to for a normal range and density at 10x rescaled planets?

Link to comment
Share on other sites

3 hours ago, UltraJohn said:

Ah, I was wondering if that was the case about stretching further out, but seeing as they didn't mention it I thought it wasn't the case. Although I feel like the scatter range still looks normal at 10x rescale. I tried 0.1x range multiplier and trees literally spawn right in front of me, so I don't think that was the right value.

What would I need to set the values to for a normal range and density at 10x rescaled planets?

Errr i would say just experiment with range, density and your framerate and find whatever works well for you.
First find a range that satisfies you, then tweak density until it looks as you wish. If runs like crap, decrease range further.
I personally try to decrease the default density significantly, as on default every moon's surface is impassable rubble field - not good for playability. Makes Kerbin trees scarce as a drawback.
Currently tweaking it for ~3.5 scale, so can't offer nice numbers
 

Link to comment
Share on other sites

On 3/30/2023 at 3:29 AM, Gameslinx said:

Development Update - Performance

VRAM

Hey all, I've been spending some time working on the features I outlined in the last update (https://forum.kerbalspaceprogram.com/index.php?/topic/209714-112x-parallax-pbr-terrain-and-surface-objects-202/&do=findComment&comment=4257019).

Essentially I am rewriting a core portion of the mod responsible for object placement in order to switch from world space to local space in order to fix many key positioning issues that can arise in the mod, such as the floating trees. I have also made an estimated reduction in VRAM usage of 56%. At least, this is the VRAM usage of the generated objects on all built quads within range before they are evaluated by the culling compute shader.

Before, I would compute the localToWorld matrix immediately and store these ready for the culling shader to process them and output the objects in range. This matrix is 16* 4 bytes. Now that the system works in local space, I only need to store the local position, rotation and scale as a float3, float and float3 (7 * 4 bytes). The culling shader now does a little extra work to construct the localToWorld matrix every frame, but this isn't too expensive to do. More testing - and in-game - will tell me more. But for now, this is looking promising.

FPS

I am able to make an approx 4x reduction in performance impact with shadows enabled. A fun drawback of Unity's DrawMeshInstancedIndirect function is that it draws the mesh in all shader passes in all shadow cascades. A shadow cascade is a region of shadow based on distance from the camera of varying quality. Further away objects will use a lower quality shadow map - a higher shadow cascade. With 4 shadow cascades, each object is rendered once for the scene and one additional time for each shadow cascade. This leads to rendering the object 4 times when it only lies in one shadow cascade. 

I have some preliminary but not perfect code in place to differentiate Parallax objects into 4 regions based on which shadow cascade those objects lie in. Each set of objects are drawn using a command buffer before each relevant shadow cascade renders. This means that most objects will be drawn just once for the shadow pass, and very few will be drawn twice if it lies within two cascades.

Quick note - This technique will reduce the number of vertices rendered by around 75%. 

In a unity test scene with this code and a lot of objects, frame time changed from 17ms (58fps) to 4.4ms (227 fps) which is roughly a 4x increase in performance.

I am looking forward to sharing more with you all soon!

wow, can't wait!!

Link to comment
Share on other sites

30 minutes ago, kowkillar said:

How long should it take to load ksp with this? I've been loading for a while now.

Depends on your hardware. But for what it's worth, on my system (which is a 5yr old rig now) Parallax does not really make a noticeable difference in load-up times. You can see how much it takes to load up all the different parts and textures, and the Parallax files flash through in a snap on my dated system here. (not running the colliders though, never tried them yet)

Link to comment
Share on other sites

I tried parallax on an RSS install on my low to mid end laptop with an igpu just to get a feel for the performance impact, fully expecting it to either run at  5fps or immediately crash. I was extremely pleasantly surprised!

I didn't try it with ground scatters, I only had the terrain shader quality setting on high, not ultra. After taking a quick peek at the moon and Mars, I found they looked much better without too bad of a performance hit. Running the game at 720p, I went from maybe 40 to 45 fps down to around 35-ish.

But the most important thing I noticed is that somehow parallax enables craft shadows even with the render quality set to fastest. In the stock game, shadows are locked to simple or above. And despite the shadows looking like trash on simple, the setting absolutely obliterates my FPS. I thought this was specific to shadows specifically since not much else seems to change when I increase the render quality.

But with Parallax, I have decent shadows enabled on the fastest render setting without any noticeable drop in performance at all. Had no idea that my machine was capable of it. I went from thinking I'd be giving parallax a quick try just messing around with it to making it a mainstay of my modded install just for the sake of shadows alone. I think the OP should probably mention this for the sake of people with lower end systems, I wish I had given it a try a lot sooner. This was a nigh magical experience, and I'd like to thank Gameslinx for the massive amount of effort put into this mod.

Edited by cosekantphi
Link to comment
Share on other sites

7 minutes ago, kowkillar said:

Any help would be appreciated

Am not professional by any means, but..
Seems to have gajilions of new planets on top of stock ones. And it dies off after failing to process landscape features for several last of them. Can it be that you simply run out of RAM on load?

Also says there's no Parallax config for a bunch of them, perhaps some of those packs aren't compatible with Parallax.

Edited by ShadowDr
Link to comment
Share on other sites

2 hours ago, ShadowDr said:

Am not professional by any means, but..
Seems to have gajilions of new planets on top of stock ones. And it dies off after failing to process landscape features for several last of them. Can it be that you simply run out of RAM on load?

Also says there's no Parallax config for a bunch of them, perhaps some of those packs aren't compatible with Parallax.

I'm using grannus pack, but I tried without it and it still wouldn't load. Thanks for responding though.

Link to comment
Share on other sites

4 hours ago, kowkillar said:

I'm using grannus pack, but I tried without it and it still wouldn't load. Thanks for responding though.

Let's try to dig. Will it load on completely bare install, only Parallax and dependencies? Can install via CKAN to be sure to not miss anything. That works, even though not mentioned here by author, thanks good people who did it
Also what's your system specs, RAM and vRAM in particular?
 

Link to comment
Share on other sites

18 hours ago, suskey said:

i always get the warning that i should put terrain quality to high/ultra, but i already have it set to high. how can i fix this?

It need to be on Ultra to use Tesselation. If not on Ultra it will always give you the warning. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...