• Announcements

    • Detrux

      Site Relaunched   10/13/2016

      Welcome back to BFEditor.org! We've upgraded the forum software, removed the spammers, and improved security. Apologies for the downtime! Det
Coronaextra

Corona's Shaders

43 posts in this topic

Just a little update: I have been working on making the code more portable so if someone else wants to compile it they have to download as few libraries as possible. Now I got it to the point where the only needed library is actually the directx9 sdk which is a must for the shader functionality to work. Also it has to be compiled with Visual studio 2015 because it uses some of the new fancy C++ 11/14 features. I still have to find out why the game always crashes when exiting instead of shutting down and freeing resources correctly.

Edited by Bad_santa12345

Share this post


Link to post
Share on other sites

Hey guys.

This all sounds amazing. Truly epic.

This might sound abit silly but what does the Event Viewer log at the time of the crash? Many times the Event Viewer reports has helped fix the online server crashes.

Hope to speak soon guys.

 

Share this post


Link to post
Share on other sites

Nice work guys! I might take a look at it this, if time allows.

By the way, is it just me or did nVidia break PCF texture filtering in BF2? IIRC DICE poorly hardcoded hardware SM detection, so modern NV hardware falls back to crappy ATI low quality stuff. We fixed this in FH2 by getting rid of the (now useless) optimizations altogether (SpecularLUT etc to get nicer specular), but PCF remains rather broken in my NV setups after updating drivers some years ago.

Passing variables to shaders is a very neat feature, this could allow some nice post processing effects without the hacks we did in FH2.

Edited by Remdul

Share this post


Link to post
Share on other sites

By the way Corona, you can store 'kind of' store a normal map in one channel. I found this out by accident in one of my own game projects where I stored a terrain normal map in two XY and reconstructing Z. Except that I bungled the shader code, and was actually passing and unitialized value (zero) as Y. Yet the normal map looked pretty acceptable. Essentially it's like a DUV map, where you reconstruct one component. For most terrain detail normal maps (= tangent space) you have relatively little bump/contrast (blue channel is mostly blank), so you can get often away with it. It may reveal itself more with specular reflection and envmaps though.

Edited by Remdul

Share this post


Link to post
Share on other sites

Yup, I tried a few different variants before I settled with what I'm suing now. Really, you can derive any component of the normal map with a heightmap but I preferred the cross multiply method because it derives the full normal map and uses only a few instructions. I actually got the idea from a material function in UE4/UDK called "NormalFromHeightmap".

The version of the shader I'm using now has specularity turned off completely because it can't be controlled at the moment. It just uses the normal bump.I guess this would be called a "diffuse lambert" shader. You can see an example of it in the video I posted last page.

Height2Normals_zpsa3xki7lb.png

I wanted to ask you a question though.. since you have obviously torn into the BF2 mesh files to make Meshview, I was wondering if you could confirm that staticmesh files do or do not contain vertex colors? I have been playing around with the staticmesh shader and I could not get it to output the vertex colors. Sometimes the EXE won't pass information like that to the shader if its not used for vanilla bf2.

Share this post


Link to post
Share on other sites

I mentioned DUV because doing multiple texture fetches from the same texture to build your normal gets expensive really quick. Especially with 6 layers of detail textures, I guess the only reason you don't hit the SM2 limits is because BF2 alpha-blends the detail layers (texture fetches spread over several drawcalls/pixel shader invokations).

Not sure about vertex colors actually. The BF2 mesh files (.staticmesh, .bundledmesh and .skinnedmesh are virtually identical internally) do store a table of vertex attribute information, with a field for the type (position/normal/UV/weight etc). This information includes the attribute usage type, which maps to a D3D constant. By adding an attribute for vertex colors it *may* work. But you'd have to seriously modify the exporter tools. If I have time I'll see if I can generate a blank VC channel in some staticmesh file and see if I can get access it in a BF2 shader (that's the critical part, does BF2 actually bind the attribute if it exists in the mesh file); a proof of concept.

There's however an easier alternative, and that's by storing the vertex colors in UV channels (you need two channels to get RGBA). The POE exporter at least exports always at least 4 UV channels, even if not all are used. Alternatively, you can even use an (uncompressed!) lookup texture (rainbow) and index into it via UV coordinates. 3dsmax does (or did) this internally, it's really stupid and confusing, but it works.

Edited by Remdul

Share this post


Link to post
Share on other sites

Here is a bare bones version of the source code https://github.com/BadSanta12345/RFX 

It doesn't have any actual features yet but at least I got it to GitHub so it should be faster to add them in. I do have the code for all the stuff presented in my YouTube videos and for the shader variable thing but I have to do some cleaning up before I am ready to add them to the GitHub project for everyone to see.

Share this post


Link to post
Share on other sites

Looking forward to the features, like fov fix for widescreen and scope effect like the one in alpha project!

Share this post


Link to post
Share on other sites
On 2017/02/19 at 0:00 AM, kano said:

Looking forward to the features, like fov fix for widescreen and scope effect like the one in alpha project!

Yeah, and not to even mention the customisation system, along with the dryfire system etc.

I also cannot wait to see whether it is possible to properly and robustly implement the terrain normals. That surely would make BF2 look a lot prettier!

Share this post


Link to post
Share on other sites

https://github.com/BadSanta12345/RFX/releases/tag/Test here are the build binaries for testing that the code even runs. You should copy both RFX.exe and RFX.dll to your BF2 install directory. Then if you run RFX.exe with shortcut parameters "+fullscreen 0" and "+szx 1920 +szy 1080" (adjust to your resolution). Then you should be able to toggle fullscreen with Alt+Enter.  Thats pretty much the only feature this version has.

Share this post


Link to post
Share on other sites

I get can't find stl_8_wrapper.dll,

RFX.exe and RFX.dll are in Battlefield 2 install directory.

any idea what im doing wrong?

Edited by kano

Share this post


Link to post
Share on other sites
22 minutes ago, kano said:

can't find stl_8_wrapper.dll,

RFX.exe and RFX.dll are in Battlefield 2 install directory.

Ah I forgot that one it should be on there now. You might still need some Microsoft Visual C++ runtimes. I will have to check which ones are actually required and upload a copy of those as well.

Share this post


Link to post
Share on other sites
8 hours ago, Bad_santa12345 said:

Ah I forgot that one it should be on there now. You might still need some Microsoft Visual C++ runtimes. I will have to check which ones are actually required and upload a copy of those as well.

get this now!

error.png

Share this post


Link to post
Share on other sites

had to add this to get it to work in shortcut target!  "C:\Program Files (x86)\Nations At War\RFX.exe" +menu 1 +fullscreen 0 +szx 1900+szy 1020 +modPath mods/NAW.

 

now i assume rfx.exe isn't launching bf2.exe it's replacing it hence the error, it can't connect to our asp 3.0.

only problem was this was with a offline account so it wasn't connecting to our asp!

 

Untitled.png

Edited by kano
had to add this to get it to work!

Share this post


Link to post
Share on other sites
Quote

now i assume rfx.exe isn't launching bf2.exe it's replacing it hence the error, it can't connect to our asp 3.0.

can your code in your RFX.exe be added to our exe? or would it be easier to add our master server info to your exe?

Edited by kano

Share this post


Link to post
Share on other sites
On 8.4.2017 at 0:50 AM, kano said:

can your code in your RFX.exe be added to our exe? or would it be easier to add our master server info to your exe?

Only thing modified in the RFX.exe compared to vBF2.exe is the import address table so that the first thing it does is load the RFX.dll. The IAT modification can be done to any .exe. I used CFF Explorer to do it.

Share this post


Link to post
Share on other sites
8 hours ago, Bad_santa12345 said:

Only thing modified in the RFX.exe compared to vBF2.exe is the import address table so that the first thing it does is load the RFX.dll. The IAT modification can be done to any .exe. I used CFF Explorer to do it.

yeah we did the exe, just need what ever is left to release.

have you had time to do any more work on this?

Share this post


Link to post
Share on other sites

Hey guys hope everyone is good. Just had a good read of the thread looks brilliant.

1. Corona your shader looks like a Plogue Bidule setup, very impressive. Also just seen the Jungle map thanks for the download.

2. Bad Santa I noticed that you posted about a possible mod regarding cascaded shadow maps? Well that would 100% fix the dynamic shadow bugs with nightvision/thermalvision active.

Good stuff going on here hope to speak soon.

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