#Large world with high view distance

1 messages ยท Page 1 of 1 (latest)

subtle sigil
#

Well, lez go

unique wasp
#

Okay, so you might want to reduce the total resolution of your game and use other techniques in order to blend details back in.

subtle sigil
#

if you don't mind, i already tested around 6 different versions of chunking

#

in several months

#

and i'm still not close to the result i want...

unique wasp
#

Like, having each vertex of your terrain detail be 1 m or so. I was thinking that you could make the terrain way simpler, but process the height data in real-time.

#

The problem is obviously related to there being too many of something in the scene. I'm focusing on an approach that doesn't require you to split the scene or stream load pieces of terrain into memory as that sounds like an important requirement to you.

subtle sigil
#

i have no requirements

#

well

#

i do have two

unique wasp
#

Seeing the whole terrain in the distance sounds like one.

subtle sigil
#

first is view distance, yeah

#

i want the mountains to be mountains even if they are far

unique wasp
#

What's your second requirement?

subtle sigil
#

i'd like to paint(texture/steepness) each small tile individually for modding purposes

unique wasp
#

Small tile being a terrain piece?

subtle sigil
#

yeah, the 64x64 one

#

so two mods modifying world can work together

unique wasp
#

Okay, and is this URP, with 4 textures max per terrain piece?

subtle sigil
#

like one changes some cave enterance and second changes the mountain which is on another side of the map

subtle sigil
subtle sigil
unique wasp
#

Well, I am thinking that the terrain shader is the secret sauce to this, because for details, we can always back in new vertices programmatically and leave the underlying data to be much simpler. I think you might be shocked at how jagged Skyrim's terrain data is behind all it's smoke and mirrors.

subtle sigil
#

idk what other games provide modders with, but well, some guys managed to other worldspaces with deserts/lava-lands to Skyrim, where primary colors are grass, dirt, snow and road

unique wasp
#

How familiar are you with shader work?

subtle sigil
#

to get million triangles processed with Graphics.RenderMeshIndirect()

#

but other than that, i only used guides to creates snow/moss shaders

#

which were extremely easy compared to what guys do here with tons of nodes scattered around several graphs

unique wasp
#

Okay, so iwith shadergraph we can easily make something to support 4 textures. With a bit more work, we can do 8, but shadergraph doesn't support multipass rendering, which is what the HDRP terrain shader uses to achieve that (and honestly, it's still a very basic implementation that I don't like).

#

To get a real AAA result, you would need to at least edit the final output hlsl to add the multipass flag and modify some stuff, but that's quite a bit of work coming from shadergraph. I haven't experimented with Amplify, but I understand that it supports multipass as a feature.

#

If you want, I can show you how to override the terrain material with your own shader in like 30 minutes.

#

I have to finish some things before my wife leaves for work.

subtle sigil
#

so well, i cannot use multipass thing in URP?

unique wasp
#

You cannot; that's an HDRP exclusive.

subtle sigil
#

so i should probably move to HDRP

#

i have no clue how to work with hdrp tho

#

I use URP cuz volumes and Decal projector xD

unique wasp
#

Well, what I can help you with now won't really address the multipass part, but you could extend the same idea to HDRP if you wanted to do that. My solution won't include any multipass support. To be clear, your splatmap can have max 4 channels when using the terrain tools in URP and 8 channels if using the terrain tools in HDRP. This is because the interface on the components is hardcoded with those restrictions. To make efficient use of all 8 channels in HDRP, you need multipass rendering control. You can make something that works with 8 channels in the meantime, but it just won't be as efficient as the built-in terrainlit shader in HDRP unless you do some tweaking later.

#

TerrainLit is a slimmed-down version of the lit shader in both pipelines, while the HDRP version uses multipass rendering internally. Shadergraph doesn't support making multipass shaders, but that's only an optimization.

subtle sigil
#

so that means with a lot of time and HDRP shader tweaking i can achieve decent open-world in Unity

unique wasp
#

Until you find new headaches, anyway.

#

You can start in URP and migrate later.

subtle sigil
#

and with URP i can achieve the same thing but a bit slower cuz there is no multipass support

unique wasp
subtle sigil
#

well, i probably can do that yeah

unique wasp
#

But still faster than your memory issues that you're currently facing. This will trade memory data with GPU time.

subtle sigil
#

i already use custom functions from hlsl .shader file in shader graph so my grass works on urp

unique wasp
#

What sort of grass rendering style are you using?

subtle sigil
#

i'm crossing 4 planes

#

billboard grass or smth

unique wasp
#

Okay, so it's basically 3D sticking out. Got it.

#

Like, slices rising up from the ground.

subtle sigil
unique wasp
#

Anyway, I should go and come back before we really start.

subtle sigil
unique wasp
#

OOh, nm I thought you were doing something else.

subtle sigil
subtle sigil
unique wasp
#

I'll brb and let you know when I'm back.

subtle sigil
#

gl

unique wasp
#

Okay, I'm back!

#

So, what I propose is simplifying your terrain and using a combination of vertex and fragment shader to combine your splat and heightmap yourself. You can create your own tessellation rules to expand the nearby vertex count so that there is more detail up close.

#

@subtle sigil

#

To do this, you will need to create a new lit shadergraph with tessellation enabled.

#

To get the splatmap to hook up easily, create a Texture2D input and name it whatever you want, but it's reference name must be _Control0. If you assign that to the shader's colour output, save the shader, and attach the material to your terrain, you should right away see RGB colouring in your game.

subtle sigil
#

should it be just default lit shadergraph

unique wasp
#

Yep.

subtle sigil
#

and i should set it on a terrain

#

not a flat plane mesh

#

when it's done

unique wasp
#

It should work for either, but in this case, the terrain texture2d input will be automatically populated by the terrain system.

#

You will get a warning about the shader not being compatible with the terrain system, but that's only because the hlsl output doesn't have a certain #pragma, so it's literally a useless warning.

subtle sigil
#

well, i can inject pragma in any time, right?

#

with a custom function

unique wasp
#

You could, yep.

#

Can you? I don't know of any functions that add header content.

subtle sigil
unique wasp
#

The reference name must be _Control0. Check the graph inspector.

subtle sigil
unique wasp
#

So, call it Control0 then. The reference will become _ + your given name.

#

Here's an example.

subtle sigil
#

done

unique wasp
#

Perfect. So now, sample the texture using a sample texture2d node and link the output directly to your colour output.

subtle sigil
unique wasp
#

Now, drop that onto your terrain under the terrain settings tab. ๐Ÿ˜„

subtle sigil
#

cool it's white

unique wasp
#

Okay, you should be able to paint the first 4 textures onto your terrain and get RGB values.

#

You will see colour, not the chosen textures.

subtle sigil
#

how do i go about that

#

oh

#

nvm

unique wasp
#

Here's an example from my end. The actual layers don't matter, just the ability to select them with the paint tool.

subtle sigil
#

yeah, rgba

unique wasp
#

There you go! So, what is happening here is the terrain system is hijacking _Control0 behind the scenes and filling that with your splatmap data.

subtle sigil
#

cool

#

now i need to display textures ig

#

instead of colors

unique wasp
#

Yes, you can do that. What this allows us to do is control how tessellation works, because there's a fragment component to the lit shader. That is where you can expand less detail in memory into something more complex to show to the player.

subtle sigil
#

isn't fragment shader needed here cuz of heightmap

#

or it's not connected

unique wasp
#

No, graphics data is just a 2D matrix.

#

So, what I would do next is enable tesselation if you haven't done that already. You should have tesselation options in the vertex shader portion of your master stack.

subtle sigil
#

shoul be some tick here?

unique wasp
#

Okay, this might be limited to HDRP, then.

subtle sigil
#

XD

#

alr well doesn't matter

#

my grass will stop working but still

unique wasp
#

Shit, I took you on a path and hit a wall. To be honest, I thought we would get further with URP.

subtle sigil
#

i can switch rq

unique wasp
# subtle sigil my grass will stop working but still

Not necessarily; if you have your grass objects populating on a channel such as the green channel, you should be able to control the grass texture via your shader but also have the terrain retain it's default object populating behaviour.

subtle sigil
#

my grass is not terrain-based

#

it's another shader on another object which places grass

unique wasp
#

Then I don't see why you can't have both. You can always export your heightmap data and use that in other systems.

subtle sigil
#

well, HDRP uses some weird renderin path so my current grass shader isn't working with it

#

i don't remember what exactly was the problem, but afair my thing rendered all grasses on 0/0/0

unique wasp
#

That should be a simple fix, whatever is going on.

subtle sigil
#

i will look into it later

unique wasp
#

Okay. Some additional notes, then - in HDRP, terrains support 8 layers because it uses two textures for splats. In shadergraph, layers 5-8 appear on _Control1

subtle sigil
#

alr

#

if i'm not able to make terrains, then i shouldn't make this game anyway

#

will try small-scaled stuff instead then

#

or switch to 2D project i planned on doing some day

unique wasp
#

Also, the default tessellation implementation isn't the most effective way to achieve what you want. I was going to get into screenspace maths and show you how to force control at certain distances.

unique wasp
subtle sigil
#

well, i'll tag you when i'm done with all that stuff in hdrp lit shader

unique wasp
#

Sure, please feel free.

#

Sorry, you need tessellation control to command vertex detail finely enough to do the Skyrim open world thing.

subtle sigil
#

idk what that means

#

xD

unique wasp
#

Tessellation involves dividing polygons into... more polygons.

#

The terrain system already renders more polygons close to your camera and fewer away, but it isn't strong enough for what you're trying to do.

subtle sigil
#

even tho it renders more or less, terrain stores the high-res map for the entire game session:)

unique wasp
#

Yeah, you can procedurally reduce that data a lot.

subtle sigil
#

bruh is that even a terrain

#

it's too good to be true

unique wasp
#

Not a unity default one lol.

subtle sigil
#

๐Ÿ˜ญ

unique wasp
#

Tessellation is adding data according to rules on top of your macroscopic "level design" data. Ideally, you would set up your terrains so that they are detailed enough for physics interactions, then leave everything else to just subdividing those polygons on the graphics card.

#

What we did by making that custom shader was create an entry point towards having fine control, but you also need to reduce your detail in terms of terrain data and also switch to HDRP (apparently) in order to have strong enough control over what we can do procedurally.

subtle sigil
unique wasp
#

Did you switch your target to HDRP?

subtle sigil
#

i created a new hdrp project ๐Ÿ˜‰

#

just to keep it apart for now

#

so i don't accidentaly break smth

unique wasp
#

Okay. Do you have a working terrain with RGB painting control?

subtle sigil
#

oh yeah i set the target to hdrp now

#

works alr

unique wasp
#

Okay. So for future reference, you can add a new texture with reference _Control1 to get access to layers 5-8, but we can skip that for now.

subtle sigil
#

i added both textures

#

works fine

unique wasp
#

Okay, I'm going to quickly throw together a depth render path on my end and then show you what I did. Brb.

unique wasp
#

What I did here is create a vertex shader that adds details when the camera view angle approaches being perpendicular to the surface normal of a sphere.

#

This means that the outline of terrain bits gets a bit of extra detail compared to when looking at things head-on. This makes mountain outlines more detailed while the face of a mountain aiming directly at your camera won't have added detail.

#

The triangle texture in this case is a bump map. You can see how it only affects the part of the sphere not directly facing the player.

#

The takeaway here is that we don't need to add detail when looking straight at a surface that is also facing us back. This math that I provided isolates edges and adds more detail according to how much the surface normal is perpendicular to our view. This is technique #1 that you should know.

#

The second thing you need to do is multiply the "tessellation factor" by the camera distance to the vertices. This is as simple as multiplying the scene depth in right before that last connection to the Tessellation Factor float output so that the effect seen here gets reduced as the object becomes further away.

#

After that, you can expose variables so to fine tune the effect in the engine. Pro-tip: you can use compute buffers to make your splat data available to the vertex shader and have the tessellation control scale or use different rules depending on what kind of terrain is being rendered. That's a step up in difficulty, mind you, but it can help further sell the effect.

subtle sigil
subtle sigil