The LOD mod version 1.4 -Added screenies

Users who are viewing this thread

killkhergit

Squire
Have been experimenting with shaders or a while, and came up with modification of mb.fx(o), which skips geometry after a certain distance from the camera has been reached.




When should I use this mod right now?

1. When you want to improve your framerate.
2. When you're interested in how shaders work.
3. When your graphics card supports the dx9 option of MnB (pixel shaders not needed, but recommended).

Release 1.4

Download --> http://www.mbrepository.com/file.php?id=1573

- Even more optimization
- Made all vertex shaders use LODs
- Simplified options, added english comments
- Set fading to off by default
- Compatibility with the Flora Mod

Release 1.3

- Made all vertex shaders use LODs
- Added even more user friendly options, with dutch comments
- Added an optional fading instead of discrete dissapearing

Release 1.2

- Made most vertex shaders use LODs
- Pixel shaders do cooperate now, no artifacts anymore
- Fixed a few shaders

Release 1.1 beta

- Made most vertex shaders use LODs
- Added more user friendly options
- Pixel shaders do cooperate now, no artifacts anymore

Release 1.0 beta

- Made most vertex shaders use LODs
- First release
- Pixel shaders don't yet cooperate at the moment

How to install:

- Place both 'mb' files (mb.fx/mb.fxo) in a backup.
- Put the new ones including defs.fx when using v1.3 in their place.
- settings can be edited in the top section of mb.fx

When a frame needs to be drawn, and in that frame a model needs to be drawn, the CPU tells the graphics card to go render 'that' model on 'that' position in the frame. Take a tree for example. They mostly use a materials called 'trees', this material uses the 'flora' shader. In mb.fx, the CPU will then go looking or a technique called 'technique flora':

technique flora
{
    pass P0 // First frame pass   
    {
          compilecommand of the vertex shader
          compilecommand of the pixel shader
    }
}

Every model which uses 'trees' material gets the 'flora' treatment. All the previous stuff is being put together by the CPU, and sent to the graphics card.
First the vertex shader is called (vs_flora()), and every vertex* is processed by it. When all vertices are passed, most important stuff (like colors, positions, texture coords) are sent back to the technique bit of code. Immediately after, the pixel shader is called. Most important information previously calculated, is sent with it. Then the pixel shader shoots test rays into the scene (the scene is still invisible to the user, if he'd be able to stop progress at this point), and when a ray hits an object, it reads through the sent data, locates the correct textures, positions, colors, and generates a rgb(a) color. This color is outputted. After all pixels** have been sampled, the completed frame is sent to the frame buffer, waiting to be sent to the screen.

This modification calculates the vertex position, and when it exceeds a certain limit, all further vertex calcutions are skipped, and alpha is set to 0.0, making the vertex invisible.

*Every vertex shader (in the graphics card chip) can process one vertex at a time
**Every pixel shader (in the graphics card chip) can process one pixel at a time
***The new DX10 Unified Shaders can process both pixels and vertices. Removing the waiting between the vertex process and the pixel process.
 
Hi is this possible to make this work for trees only?
I mean, if I can control minimal fog distance, can I make this mod turn off all trees when they are not visible?
Or, can I copy tree shader, use it for part of my tree, so it will turn off some polygons when object will be far from camera?
It could work as LOD...
Can you explain ow I can use this (i have little knowledge about shaders, but some people can help me) - what I need to put into shader to make it work?

Great job.
Gutek
 
Gutek, I saw lods in the Warband townhouse brfs. Support may have also been added for vegetation.
 
gutekfiutek said:
Hi is this possible to make this work for trees only?
I mean, if I can control minimal fog distance, can I make this mod turn off all trees when they are not visible?
Or, can I copy tree shader, use it for part of my tree, so it will turn off some polygons when object will be far from camera?
It could work as LOD...
Can you explain how I can use this (i have little knowledge about shaders, but some people can help me) - what I need to put into shader to make it work?

Great job.
Gutek

Almost everything can be disabled if you'd like. Making parts o objects is also doable, but if you don't mind, I first want to get rid of some bugs in this simpler LOD mod, and then get to the harder part.
 
So this simulates something like "view distance" as it appears in other games? Through shaders?
 
I'm guessing it more than simulates it. Graphics cards tend to only load stuff that can be seen (in my experience anyway), so I'm guessing that all the stuff hidden by the shader won't be loaded into the card until it can be seen.
 
Yeah, that's what I meant. MaB could use some better unseen object elimination. IIRC you still get a fps hit if you look at a hill behind which there are many agents.
 
I'm guessing it more than simulates it. Graphics cards tend to only load stuff that can be seen (in my experience anyway), so I'm guessing that all the stuff hidden by the shader won't be loaded into the card until it can be seen.

Indeed, more than simulating. Normally every pixel/vertex gets the full computation. Now: a simple vertex position is calculated, compared to cameras position, and if too much, skips all further computation. Everything done before this point is sent to the pixel shader to be sampled, and if the pixel shader encounters a received color of 0, the computation of the pixel is also skipped.

That means, in practice, when the allowed distance is set to 0.000001, framerate will be the same when viewing a full city as viewing the sky.
 
This is for experience users, isn't it ? I tried to play with the first values of the file but the game crashed when I activated the fading option (my settings were 200 - 5 - 205).

Without the fade I had strange artifacts on the ground. Like holes or pools reflecting the sky (it was probably holes through which the skybox underneath could be seen). (I use a nvidia). Besides the files look really small compared to the originals, I don't know if this is normal (since the game crashed and all).
 
I don't really much know about the technical side of this but
How much does this actually improve frame rate?

My current pc can run DX9 but I never do because it's MURDER
I get crappy frame rate even when using DX7 so thats why my battle-sizer is always around 50

Would using this mod in DX9 give better performance than DX7 without this mod?
(I'm guessing not...)
 
What do i do to uninstal? I forgot to backup the original files, and ive tried reinstalling, but it still wont go away :S
could someone maybe be bothered to put the original backup files up on zshare or something :/?
 
Angloth said:
What do i do to uninstal? I forgot to backup the original files, and ive tried reinstalling, but it still wont go away :S
could someone maybe be bothered to put the original backup files up on zshare or something :/?

The only files that are changed are mb.fx and mb.fxo.

But they won't be removed when you uninstall M&B, because the uninstaller doesn't recognise them as the originals. The'll stay inside the folder. When installing M&B again in the same folder (not overwriting mb.fx(o)), the files will be used again.

Try removing the two files (or the whole leftover folder) first when installing.
 
Nemeo said:
This is for experience users, isn't it ? I tried to play with the first values of the file but the game crashed when I activated the fading option (my settings were 200 - 5 - 205).

Without the fade I had strange artifacts on the ground. Like holes or pools reflecting the sky (it was probably holes through which the skybox underneath could be seen). (I use a nvidia). Besides the files look really small compared to the originals, I don't know if this is normal (since the game crashed and all).

Do the holes still appear within the allowed distance when not using fading?

I've had them before when using fading*, but M&B doesn't properly define an alpha value for every object (try setting SkipLimitFace to the same value as SkipLimit for example). Started doing quite weird things, such as riverbeds dissapearing, fading borders between ground textures dissapearing and stuff like that.

*Calculates a normalized (simplify a value to range 0 - 1) alpha value from the distance between vertex and camera after "Start" and within "Length".

---

You could also try using BRFedit's "Reload Shaders" using your graphics card. See what error it returns.
 
I can't remember if fading was active when holes appeared, sorry. I just tried it for the technical find. Needs work but good find indeed :smile:
 
Sorry about reviving an ancient thread but I need some help getting this to work.

How should I alter my settings? What's the lowest they can possibly go.
 
Back
Top Bottom