Jump to content
Lord Aquila

Environment Improvements

Recommended Posts

Hello Stronghold Nation!

After playing this game a while back, I remember I was quite frustrated, first because of the bugs, but mostly because of the unfinished and rushed stuff. For example, the mechanics and maybe objects that never surfaced, although probably planned, or the quick terrain brushes they did to finish the maps on time, as well as the poor quality of the sea and river water objects. I can see where the game might have ended up being, and I always wanted an improved 3D version of the first game, with new well-thought campaigns, but also as importantly a really well done environment that immerses you into the game's theme and atmosphere.

The engine used in this game has more capabilities in terms of environment quality, than it seems to the average person who fires up the game and enters a campaign, a siege, or freebuild map. So, I decided to see what I can do to improve some environment assets, such as the water shader, for a start. So I made this mod. It features a realistic sea water for the game, by exploiting the shader properties on the editor, as well as changing it's normal map and foam textures. This gave a very nice result in my opinion. 🙂

Next priority for me is to see what I can do with the terrain quality. As I have realised, playing with the editor, the terrain system offers an astonishingly high resolution to play with! (see last image) Painting on the terrain is really high res too, which instantly offers for many terrain ideas (i.e. distinct rocky surfaces) to come to life. So, I tried making a coastal part of the terrain (though unfinished) for a test to see where I can get in terms of quality, and how well it goes with the sea. (see image 4)

I would really like to see your thoughts and criticism!

1.png

2.png

3.png

4.png

5.png

Edited by Lord Aquila

Share this post


Link to post
Share on other sites
1 hour ago, Crusader1307 said:

Quite ambitious. Look forward to more of your Mods, as are others I imagine.

Thank you. Though my free time is limited and not consistent at the moment, but I hope I can provide with results from time to time.

Share this post


Link to post
Share on other sites

This is pretty incredible I have to say. You have some awesome graphical skills, which has always been an area where I have lacked personally.

The way you've brightened up that terrain really is quite remarkable. Do you think this is something that can be taught to people if we were to put an article up about it? Or does it depend more on the person's individual skills?


Quote

The fields have eyes, and the woods have ears.

⁠— Geoffrey Chaucer, The Canterbury Tales: The Knight's Tale

Useful Articles

Share this post


Link to post
Share on other sites
1 hour ago, Lord_Chris said:

The way you've brightened up that terrain really is quite remarkable. Do you think this is something that can be taught to people if we were to put an article up about it? Or does it depend more on the person's individual skills?

Definitely can be tought! The main skill was finding the "catch" within the sea water properties to achieve the coloring and other shader stuff you see there. Maybe also the ability to make a seamless tiled texture that doesn't seem repetitive, which I think everyone can understand how to do it within a few minutes.

However, the main part for me on this mod that really is the icing on the cake is the water normal (mainly the water form) quality, which I wouldn't say it needed much artistic skill to create. In fact it was created for me by the Blender software, after adjusting the ocean modifier's properties, and exporting part of it in a way that it was seamless.

So again yes, it can be tought, since the whole process is actually playing with numbers and adjustments, and judging from the result they give you, rather than a super manual process, like sculpting on a mesh, which is the case of terrain sculpting, that it's more of a person's individual skill in my opinion, since it's mainly a manual artistic process. However, I think an article is feasible on this topic too, on how one can achieve better terrain results.

 

Edited by Lord Aquila

Share this post


Link to post
Share on other sites

Would you be interested in writing an article for us on how people can do this kind of thing? Or if not, possibly explain it to me so I could have a go and write something?

I really feel that this could massively help people in customising the newer games and it's quite an exciting opportunity.


Quote

The fields have eyes, and the woods have ears.

⁠— Geoffrey Chaucer, The Canterbury Tales: The Knight's Tale

Useful Articles

Share this post


Link to post
Share on other sites

I would be very interested to do it! However, it might take a while because of my limited time the upcoming months. Is it ok if it takes a while? Or maybe I can steal some hours and it comes along easier and faster than I think.

So yeah, I will start writing as soon as I can. If I see it takes longer than I think, or become unable to continue due to not having enough time, I will let you know. 🙂

Edited by Lord_Chris
Removed unnecessary quote of previous post

Share this post


Link to post
Share on other sites

That's fine :classic_smile: Take as long as you need there's absolutely no rush. I'll definitely look forward to reading it, though!


Quote

The fields have eyes, and the woods have ears.

⁠— Geoffrey Chaucer, The Canterbury Tales: The Knight's Tale

Useful Articles

Share this post


Link to post
Share on other sites

 

23 hours ago, Lord_Chris said:

That's fine :classic_smile: Take as long as you need there's absolutely no rush. I'll definitely look forward to reading it, though!

Thank you! I hope it comes about well done.

 

The sea water shader is not all there is in terms of water of course, so I found a little bit more time today and next I tried messing around with the river. We all know how bad rivers look in Stronghold 3.. They are like glass planes with an animation video projected on them. Too flat, colourless, dull and without depth and form.

Things are trickier now however, as the shader properties are not accessible via the Map Editor. What's more, there is a main issue, that I will get to later.

I found a solution after a while though, and that is the 'water.xml' file inside the 'definitions' folder in the 'core.v'. There are all the bunch of options there from 'opacity', to 'water_tint', 'normal_scale', etc. I played with those values, but only a few of them worked.. One of them, the 'opacity' which gave this nice depth transition you notice in the sea mod I made, didn't seem to work as such, hence the flat look on the river. There is no transition at all and the value applies to the whole area of the river equally.

Here is an example of the best result I could get so far:

1.thumb.png.a32079e3f9adb9d347208b8ef4c037e4.png

 

What's more, inside the xml file there are references to a water colour and normal texture, but not to foam, as it clearly has such option, after I checked the .vshaderbin file of the river shader, which actually pointed to a marsh foam texture. I know foam is not the most important thing, but it's weird why this reference was not inside the xml too. However, I edited the path from there to point the shader to another foam texture, that of the sea for now, to see if it worked, which it did. (I edited the .vshaderbin file with HxD software, as it was the only way to save it afterwards without information loss, as it is a binary file)

Anyway, so my main issue is that although there seems to be references to darker and brighter colour choices according to water depth, which means the shader probably supports depth transition (also some 'depth fog' parameter inside the .vshaderbin file), it doesn't render it, and I  can't seem to find a way to fix it and understand if it is a bug or done intentionally for some reason. Here is a comparison of the river(above) with the sea(below), which transitions nicely + has an actual water form (erased the shore foam for it to be more apparent):

2.thumb.png.166c2eafa358fa335de18b5784807eae.png3.thumb.png.9ef583fbe53ae77a30210d6b7e595dd3.png

 

I tried replacing with the sea water shader files, but obviously got an error when trying to paint river on the editor. Then I remembered that in SC 2 the river water actually has some transition and I thought why not trying replacing with those shader files. I didn't get an error, but the water was invisible, althouh the engine recognised it. I thought maybe the opacity form that version has different standards than the S 3 one, so I increased its value, but still no change.

4.thumb.png.d191a54d1e4150581caf2ce4ab14f34a.png5.thumb.png.e3392e540684262b3310b7db57e4919e.png

Any ideas?

 

EDIT: Forgot to mention that I have noticed there are 2 shader files for river, one for dx9 and one for dx11. Maybe the game is bugged to a low quality dx9 shader rendering? And I need to find the switch to dx11 or at least a better quality dx9 version?

Edited by Lord Aquila

Share this post


Link to post
Share on other sites
On ‎15‎/‎11‎/‎2020 at 14:58, Lord Aquila said:

Anyway, so my main issue is that although there seems to be references to darker and brighter colour choices according to water depth, which means the shader probably supports depth transition (also some 'depth fog' parameter inside the .vshaderbin file), it doesn't render it, and I  can't seem to find a way to fix it and understand if it is a bug or done intentionally for some reason. Here is a comparison of the river(above) with the sea(below), which transitions nicely + has an actual water form (erased the shore foam for it to be more apparent):

If the Sea is transitioning, but the River is not, then this is something to do with the game itself. I've checked the water.xml file and I can only find an entry added for River, not Sea. So you only changed one entry for the river water, right?

It's also possible that Sea has different files to the River. I don't know about this as I haven't looked closely enough, but if this is the case, you would need to modify the files themselves and change the colour- try a really light colour at first, to see what happens, maybe something that isn't even a water colour at all like White, because this will stand out regardless of where it is placed, and will give you a clearer indication as to what shading works and what doesn't.

In the particles folder there are also two files for water splashing and water mist. I don't know whether these may be of any use in this case or not.

Additionally, it is also possible that this feature just isn't available for rivers, for whatever reason- even if it seems to be and the option is there. I know that in Stronghold Crusader 2 for instance the game has a whole load of files from Stronghold 3 such as environment, I think off hand, that just aren't used, but the functionality is still there. Firefly have a habit of leaving unused files within game installations, so this may be why if it still continues to not work.

P.S. Without knowing the exact changes you're trying to make (i.e. seeing the code) it's very difficult for me to debug and see what might be going wrong. It may be worth posting your code below so I can run it in my own game line for line and see if it's working for me, or I see any issues with it.


Quote

The fields have eyes, and the woods have ears.

⁠— Geoffrey Chaucer, The Canterbury Tales: The Knight's Tale

Useful Articles

Share this post


Link to post
Share on other sites
On 16/11/2020 at 20:21, Lord_Chris said:

If the Sea is transitioning, but the River is not, then this is something to do with the game itself. I've checked the water.xml file and I can only find an entry added for River, not Sea. So you only changed one entry for the river water, right?

Yes, I played with the the water values on that section to make any changes, apart from the foam texture reference, which as I said was inside the shader binary file of the river. Fortunately it worked after changing the path.

On 16/11/2020 at 20:21, Lord_Chris said:

It's also possible that Sea has different files to the River. I don't know about this as I haven't looked closely enough, but if this is the case, you would need to modify the files themselves and change the colour- try a really light colour at first, to see what happens, maybe something that isn't even a water colour at all like White, because this will stand out regardless of where it is placed, and will give you a clearer indication as to what shading works and what doesn't.

Yes it does. From what I have got so far, they are the shader files inside the "River.Shaderbin" (for river) and "Water.Shaderbin" (for sea) folders, inside assets/shaders.

I tried all sorts of colours, even white, believe me, and they worked only in the case of the water tint colour, which by the way has more of a mask for the main diffuse texture of the river (which is the dds file that gives the river it's actual colour you see). In the sea water shader, it was more obvious. Probably it's not applied to he river. However, I have noticed lines inside the .vshaderbin file, that mention "depthFog" and "depthFogCol", as well as inside the .shaderlib source file. (+ " #define HAS_DEPTH_INFORMATION", which I couldn't find a way to get it working, probably because I have to find and edit it inside the compiled shader file somehow (dx9.vshaderbin or dx11.vshaderbin), which I couldn't.

3.thumb.jpg.6666b3aeb540db04d06656ef341215cc.jpg2.thumb.jpg.b3db52913917d140782b270814936f7a.jpg

The 'water splash' and 'water mist' files are probably related to some effects objects you can add in the editor. Like the ones in Stronghold 2 editor. So I think they are not related to the shader.

Finally, here is the .xml values I currently use, but I am feeling the river looks even worse than before, haha. Also, those apply better on a different normal texture I replaced with, so it might look too reflective or shiny for example. 

	<water_type name="River">
		<texture diffuse="textures\particles_and_effects\water.colour.dds" normals="textures\environment\water\water.normals.dds" />
		<opacity>0.85</opacity>
		<flow_speed>0.19</flow_speed>
		<roughness>0.205</roughness>
		<normals_uv_scale>0.0015</normals_uv_scale>
		<normals_scale>1.0</normals_scale>
		<fresnel_power>4.0</fresnel_power>
		<fresnel_scale>3.0</fresnel_scale>
		<fresnel_offset>0.1</fresnel_offset>
		<water_tint_color r="255" g="0" b="0" />
		<dark_water_color r="50" g="50" b="50" />
		<bright_water_color r="100" g="100" b="100" />
		<shore_fadeout_range>0.04</shore_fadeout_range>
		<edge_transparency_scale>5</edge_transparency_scale>
		<reflection_multiplier>0.4</reflection_multiplier>
		<depth_fog>255,255,255,1.0</depth_fog>
		<depth_fog_col>255,255,255,1</depth_fog_col>

		<low_detail_water_color r="0" g="40" b="60" />
		<low_detail_scale>0.0006</low_detail_scale>
		<low_detail_blending>0.6</low_detail_blending> <!-- 1 = All texture, 0 = all tint-->
		<low_detail_opacity>0.25</low_detail_opacity>
	</water_type>

As you can see, I also added "depth_fog" and "depth_fog_col" values to see if they work, but they don't. I noticed they are float4 type, that's why you see 4 numbers there, but I haven't been able to get something working. Maybe they just don't work this way, or not at all, like you said.

P.S. I am working a little bit on the waterfall object. I just replaced the texture for the moment to see how it looks and it comes about quite better. Though the lower flowing parts look a little bit too stretched. (You can see how bad the river looks at the moment)

1.thumb.jpg.361e4eb152c026100796dee1d8fd345f.jpg

Edited by Lord Aquila

Share this post


Link to post
Share on other sites

You've been working a lot on this, and it looks pretty interesting. Stronghold 3 already provides players to make and play games in stunning landscapes, and this pushed it much more ahead!

Sorry for a dumb question now, you wrote a lot, and I might have missed it... Would you this way enable somebody to make better maps which could be played in non-modified game too, or would everybody who wants to enjoy these edits need to apply the mood on his game as well?

Sent from my Mi A2 Lite using Tapatalk

Share this post


Link to post
Share on other sites
On 21/11/2020 at 17:23, EaglePrince said:

You've been working a lot on this, and it looks pretty interesting. Stronghold 3 already provides players to make and play games in stunning landscapes, and this pushed it much more ahead!

Sorry for a dumb question now, you wrote a lot, and I might have missed it... Would you this way enable somebody to make better maps which could be played in non-modified game too, or would everybody who wants to enjoy these edits need to apply the mood on his game as well?

Sent from my Mi A2 Lite using Tapatalk
 

Thanks! 🙂

I am writing an article where I explain how I did all of this, where it will answer your question in detail, but overall, yes and no. For example, one can achieve a pretty decent result in sea water, without the need of my mod, as the Editor provides options for the sea shader (which I will also show the way in the article). However, if they want the full aesthetic package, they will need this mod, or of course the way to create it themselves, if they want to. Also, if one wants to tweak the river, they have to go beyond the Editor too, as for the river there are no such options in the editor, as the sea. 

Speaking of which, I realized that SC 2 uses a different graphics settings system, at least for the river shader, which is hardwired within its shader files. This system has references to different LOD types of its basic diffuse texture, which is needed for the river to show at all. Those references vary between this game and S 3. That's why, when I replaced the S 3 river shader with the one from SC 2 (the .vshaderbin files), the river didn't show. Because, it couldn't find the diffuse texture, as the pathing system is different and based on SC 2 Graphics Settings. There are 4 .pak files in SC 2 assets folder, which contain the different LODs of its diffuse texture (.../textures/environment/water_river.colour.dds) and of which the game chooses one that fits your graphics settings. Whereas, in S 3 there are not such files.

So, I need to find the right lines within the Shader file, to fix the path finding system to S 3, so that it can find the diffuse texture and finally show the river, in its new better now form.

Share this post


Link to post
Share on other sites

So there's a lot going on here and it's not really easy to digest it all because there are so many files involved now. What I think caught my attention most of all is the fact that as you've previously pointed out there are two shaders, one for DirectX 9 and another for DirectX 11 (some textures also seem to have shaders for DirectX 10 as well, but at least in the case of the water this isn't happening). I suspect that in this instance the DirectX 9 shader would be used on DirectX 10 installations. What version of DirectX are you actually playing the game using? It's important not to just assume this, but to actually try and verify that (a) this version is actually installed on your machine, and (b) that the game is definitely running using this version (not as important if you only have 1 DirectX version installed).

You can check this through creating a DxDiag file. The minimum version is 9, so I'm guessing it will probably be 9.0c as the lowest possible value (pretty common on older games). With Windows 10, I've be surprised if it wasn't 11 now, unless you have manually configured something. Once you've established this, you should also check to make sure that your hardware (specifically your graphics card) is fully compatible with Stronghold 3, and that it is fully capable of displaying all of this.

I know that it probably is, so please don't think I'm being patronising, I'm just trying to make sure we've covered every possible angle first outside of the game before we start trying to look at the game itself, so we can quickly establish that it's definitely the game that is at fault. Next, you should check the graphics settings in Stronghold 3 itself. You can do this by finding the options.xml file in your My Documents/Stronghold 3/Profiles/ folder. The second row will look something like this:

<graphics ssao="2" dof="false" terrain_detail="2" terrain_shader="2" terrain_detail_textures="true" rim_light="true" bloom="2" tone_mapping="true" lod_scaling="2" dynamic_lights="true" vertical_sync="false" shadow_quality="2" particle_detail="2" water_detail="1" texture_detail="0" overall="2" fullscreen="true" />

Please note that these are personalised settings, and will probably have been created automatically by the game on installation, depending on what it perceived as being capable by your hardware. You can also check or modify these via the graphics settings in the game as well.

Once you've done this it's probably a good idea to enable error reporting. This is something you should always have enabled if you're playing around with the game files because it will alert you to any programming problems. It is possible that when you've changed the values, it could be causing some kind of mathematical programming error but because the game is handling it and error reporting is off, you don't know about it.

To do this, locate the config.xml file in the bin/win32_release folder, and replace 0 with 1 on the following lines:

<errordialog enabled=0 />   <!-- Enable/disable pop-up error/warning dialog. -->
<onscreenprint enabled=0 /> <!-- Enable/disable drawing Vision::Message.Add() messages -->

After this, restart the game and try creating a map with your river texture in. Save the map, play it in the game, and see if any errors appear. If nothing appears, nothing crashes and it all seems fine, then you can be sure that the values you have changed (that are actually editable) are being accepted by the game.

I have a couple other files you should look into as well. I opened the River.ShaderLib shader file you mentioned and just from an overview I can see that this is an important file. I can see that the DirectX version is set to 9 from here. Whether or not this is a safety measure, i.e. a fallback in case DirextX 11 is not installed, I do not know.

Have a look in some of the other files and see if you can find a class called WaterShaderPass. This could be significant. My instinct is that this is one of the compiled C++ or C# classes, so it might not be viewable, but I don't know as I haven't looked into it. I can also see from that shader file there's a potentially important DDS file called \textures\particles_and_effects\marsh_foam.colour.dds. Maybe looking at some of the .normalmap files might be useful as well, particularly in relation to opacity.

This is the foam colour for marsh, but it's equally possible that this could be also loaded into the river texture as well, so it's worth ruling this out. As well as this, you should take a look at the RiverShaderPS.inc, RiverShaderVS.inc and WaterShaderHelpers.inc files. All of these have references to specifically the water depth.

It's my honest opinion that a lot of this is being mathematically calculated by the shader files, which is probably why changing settings in the XML file is not having much effect. However, it might still be possible to change this through changing the algorithms.

I don't want to overload you with info and I feel this has been quite a lengthy post so I'll pause here for now and we can continue again once you've had a chance to review all this. :classic_smile:

P.S. It's great that you're trying to add in new values with the XML file, but sadly as these values have to be parsed, adding in totally new values probably isn't going to work. That's really because the ones that are there already are hard-coded somewhere for the game to parse those values, and then use them. What I suspect is happening in relation to the Water depth is that the game is calculating it based on some kind of formula, and therefore, it's not using anything in the XML file, because Firefly didn't create it that way. So adding in new values only modifies the XML file, not the wider game where the XML values are read and used.


Quote

The fields have eyes, and the woods have ears.

⁠— Geoffrey Chaucer, The Canterbury Tales: The Knight's Tale

Useful Articles

Share this post


Link to post
Share on other sites

@Lord_Chris, that was really insightful! Thank you very much, as I am still learning all of this stuff!

I will definitely consider all your time to look into this and your notes on the matter, and I will get back with my results.

By the way my specs are pretty strong:

core i7 8750H
GTX 1070 8 GB VRAM
16 GB RAM

However, I will definitely follow your suggestion about which dx the game is set to run in my case, before making any conclusion!

Thanks again! 🙂

Edited by Lord Aquila

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...