Shaders.rfa - The final frontier....

Ask questions, discuss ideas, get answers
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Shaders.rfa - The final frontier....

Post by Apache Thunder »

Shaders. The mysterious rfa that no mod (that I have seen) has touched. This file is found only in the vanilla files thus far and to most modders is completely alien. Unlike most the other files there is no "tool" that edits them or converts them. Thus why they have been left untouched for so long.

Recently (last night), I finally got a succesfull "compile" of a vso file. I found that the Singleplayer demo (the oldest version of the game I can get my hands on since I still can't find a beta version of the game which for me would be the modder's holy grail. :P ) has uncompiled versions of most of the shaders present in the retail game.

Curously it also has shaders not present in the retail game. SkidMark shaders, A cloudshader and a "shimmerSprite" shader to name a few. It also has a few pixal shaders (PSO is the compiled versions of these)

Before this I used one of the SDKs of Direct X to compile these, but I was on the wrong track as the resulting VSO files did not resemble that of the game's official files at all.

Here is what a typical VSO file looks like:

Code: Select all

þÿþÿ FILEC:\New_Battlefield\Shaders\FlareShader.vs   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE	   þÿ LINE
   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE
   þÿ LINE
   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE       € Tþÿ LINE   þÿ LINE       € T€ Uþÿ LINE   þÿ LINE       € T€  þÿ LINE   þÿ LINE      	 €  € U€þÿ LINE   þÿ LINE      	 € U€  þÿ LINE   þÿ LINE   þÿ LINE        À  T	 T€þÿ LINE   þÿ LINE        À  ªþÿ LINE   þÿ LINE   þÿ LINE   þÿ LINE        à	 Tþÿ LINE   þÿ LINE    þÿ LINE!   þÿ LINE"   þÿ LINE#   þÿ LINE#        Ð äþÿ LINE$   ÿÿ  
A mess basically and clearly not something designed to be "edited".

Here is what a typical uncompiled shader looks like (vs file extension. note the lack of the "o" at the end)

Code: Select all

; (c) Copyright 2000 - Digital Illusions CE AB, All Rights Reserved
;
;
; @file SkinningShader2Bones.vs
;
; @author	Marco Hjerpe, Mats Dal
;

//-------------------- DEFINES --------------------------------------------------------

#define VERTEX_OFFSET0	v7
#define VERTEX_OFFSET1  v8
#define VERTEX_OFFSET2	v9
#define VERTEX_OFFSET3 	v10
                            
#define WEIGHTS						v1
#define VERTEX_NORMAL					v3
#define INDICES						v5
#define TEX_COORDS					v0

#define WORLD_VIEW_PROJ_MATRIX_1			c[0]
#define WORLD_VIEW_PROJ_MATRIX_2			c[1]
#define WORLD_VIEW_PROJ_MATRIX_3			c[2]
#define WORLD_VIEW_PROJ_MATRIX_4			c[3]

#define CONST						c[4]         
#define C_FOGDATA 					c[5]
#define LOCAL_SPACE_LIGHT_DIR				c[6]
#define C_LIGHT_COLOR					c[7]
#define C_SHADOW_COLOR					c[8]

#define BONE_START_1					9
#define BONE_START_2					10
#define BONE_START_3					11
        
vs.1.1

mul r3, INDICES.zyxw,CONST.xxxx

                                   
mov a0.x, r3.x                                                  
// Transform offset 0 by bone0.
dp4 r1.x, VERTEX_OFFSET0, c[a0.x+BONE_START_1]              
dp4 r1.y, VERTEX_OFFSET0, c[a0.x+BONE_START_2]              
dp4 r1.z, VERTEX_OFFSET0, c[a0.x+BONE_START_3]                  
m3x3 r5.xyz, VERTEX_NORMAL, c[a0.x+BONE_START_1]
// Weigh vertex.
mul r2.xyz, r1.xyz, WEIGHTS.x
mul r4.xyz, r5.xyz, WEIGHTS.x
                          
mov a0.x, r3.y
// Transform offset 1 by bone1.
dp4 r1.x, VERTEX_OFFSET0, c[a0.x+BONE_START_1]              
dp4 r1.y, VERTEX_OFFSET0, c[a0.x+BONE_START_2]              
dp4 r1.z, VERTEX_OFFSET0, c[a0.x+BONE_START_3]  
m3x3 r5.xyz, VERTEX_NORMAL, c[a0.x+BONE_START_1]                      
// Weigh vertex.
mad r2.xyz, r1.xyz, WEIGHTS.y, r2.xyz
mad r4.xyz, r5.xyz, WEIGHTS.y, r4.xyz

mov r2.w, CONST.y 
dp4 oPos.x, r2, WORLD_VIEW_PROJ_MATRIX_1
dp4 oPos.y, r2, WORLD_VIEW_PROJ_MATRIX_2 
dp4 oPos.z, r2, WORLD_VIEW_PROJ_MATRIX_3 
dp4 oPos.w, r2, WORLD_VIEW_PROJ_MATRIX_4

;dp4 oPos.x, VERTEX_OFFSET0, WORLD_VIEW_PROJ_MATRIX_1
;dp4 oPos.y, VERTEX_OFFSET0, WORLD_VIEW_PROJ_MATRIX_2 
;dp4 oPos.z, VERTEX_OFFSET0, WORLD_VIEW_PROJ_MATRIX_3 
;dp4 oPos.w, VERTEX_OFFSET0, WORLD_VIEW_PROJ_MATRIX_4

// Compute fog.
dp4 r1.x, r2, WORLD_VIEW_PROJ_MATRIX_4
mad oFog.x, C_FOGDATA.y, r1.x, C_FOGDATA.x	// ((-1/Range)*d)+End/Range = (End-d)/Range

// Animate texture coordinates. Tracks on tanks etc.
mad oT0, TEX_COORDS, CONST.y, CONST.zwww	// TEX_COORDS + [Offset,0,0,0]

// Lighting.
// normalize normals
mov r4.x, r4.x
mov r4.z, r4.z
dp3 r4.w, r4, r4;
rsq r4.w, r4.w
mul r4, r4, r4.w;

dp3 r1.x, r4.xyz, -LOCAL_SPACE_LIGHT_DIR.xyz
max r3.x, r1.x, CONST.w

// Compute color.
mov r2, C_SHADOW_COLOR
mad oD0, C_LIGHT_COLOR, r3.x, r2 	// oD0.w implicitly set to C_SHADOW_COLOR.w = 1
Now that is recognizable code and can be changed. For awhile I was using VSA.exe which is a compiler for vertex shaders that comes with most versions of the DirectX SDK. However they did not come out looking like the VSO files as shown above. Unsurpriingly the game rejects them.

So for awhile I had shader mods on the backburner. Then I dove into the demo which I found the uncompiled shaders. That wasn't the good part though. There was file at the root of the game folder called "nvasm.exe".

I ignored it for the longest time untill last night. I opened up command line and ran the program to see what it is. It appeared it was designed to use a input file and outputs something as vaguely explained by it's help text that it displayed since I didn't give it a input file.

So I dropped in a VS file and gave the program that. To my surprise it outputted a VSO file AND it had the same data structure as the official game VSO files. BINGO!

I found the app I need to compile them. So now I can finally get on the interesting part.

Now my theory here is that new shaders can't be made since the game is probably hardcoded to only load a certain list of shaders as the game is only programmed to use said shaders. However there is one shader that can be added because the retail game doesn't have it yet the debugger complains about not finding this shader. But this error only appears in the debugger log and the retail game doesn't say a peep about it.

The "SpritePointSprite.vso" file is what the debugger expects to find and yet it is mysteriously absent from from both the retail game and the demo (in compiled form). Now the demo did have an uncompiled vesrion of the shader but with a xvs extension. Here is what it looks like:

Code: Select all

; (c) Copyright 2000 - Digital Illusions CE AB, All Rights Reserved
;
;
; @file SpritePointSprite.vsh
;
; @author	Marco Hjerpe
;

//-------------------- DEFINES --------------------------------------------------------

#define VERTEX_POSITION			v0

#define DIFFUSE					v4
								
#define SPRITE_WH				v12

#define SPRITE_SIN_COS			v13

#define TEX_COORDS				v14

#define VIEW_MATRIX_1				c[0]
#define VIEW_MATRIX_2				c[1]
#define VIEW_MATRIX_3				c[2]
#define VIEW_MATRIX_4				c[3]

#define PROJ_MATRIX_1				c[4]
#define PROJ_MATRIX_2				c[5]
#define PROJ_MATRIX_3				c[6]
#define PROJ_MATRIX_4				c[7]
										
#define CONST						c[8] 
#define C_CAMPOS					c[9]								

xvs.1.1

dp4 oPos.x, VERTEX_POSITION, VIEW_MATRIX_1
dp4 oPos.y, VERTEX_POSITION, VIEW_MATRIX_2
dp4 oPos.z, VERTEX_POSITION, VIEW_MATRIX_3
dp4 oPos.w, VERTEX_POSITION, VIEW_MATRIX_4

//--- Get delta position (vertex position (world coord)) - (camera pos (world coord))

;add r6, VERTEX_POSITION, -C_CAMPOS

//--- Transform by world-view transform. (in this case only View matrix with out transformation) and transposed
//----------- OPTIMIZED STEP 1 ------------------------------------------------

;dp3 oPos.x, r6, VIEW_MATRIX_1 //X component of all angles don't need the position part (W) here because it is 0,0,0,1 therefor the dp3
;dp3 oPos.y, r6, VIEW_MATRIX_2 //Y component of all angles
;dp3 oPos.z, r6, VIEW_MATRIX_3 //Z component of all angles
;mov oPos.w, CONST.y			  //set 1 to w

// Output color
mov oD0, DIFFUSE

// Output width as point size.
mov oPts.x, SPRITE_WH.x
Only difference in the file from that of a VS is that it has "xvs.1.1" as the starting code and not "vs.1.1" like the other shaders.

I have compiled this shader and tried it in the retail and the debugger still pukes it up with the same error in the logs. I had the debugger stay quite on it by copying the sprite shader and renaming it to SpritePointSprite. but this didn't seem to work ingame to the effect I was expecting.

First off my theory here is that SpritePointSprite is used in the weather system. The weather codes don't work as we know, but I can bet that a missing shader might be why. The debugger does report loading the texture that is set up to be loaded by the weather code so the code works. But nothing is shown ingame.

There is a couple of key commands that leads me to believe that the SpritePointSprite shader is what the weather system needs:

Code: Select all

wPart.pointSpriteMinSize
wPart.pointSpriteMaxSize
"PointSprite" Key word there. It matches that of the SpritePointSprite file name. So I believe this is the shader needed for the weather code to work.

I have recompiled different shader as well the "newbf2_SkinningShader2Bones.vs" shader which is the only uncompiled shader found in in the retail game. I then took off the "newBF2_" from the file name so this replaces the compiled shader "SkinningShader2Bones.vso". I got a noticable effect ingame. The game didn't reject the shader and plus it had an effect to how animated meshes appeared ingame. The soldier mesh lost some detail and had "holes" in the hands and some other places. It looked kind of odd. This is not the same as a "broken" shader. When I broke the shader animated meshes would appear all blue or some other solid color and looked very bad. So it does seem a compiled shader does define how some elements in the game behave.

So if I can figure out why the SpritePointSprite shader code is getting rejected I could end up reviving the weather system!

I'll keep you updated if I find anything out. First I will look for a newer version of NVASM. Perhaps using one dated to the retail game might give better results. I will also play around with the code of the shader to see if I can get the game to accept it.
ImageImageImage
I have cameras in your head!
freddy
Posts: 1267
Joined: Sun Oct 18, 2009 4:58 pm

Post by freddy »

interesting, great find!
User avatar
fo0k
Posts: 1433
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

Re: Shaders.rfa - The final frontier....

Post by fo0k »

Very interesting!

Will be watching this space.. There must be a beta out there.
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Shaders.rfa - The final frontier....

Post by Apache Thunder »

While searching for the beta of BF1942, I found this from a few wiki entries I came across:

http://www.youtube.com/watch?v=WI4In959KjE

Slightly better quality alternate video:

http://www.youtube.com/watch?v=ZVinsxZ68jA

This game is the only other game that uses the Refractor 2 game engine that BF1942 uses. Now because of this it may be coded in a similer manner and it's worth a look. I believe this is also OLDER then BF1942 in that it was the first to use the engine. It predates BF1942 by a couple months. March of 2002 it was released. BF1942 was released in September of the same year. (it even predates the release of the the singleplayer demo which is the oldest copy of the game that can still be found)

Of particular interest is that this game has skidmarks. Something that might still be present in BF1942 but I haven't gotten the code to work without CTDs yet. This game could be a excellent comparision as it might have the skidMark code in working form. If it has weather code in it, that may be worth a look too. This game could prove to be just as good as the BF1942 beta coding wise. I will try and find this game and crack it open and see how it runs. :D

Perhaps there is also shadows on static objects and not just the terrain. But I haven't seen a video that yet has a car going over a object of some kind where this can be seen. Also note that dynamic shadows look better in this game.

Also this may explain the game.setBackgroudMusic code. THis code has little practicle use in BF1942, but this code could be used heavily in the racing game. :P

UPDATE: I got my hands on Rallisport Challenge. This game uses a archive format that predates RFAs. "RFF" they are called "Refractor2 FinkelArchive 1.0"

Freaky. Also they are encrypted (so apparently they didn't want any one to mod this game lolz)

But fortunately I found a tool that can extract it.

I extracted the "cars.rff" file and found SSC files and CON files! This game is has more in common with BF1942 then I could ever think!

Here is sample code I grabbed from one of the con files:

Code: Select all

rem
rem *** Beetle ***
rem
ObjectTemplate.create RallyCar Beetle
ObjectTemplate.saveInSeparateFile 1

rem
rem *** Physics parameters ***
rem
run Cars/Beetle/PhysicsCar

rem
rem *** Wheels ***
rem
ObjectTemplate.addTemplate BeetleWheelBundleFrontLeft
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/0
ObjectTemplate.addTemplate BeetleWheelBundleFrontRight
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/0
ObjectTemplate.addTemplate BeetleWheelBundleRearRight
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/0
ObjectTemplate.addTemplate BeetleWheelBundleRearLeft
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/0

rem
rem *** Car parts ***
rem
ObjectTemplate.addTemplate BeetleBody
ObjectTemplate.setPosition 0.000000/0.000000/0.000000
ObjectTemplate.setRotation 0/0/0
ObjectTemplate.addTemplate BeetleInterior
ObjectTemplate.setPosition 0.000000/0.000000/0.000000
ObjectTemplate.setRotation 0/0/0

rem
rem *** Driver/Co-Driver ***
rem
ObjectTemplate.addTemplate BeetleDriver
ObjectTemplate.setPosition -0.33/-0.056/0.047
ObjectTemplate.setRotation 0/0/0
ObjectTemplate.addTemplate BeetleCoDriver
ObjectTemplate.setPosition 0.34/-0.084/0.052
ObjectTemplate.setRotation 0/0/0

rem
rem *** Other parts ***
rem
ObjectTemplate.addTemplate BeetleCarCamera
ObjectTemplate.setPosition 0/1/0.25
ObjectTemplate.setRotation 0/0/0
ObjectTemplate.addTemplate CarEntry
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/0
ObjectTemplate.addTemplate BeetleCarSound
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/0

rem
rem *** Exhaust burst attachment loadup ***
rem
run Cars/Beetle/Burst.con

rem
rem *** Lensflare attachment loadup ***
rem
run Cars/Beetle/Lensflares.con

rem
rem *** Particle attachment loadup ***
rem
run object/PFX_Template.con

rem
rem *** Sound ***
rem 
var v_inMenu
game.stateMenu -> v_inMenu
if v_inMenu = 0
	run Cars/Beetle/SoundPlayer
endif

Organized a bit differently and a whole bunch of commands that don't exist in BF1942. But it is in a language I can understand and more digging and I can bet I can dig up the skidMark code and weather code! :D


EDIT:



JACKPOT:

Code: Select all

rem
Weather.initWeather
WPart.type 1
WPart.radius 30
wPart.partSize 0.6
WPart.speed 1/-20/2
WPart.random 3
WPart.numParticles 2000
WPart.pointSpriteMinSize 1
WPart.pointSpriteMaxSize 63
wPart.color 0.15
WPart.fadeZ 30
wPart.fadeInValue 10
wPart.acceleration 4
wPart.displacement 0/2/20
wPart.scale 0.7/0.5/0.7
WPart.setTexture 0 rain_lgt99
Now I finally have something to compare with.

EDIT:

Found the skidmark system. Not anywhere near how I was supposed to be doing it:

Code: Select all

rem
rem *** Skidmarks, default setup ***
rem

skidMark.setMaterialTrigLevels 0 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 1 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 2 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 3 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 4 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 5 1 1 0.1 0.1
skidMark.setMaterialTrigLevels 6 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 7 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 8 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 9 0.0 0.0 0.0 0.0
skidMark.setMaterialTrigLevels 10 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 11 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 12 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 13 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 14 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 15 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 16 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 17 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 18 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 19 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 20 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 21 0.01 0.01 0.1 0.1
skidMark.setMaterialTrigLevels 22 0.01 0.01 0.1 0.1

rem Grass 00
skidMark.setMaterialSkidMarkExtraWidth 0 0.05
skidMark.setIntensityClamp 0 0.5
skidmark.setColor 0 0/0/0

rem Asphalt 01
skidMark.setMaterialSkidMarkExtraWidth 1 0
skidMark.setIntensityClamp 1 1
skidmark.setColor 1 0/0/0

rem Gravel 02
skidMark.setMaterialSkidMarkExtraWidth 2 0.05
skidMark.setIntensityClamp 2 0.8
skidmark.setColor 2 0.1/0.05/0

rem waterAsphalt 03
skidMark.setMaterialSkidMarkExtraWidth 3 0.01
skidMark.setIntensityClamp 3 1
skidmark.setColor 3 0/0/0

rem Mud 04
skidMark.setMaterialSkidMarkExtraWidth 4 0.04
skidMark.setIntensityClamp 4 0.5
skidmark.setColor 4 0/0/0

rem Sand 05
skidMark.setMaterialSkidMarkExtraWidth 5 0.05
skidMark.setIntensityClamp 5 0.2
skidmark.setColor 5 0.2/0.05/0


rem Wood 06
skidMark.setMaterialSkidMarkExtraWidth 6 0
skidMark.setIntensityClamp 6 0
skidmark.setColor 6 0/0/0


rem Snow 07
skidMark.setMaterialSkidMarkExtraWidth 7 0.06
skidMark.setIntensityClamp 7 0.3
skidmark.setColor 7 0/0/0.05

rem SnowDeep 09
skidMark.setMaterialSkidMarkExtraWidth 9 0.07
skidMark.setIntensityClamp 9 0.3
skidmark.setColor 9 0/0/0.05

rem GravelDeep 12
skidMark.setMaterialSkidMarkExtraWidth 12 0.04
skidMark.setIntensityClamp 12 1
skidmark.setColor 12 0.1/0.05/0

rem Cobbles (Railroad) 13
skidMark.setMaterialSkidMarkExtraWidth 0 0
skidMark.setIntensityClamp 13 0
skidmark.setColor 13 0/0/0

rem GravelGrass 16
skidMark.setMaterialSkidMarkExtraWidth 16 0.05
skidMark.setIntensityClamp 16 0.5
skidmark.setColor 16 0/0/0

rem MudGrass 17
skidMark.setMaterialSkidMarkExtraWidth 17 0.05
skidMark.setIntensityClamp 17 0.5
skidmark.setColor 17 0/0/0

rem SandDeep 19
skidMark.setMaterialSkidMarkExtraWidth 19 0.07
skidMark.setIntensityClamp 19 0.2
skidmark.setColor 19 0.2/0.05/0

rem IceAsphalt 20
skidMark.setMaterialSkidMarkExtraWidth 20 0.02
skidMark.setIntensityClamp 20 0.3
skidmark.setColor 20 0/0/0.1

rem SandDark 21
skidMark.setMaterialSkidMarkExtraWidth 21 0.05
skidMark.setIntensityClamp 21 0.2
skidmark.setColor 21  0/0/0

rem SandDarkDeep 22
skidMark.setMaterialSkidMarkExtraWidth 22 0.08
skidMark.setIntensityClamp 22 1
skidmark.setColor 22 0.05/0.05/0
EDIT: Sadly the skidMark code is beyond repair. There is much listed above that doesn't exist in BF1942 anymore and there may also be extra code needed to "activate" the skidmarks but they were removed.

For example I found "game.drawSkidMarks" in one of the con files for the racing game. But this command exists nowhere in BF1942. :(

And then there's the lensflares. (not sure if any of the videos show it). The lensflares look great. But I have yet to get them to work in BF1942. I don't know what EA did to screw them up. I wonder why they were disabled in the first place.


Also after fiddlling around with this game I will never see BF1942 in the same light. It's hard to believe BF1942 started out as a racing sim. :P Yep. That's the first game the Refractor2 game engine was used for. :P

EA restructured the code and removed A LOT of the features the racing game had. Like the higher quality dynamic shadows. What appears to be more detailed lightmapshadowbits. (when the car went under a bridge or near a treeshadow, the shape of the shadow could be seen on the car. Semi self shadowing!)

This game has lower detail meshes and BF1942 certainly kicks it's ass in the poly count. But its the effects like lensflares, working weather system and better shadows that make the racing game better. Why the hell EA had to remove this stuff? I can't imagine how different it would be if the game was left structured how the racing game was. In the racing game the levels also are not structured the same. There is no terrain raw file. Instead there is "qm" files called track.

Notice the mention of "track" in the lightmap con files for BF1942? "raytracer.addIgnoreObject track" Well "track" was the former level type so I guess that element got left behind.

I'll continue looking at the code for the racing game but I don't see much hope in the weather system or the skidmark system of ever working. Perhaps might coax the lensflares to work but that's a long shot. The racing game also has working sky clouds. :P
ImageImageImage
I have cameras in your head!
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Shaders.rfa - The final frontier....

Post by Senshi »

How about we port the whole of BF42 over to Rallisport Challenge, so we can use all the cool effects? ;)
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Shaders.rfa - The final frontier....

Post by Apache Thunder »

lol I thought about that. But quickly determined to be impossible. Rallisport Challange lacks the object templates for BF42 to work in Rallisport, so no go on that. :(

For example, Rallisport SM files don't even have collision meshes. They use separate "col" files which have a bunch a vectors to define a basic size (and maybe shape) of the collision "area" for an object. Since the game only has cars and not tanks, soldiers, and projectiles running amok it doesn't have to use a mesh for collision. :P

The game also doesn't have an EffectBundle class (that I have seen yet). There is emitters and SpriteParticles I have spotted. Also, the SpriteParticles have a whole bunch of extra commands not found in BF1942. It looks like the effect system was more condensed in the racing game.
ImageImageImage
I have cameras in your head!
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Shaders.rfa - The final frontier....

Post by Apache Thunder »

Alright, so far not getting anywhere with the shaders. :(

The shaders for dynamic shadows must have been hardcoded into the game engine a few versions ago. In the demos and old versions of the game there used to be a shader called "ShadowGen.vso". This shadwer was responsible for all the dynamic shadows in the game. Unlike the current version of the game, there was no shadow meshes in the old version of the game, thus the lod was used. Now all normal meshes have shadow meshes and only the animated Meshes still generate shadows from the lod. :P

Perhaps someone with a bit of hex editing skills can coax the game into reviving the weather system, skidmark system and the lensflares. I suspect the Lensflares would be easist to revive as 99% of the code for them is still in the game. I think the Lensflares just need to be "activated" as there is more then enough code left over for them to work as is. The textures that all the lensflare objects in the vanilla game exist in Rallysport racing game. ;)

Also note that the racing game has the cloud shaders in working form with texture files for them and everything. Maybe even the cloud system could be revived too with a bit of hex editing/dll hooking. :P

I'll post up the uncompiled shaders + the app to compile them with. I will also post up the unpacked files from the racing game.

EDIT:

Compiled/Uncompiled shaders from the SP demo, the v1.0 retail game, and the Rallisport racing game are ready for download:

New_Battlefield.rar

Included is the NVASM app which is the program used to compile the shaders. Extract the RAR file so that there is a New_Battlefield directory in drive C:\. That is the path as indicated in some of the compiled shaders in the retail game. :P

Perhaps someone who knows how to edit/code vertex shaders might have more luck. Vertex shaders is just not my language. :P

EDIT:

RalliSport Racing game unpacked files:

Ralli_Dev.rar


These are the unpacked files from the racing game. Since you can't run the game from these files and such it should be perfectly fine to post the link to them here. The files are for research purposes. ;)
ImageImageImage
I have cameras in your head!
Poow
Posts: 271
Joined: Sun Nov 01, 2009 8:00 pm
Location: Germany
Contact:

Re: Shaders.rfa - The final frontier....

Post by Poow »

Cool Video from BF2 PR
I guess that's not possible for BF42?


It looks fucking great. :D
You’re entering a world of pain!
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Shaders.rfa - The final frontier....

Post by Apache Thunder »

From what I read the mod does a few things that even the normal BF2 exe couldn't do. They actually have a modified exe or a special loader exe that makes the game load custom shaders. (much like what I want to do in fact). The sky appears to be on a rotational bundle or the sun at least. No way that could be done in BF42 as a new shader would be needed to make it work and that even if somehow the sky could be rotated the dynamic shadows would not change. In that video, not only does the sun position in the sky change but the dynamic shadows change with it. ;)
ImageImageImage
I have cameras in your head!
User avatar
Apache Thunder
Posts: 1210
Joined: Mon Oct 19, 2009 2:48 am
Location: Levelland Texas, USA
Contact:

Re: Shaders.rfa - The final frontier....

Post by Apache Thunder »

lolz. Check this out while going through the game lexicon for vanilla BF42:

"MAP NOT FOUND, DO YOU WANT TO DOWNLOAD IT?"

Another message found near it:

"DO YOU WANT TO DOWNLOAD?"

Apparently EA wanted to give the game the ability to download maps the client doesn't have. Too bad they never implemented it. :P
ImageImageImage
I have cameras in your head!
Post Reply