PDA

View Full Version : working on fog and viewdistance


caliber1942
23rd June 2005, 20:57
took a look at the init.con files for the levels for bf2 and noticed this only:

GameLogic.MaximumLevelViewDistance (some number here)

there was no code for fog and for the "actual" view distance. has anyone messed with the fog (not with dx but with the fog address) or with viewdistance yet? is there no fog command like the GameLogic.MaximumLevelViewDistance command?

at any rate, was hoping to find the .con files similar to the bfv and bf1942 files but they are different with this engine.

any thoughts or comments on this would be appreciated. i will keep working at this, too-

best,
cal

goggles99
23rd June 2005, 22:07
took a look at the init.con files for the levels for bf2 and noticed this only:

GameLogic.MaximumLevelViewDistance (some number here)

there was no code for fog and for the "actual" view distance. has anyone messed with the fog (not with dx but with the fog address) or with viewdistance yet? is there no fog command like the GameLogic.MaximumLevelViewDistance command?

at any rate, was hoping to find the .con files similar to the bfv and bf1942 files but they are different with this engine.

any thoughts or comments on this would be appreciated. i will keep working at this, too-

best,
cal
Greetings,
You can approach this from many angles, but the easiest is to approach it just like in BF1942. Adjust the view distance slider in the video options and t-search for a higher and lower float value (after hitting save). The lowest point should be 0.0 and the highest should be 1.0.

This is only a multiplier for the fog (simple but effective point of attack).

If you want to find the actual fog attributes such as FogDensity, FogEnable, FogEnd, FogStart, FogColor ECT. they should all be in this same general location.

You could also hook the D3D SetRenderState and get their actual values, then search for the values in the games memory or trace back a little from the hooked call to see where they are being read from.

There are many other ways, but this should get you started.

Good Luck ;)

caliber1942
23rd June 2005, 22:29
wonder why the fogend and fogstart etc. aren't in the map files like before (or are they, just not finding them?)

thanks for the tips-
best,
cal

Sparten
23rd June 2005, 22:30
i would just like to add that there is 3 values that you can finde for fog/viewdistance.
Fog has 2 values one for fogstart and one for fogende and the are linked to the viewdistance so if you turn up viewdistance at the modifyer, you will also turn up the fog, and it looks alot better then removing the fog totaly.
(the 2 for fog is just 4 bytes appart)

caliber1942
23rd June 2005, 22:44
when you say turn up the viewdistance at the modifyer, do you mean with the slider in the options?


what do you mean that it looks better than removing the fog totally? not sure i got what you meant there.

thanks for the tips.

i can find the GameLogic.MaximumLevelViewDistance within the game rather easily but sounds like that doesn't do much, unless you want to make the viewdistance greater than that number.

so all three are linked to the slider in the options (fogend, fogbegin, viewdistance) and they increase as the slider goes to 1 and decrease as the slider goes to 0, is this the concensus? (also, all floats?)

thanks-
cal

_talon
23rd June 2005, 23:02
Greetings,
You can approach this from many angles, but the easiest is to approach it just like in BF1942. Adjust the view distance slider in the video options and t-search for a higher and lower float value (after hitting save). The lowest point should be 0.0 and the highest should be 1.0.

This is only a multiplier for the fog (simple but effective point of attack).

If you want to find the actual fog attributes such as FogDensity, FogEnable, FogEnd, FogStart, FogColor ECT. they should all be in this same general location.

You could also hook the D3D SetRenderState and get their actual values, then search for the values in the games memory or trace back a little from the hooked call to see where they are being read from.

There are many other ways, but this should get you started.

Good Luck ;)

dont bother


cant edit it anyhow.

if the full is anyhting like the demo


servers are pure lol

Sparten
23rd June 2005, 23:11
talon you should not awnser if you dont know what your talking about, nofog and viewdistance is some of the easiest hacks to get working.

@caliber1942, when you finde the DMA for viewdistance you can just change it to what ever value you would like, and that the modifyer i'm talking about. so if you set the value to 2 it will be x2 of max allowed settings.

xollox
23rd June 2005, 23:13
I know one way I changed fogged in bf1942 (besides the simple DMA defeat stuff) is a console hack. There was a console command that you could change the viewdistance to whatever you want, but it was locked out. I believe it took 3 NOPs and those forbidden console commands were no longer forbidden.

...Just something else to chew on.

Sparten
23rd June 2005, 23:15
I know one way I changed fogged in bf1942 (besides the simple DMA defeat stuff) is a console hack. There was a console command that you could change the viewdistance to whatever you want, but it was locked out. I believe it took 3 NOPs and those forbidden console commands were no longer forbidden.

...Just something else to chew on.

thats also possible in BF2 :D

Spontaneous
23rd June 2005, 23:30
xollox, actually it only took 1 address NOPed to unlock the console commands. I am sure its possible with bf2 as sparten said. Problem is finding a console command that will allow you to change the fog/viewdistance values. I could find such commands real easy with BF1942/BFVietnam in IDA Pro. Problem is, when I loaded the demo into IDA Pro, there were no such commands anymore. So I think EA/Dice learned their lesson having them commands built in and no longer think its possible to changes the values VIA the console.

p3n1
24th June 2005, 00:15
xollox, actually it only took 1 address NOPed to unlock the console commands. I am sure its possible with bf2 as sparten said. Problem is finding a console command that will allow you to change the fog/viewdistance values. I could find such commands real easy with BF1942/BFVietnam in IDA Pro. Problem is, when I loaded the demo into IDA Pro, there were no such commands anymore. So I think EA/Dice learned their lesson having them commands built in and no longer think its possible to changes the values VIA the console.

Looking at fog was one of my first approaches, when i debugged the demo exe. But if you'll look a tlitle closer at RendDX9.dll, then youll find some interesting functions:

.text:10025D1B push offset aLeafog ; "LeafOG"
.text:1002FFF9 push offset aFogcolor ; "FOGCOLOR"
.text:10030025 push offset aFogstartandend ; "FOGSTARTANDEND"
.text:10036489 push offset aFogcolor_0 ; "FogColor"
.text:100364FE push offset aFogrange ; "FogRange"
.text:10048373 call sub_1002FBF0 ; fog
.text:1004C6D2 mov dword ptr [esi+0Ch], offset aFogcolor_1 ; "fogColor"
.text:1004C8D2 mov dword ptr [esi+0Ch], offset aWaterfogstarte ; "waterFogStartEndAndBase"
.text:1004CBC2 mov dword ptr [esi+0Ch], offset aWaterfogcolor ; "waterFogColor"
.text:100A76A4 push offset aLeafog ; "LeafOG"
.text:100B3C45 push offset aFogrange_0 ; "fogRange"
.text:100B3C71 push offset aFogcolor_1 ; "fogColor"
.text:100DC87D push offset aFogrange_0 ; "fogRange"
.text:100DC8A9 push offset aFogcolor_1 ; "fogColor"
.text:100F90FF push offset aFogrange_0 ; "fogRange"
.text:100F913C push offset aFogcolor_1 ; "fogColor"
.text:1010A132 push offset aFogcolor_0 ; "FogColor"
.text:1010E3D8 push offset aFogrange_0 ; "fogRange"
.text:1010E3FE push offset aFogcolor_0 ; "FogColor"
.text:10115AC7 push offset aFogrange_0 ; "fogRange"
.text:10115AED push offset aFogcolor_1 ; "fogColor"
.text:1011DF4C push offset aFogrange_0 ; "fogRange"
.text:1011DF97 push offset aFogcolor_1 ; "fogColor"
.text:1013620F push offset aFogrange_0 ; "fogRange"
.text:1013623B push offset aFogcolor_1 ; "fogColor"
.text:101394BD push offset aFogrange_0 ; "fogRange"
.text:101394E9 push offset aFogcolor_1 ; "fogColor"
.text:1013B603 push offset aFogrange_0 ; "fogRange"
.text:1013B62F push offset aFogcolor_1 ; "fogColor"
.text:1016B14F push offset aFogrange_0 ; "fogRange"
.text:1016B17B push offset aFogcolor_1 ; "fogColor"
.rdata:10198B20 dd offset aD3ddeclusage_f ; "D3DDECLUSAGE_FOG"
.rdata:10199398 aD3ddeclusage_f db 'D3DDECLUSAGE_FOG',0 ; DATA XREF: .rdata:10198B20o
.rdata:10199DEC aLeafog db 'LeafOG',0 ; DATA XREF: .text:10025D1Bo
.rdata:1019A8B4 aFogstartandend db 'FOGSTARTANDEND',0 ; DATA XREF: sub_1002FBF0+435o
.rdata:1019A8C4 aFogcolor db 'FOGCOLOR',0 ; DATA XREF: sub_1002FBF0+409o
.rdata:1019B580 aFogrange db 'FogRange',0 ; DATA XREF: sub_100360F0+40Eo
.rdata:1019B58C aFogcolor_0 db 'FogColor',0 ; DATA XREF: sub_100360F0:loc_10036489o
.rdata:1019D8AC aFogcolor_1 db 'fogColor',0 ; DATA XREF: sub_1004C6C0+12o
.rdata:1019D944 aWaterfogstarte db 'waterFogStartEndAndBase',0 ; DATA XREF: sub_1004C8C0+12o
.rdata:1019D9E4 aWaterfogcolor db 'waterFogColor',0 ; DATA XREF: sub_1004CBB0+12o
.rdata:101B8094 aFogrange_0 db 'fogRange',0 ; DATA XREF: sub_100B37B0+495o
hope it helps in some kind.
regards

Sparten
24th June 2005, 00:47
xollox, actually it only took 1 address NOPed to unlock the console commands. I am sure its possible with bf2 as sparten said. Problem is finding a console command that will allow you to change the fog/viewdistance values. I could find such commands real easy with BF1942/BFVietnam in IDA Pro. Problem is, when I loaded the demo into IDA Pro, there were no such commands anymore. So I think EA/Dice learned their lesson having them commands built in and no longer think its possible to changes the values VIA the console.

you can search for the exact same string as in 42/BFV "unauthorized method" or something like that, and you will finde that they almost c/p the code from 42/BFV. PizzaPan posted some of the commands that can be used.

try this addy for the demo 0x00629D38 :D

Spontaneous
24th June 2005, 05:26
Sparten I havent even tried but I said it was most likely possible to unlock console :P Anyways pizzapan did not post any commands that have to do with fog/viewdistance

p3n1, I only loaded the bf2.exe into IDA Pro, not the dll yet.

Sparten
24th June 2005, 11:18
your right he didnt post the code for viewdistance/fog, but many of the other commands can sure give a huge advantage.

caliber1942
24th June 2005, 15:50
Looking at fog was one of my first approaches, when i debugged the demo exe. But if you'll look a tlitle closer at RendDX9.dll, then youll find some interesting functions:

.text:10025D1B push offset aLeafog ; "LeafOG"
.text:1002FFF9 push offset aFogcolor ; "FOGCOLOR"
.text:10030025 push offset aFogstartandend ; "FOGSTARTANDEND"
.text:10036489 push offset aFogcolor_0 ; "FogColor"
.text:100364FE push offset aFogrange ; "FogRange"
.text:10048373 call sub_1002FBF0 ; fog
.text:1004C6D2 mov dword ptr [esi+0Ch], offset aFogcolor_1 ; "fogColor"
.text:1004C8D2 mov dword ptr [esi+0Ch], offset aWaterfogstarte ; "waterFogStartEndAndBase"
.text:1004CBC2 mov dword ptr [esi+0Ch], offset aWaterfogcolor ; "waterFogColor"
.text:100A76A4 push offset aLeafog ; "LeafOG"
.text:100B3C45 push offset aFogrange_0 ; "fogRange"
.text:100B3C71 push offset aFogcolor_1 ; "fogColor"
.text:100DC87D push offset aFogrange_0 ; "fogRange"
.text:100DC8A9 push offset aFogcolor_1 ; "fogColor"
.text:100F90FF push offset aFogrange_0 ; "fogRange"
.text:100F913C push offset aFogcolor_1 ; "fogColor"
.text:1010A132 push offset aFogcolor_0 ; "FogColor"
.text:1010E3D8 push offset aFogrange_0 ; "fogRange"
.text:1010E3FE push offset aFogcolor_0 ; "FogColor"
.text:10115AC7 push offset aFogrange_0 ; "fogRange"
.text:10115AED push offset aFogcolor_1 ; "fogColor"
.text:1011DF4C push offset aFogrange_0 ; "fogRange"
.text:1011DF97 push offset aFogcolor_1 ; "fogColor"
.text:1013620F push offset aFogrange_0 ; "fogRange"
.text:1013623B push offset aFogcolor_1 ; "fogColor"
.text:101394BD push offset aFogrange_0 ; "fogRange"
.text:101394E9 push offset aFogcolor_1 ; "fogColor"
.text:1013B603 push offset aFogrange_0 ; "fogRange"
.text:1013B62F push offset aFogcolor_1 ; "fogColor"
.text:1016B14F push offset aFogrange_0 ; "fogRange"
.text:1016B17B push offset aFogcolor_1 ; "fogColor"
.rdata:10198B20 dd offset aD3ddeclusage_f ; "D3DDECLUSAGE_FOG"
.rdata:10199398 aD3ddeclusage_f db 'D3DDECLUSAGE_FOG',0 ; DATA XREF: .rdata:10198B20o
.rdata:10199DEC aLeafog db 'LeafOG',0 ; DATA XREF: .text:10025D1Bo
.rdata:1019A8B4 aFogstartandend db 'FOGSTARTANDEND',0 ; DATA XREF: sub_1002FBF0+435o
.rdata:1019A8C4 aFogcolor db 'FOGCOLOR',0 ; DATA XREF: sub_1002FBF0+409o
.rdata:1019B580 aFogrange db 'FogRange',0 ; DATA XREF: sub_100360F0+40Eo
.rdata:1019B58C aFogcolor_0 db 'FogColor',0 ; DATA XREF: sub_100360F0:loc_10036489o
.rdata:1019D8AC aFogcolor_1 db 'fogColor',0 ; DATA XREF: sub_1004C6C0+12o
.rdata:1019D944 aWaterfogstarte db 'waterFogStartEndAndBase',0 ; DATA XREF: sub_1004C8C0+12o
.rdata:1019D9E4 aWaterfogcolor db 'waterFogColor',0 ; DATA XREF: sub_1004CBB0+12o
.rdata:101B8094 aFogrange_0 db 'fogRange',0 ; DATA XREF: sub_100B37B0+495o
hope it helps in some kind.
regards

p3n1, is this the kind of code that ida pro spits out when it is done decompiling? i did the bf2.exe for the demo but not the retail and also i never decompiled the .dll. is this what it would look like decompiled? man this is very helpful. the bf2 code decompiled never looked this way or maybe i don't know how to use ida pro. seeing the code in this form is alot easier than just the raw addresses..

do you just load the code in and it ends up this way or do you have to do something special when loading in the .dll?

best,
cal

Spontaneous
24th June 2005, 21:48
Yea thats what it looks like when done. Pretty much when its done, you can find all the names such as aFogcolor in one of the windows and then click on it to bring you to the code part. IDA Pro is really nice. I just loaded the dll into IDA pro a couple min ago. Did find some console commands. Am going to try out later and tell ya what I find.