#Large world with high view distance
1 messages ยท Page 1 of 1 (latest)
Okay, so you might want to reduce the total resolution of your game and use other techniques in order to blend details back in.
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...
yeah i might want that
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.
Seeing the whole terrain in the distance sounds like one.
first is view distance, yeah
i want the mountains to be mountains even if they are far
What's your second requirement?
i'd like to paint(texture/steepness) each small tile individually for modding purposes
Small tile being a terrain piece?
Okay, and is this URP, with 4 textures max per terrain piece?
like one changes some cave enterance and second changes the mountain which is on another side of the map
if i'm able to change from TerrainLit shader to smth else, then maybe more
like have snowy textures on some pieces, and warm on other
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.
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
How familiar are you with shader work?
i have written several compute shaders and created a .shader + ShaderGraph for my grass
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
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.
so well, i cannot use multipass thing in URP?
You cannot; that's an HDRP exclusive.
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
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.
so that means with a lot of time and HDRP shader tweaking i can achieve decent open-world in Unity
and with URP i can achieve the same thing but a bit slower cuz there is no multipass support
Unless you make some tweaks in HLSL that shadergraph doesn't support, yes.
well, i probably can do that yeah
But still faster than your memory issues that you're currently facing. This will trade memory data with GPU time.
i already use custom functions from hlsl .shader file in shader graph so my grass works on urp
What sort of grass rendering style are you using?
Okay, so it's basically 3D sticking out. Got it.
Like, slices rising up from the ground.
yeah
Anyway, I should go and come back before we really start.
OOh, nm I thought you were doing something else.
alr i'll wait
nah, individual grass blades are a bit hard for me
I'll brb and let you know when I'm back.
gl
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.
alr doin
should it be just default lit shadergraph
Yep.
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.
done
The reference name must be _Control0. Check the graph inspector.
So, call it Control0 then. The reference will become _ + your given name.
Here's an example.
Perfect. So now, sample the texture using a sample texture2d node and link the output directly to your colour output.
Now, drop that onto your terrain under the terrain settings tab. ๐
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.
Here's an example from my end. The actual layers don't matter, just the ability to select them with the paint tool.
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.
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.
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.
Okay, this might be limited to HDRP, then.
Shit, I took you on a path and hit a wall. To be honest, I thought we would get further with URP.
i can switch rq
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.
my grass is not terrain-based
it's another shader on another object which places grass
Then I don't see why you can't have both. You can always export your heightmap data and use that in other systems.
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
That should be a simple fix, whatever is going on.
i will look into it later
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
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
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.
Well, it's always up to you to work on whatever you want to. If this is a learning opportunity, then yeah it's up to you to determine if now is the right time to tackle these sorts of problems.
well, i'll tag you when i'm done with all that stuff in hdrp lit shader
Sure, please feel free.
Sorry, you need tessellation control to command vertex detail finely enough to do the Skyrim open world thing.
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.
even tho it renders more or less, terrain stores the high-res map for the entire game session:)
Yeah, you can procedurally reduce that data a lot.
You can buy the Asset on Unity Asset Store https://u3d.as/2yV9
Not a unity default one lol.
๐ญ
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.
Did you switch your target to HDRP?
i created a new hdrp project ๐
just to keep it apart for now
so i don't accidentaly break smth
Okay. Do you have a working terrain with RGB painting control?
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.
Okay, I'm going to quickly throw together a depth render path on my end and then show you what I did. Brb.
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.
i definitely need some explaination here
tesselation itself is just adding more "triangles" to the final output, right?