Improved shadows mod (tweaked shader)

aruametelloaruametello Join Date: 2012-11-08 Member: 168371Members
edited September 2013 in Modding
important edit:
this mod is fully deprecated, since the reinforced update ns2 already uses a improved shadow shader. (with similar results and better performance than this mod)

===============

This thread is more about questions/sugestions to anyone than announcing a actual mod, but the post also include the download to the mod described.

Short version: some slight modifications to the shadow rendering, to use a more pronounced PCF filter and some noise in the penumbra to try to mimick smooter shadows, this mod is nothing related to actual complex optimization and/or extra code, almost everything "added" was already there, but aparently disabled for performance reasons.

WARNING: this mod cost GPU time, it is made with "high end" gpu setups in mind. (like sli/crossfire or high end video cards), in my tests i had about 20% extra GPU load.

Comparasion screenshots
Comp2_zps080098a7.png
comp1_zps83528042.png
* i didnt figured out how to post the photobucket fullsize screenshots but you probably already noticed some improvement, the extra quality is more noticeable when comparing in full resolution)

a few other random screenshots (without comparasions because you cant ask for random people playing to pose for 2 similar pictures)
arma2_2013_04_09_22_52_09_369_zpsdab1fb09.jpg
arma2_2013_04_08_22_13_15_173_zps0beb210d.jpg
arma2_2013_04_10_01_08_26_478_zps14944c32.jpg

Mod download link (single modified file): http://www.4shared.com/rar/Ub2vFeQt/RenderDeferred.html

Instalation instructions:
* make a backup copy of the file (NS2DIR)\core\renderer\RenderDeferred.fx
* overwrite the same file with the one given in the download link above. (inside the rar file)
* you need to have the option "shadows" turned on in the graphics menu. (duh)


Fact: use this at your own risk.
its worth mentioning that since this modification works even inside "non modded" servers and the same file can hold modifications that can exploit the game, you may end up being confused with some low life, hacking things like lighting (make everything bright to see in the dark) or even painting every surface with a single color, what would be similar to what some hacks do.



The questions:

1) the files outside "(NS2DIR)\NS2" arent "officially" modable? (likely considering its mostly engine inner workings sensitive stuff)
(i can be wrong in this one, but in the documentation aparrently mods are only for the "(NS2DIR)\NS2" folder and subfolders)

2) maybe splitting the RenderDeferred.fx file into several others (using #includes) could help modders to modify only smaller portions of the shaders?
(i only modified the "GetShadow" function for example)

3) This file (core\renderer\RenderDeferred.fx) is not checked for consistency? (i think it should)

4) Maybe a "oficial" version for "higher quality" shadows in the graphical settings? (like off, normal, high instead of just off,on)
(with also a bigger shadow depth buffer in the high setting plz)

Comments

  • FunkyFungusFunkyFungus Join Date: 2003-09-09 Member: 20691Members
    edited April 2013
    looks really smooth!! nice work :)

    can some dev coment on this ? :-B
  • RemedyRemedy Join Date: 2011-06-16 Member: 104735Members, NS2 Playtester, NS2 Map Tester
    This is great aurometello :)
  • lwflwf Join Date: 2006-11-03 Member: 58311Members, Constellation
    Brilliant. I don't have much bad to say about NS2, but the shadows are frankly not good, at all. I already have them off for performance reasons but even if I could afford it they don't make good eye candy, but this is great for those that can.
  • aeroripperaeroripper Join Date: 2005-02-25 Member: 42471NS1 Playtester, Forum Moderators, Constellation
    Should be official, even though I run everything in lowest detail anyways :D
  • WhiteDevilWhiteDevil Join Date: 2012-09-16 Member: 159559Members, Reinforced - Shadow
    Looks incredible, awesome job!
  • Fudo_StyleFudo_Style Join Date: 2002-12-31 Member: 11659Members
    Wow, the difference is like night and day. Uber crappy low res junk to super nice PCF shadows. There's gotta be some sort of compromise - we don't need variable penumbras. What about variance shadows?

    Variance shadow maps. According to this paper variance is between 1.5 and 10 times faster than PCF.
  • JibrailJibrail Join Date: 2009-04-16 Member: 67200Members
    what a difference, GJ on this!
  • KurrineKurrine Join Date: 2010-07-03 Member: 72235Members
    edited April 2013
    I would like to see a dev comment on this as well, it looks great, this really should be the next shadow quality setting up. I'd have no complaints of the shadows like this.

    Is there much of a frame hit to this like I'd imagine there would be?
  • IronHorseIronHorse Developer, QA Manager, Technical Support & contributor Join Date: 2010-05-08 Member: 71669Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Subnautica Playtester, Subnautica PT Lead, Pistachionauts
    edited April 2013
    Oh man..
    You should rework infestation bump mapping too, since this change really impacts those looks.
    GREAT work btw!

    Any benchmark comparisons?
  • YMICrazyYMICrazy Join Date: 2012-11-02 Member: 165986Members
    edited April 2013
    Pretty insane. GJ dude I always LOVE mods like these. Wish there was a way to force MSAA.

    Edit: Hm when I tried it this evening the shadows look extremely pixelated and blocky. Guess it doesn't work for me.

    With the mod:
    untitlhnh.jpg

    Normal unmodded shadows:
    untitllel.jpg

  • pnb84pnb84 The house on paper street Join Date: 2013-02-22 Member: 183262Members, Reinforced - Supporter
    Absolutely lovely. :D
  • MaxMax Technical Director, Unknown Worlds Entertainment Join Date: 2002-03-15 Member: 318Super Administrators, Retired Developer, NS1 Playtester, Forum Moderators, NS2 Developer, Constellation, Subnautica Developer, Pistachionauts, Future Perfect Developer
    edited April 2013
    Cool mod! I've been meaning to make some shadow improvements, but I haven't had the time.

    It is completely ok to mod files in the "core" directory. If fact you should create a workshop mod out of this (directly overwriting the install files is not recommended, since it will prevent you from playing on servers that enforce consistency on shader files and could cause the game to break when we release a patch. Say you have a mod "mymod" installed and the engine tries to load renderer/RenderDeferred.fx. It will look for that file in these locations:

    mymod/renderer/RenderDeferred.fx
    ns2/renderer/RenderDeferred.fx
    core/renderer/RenderDeferred.fx

    Which ever one it finds first it will use.

    The rendering system is actually very modable. The files renderer/Deferred.render_setup and renderer/Deferred.shader_template contain all kinds of flexibility. For example the bloom, ambient occlusion, refraction, infestation rendering and low quality particle optimization features are all implemented completely in these text files. The engine itself doesn't know anything about those features. Even the core deferred rendering system can be modified. I've done experiments with light pre-pass and other variations on deferred shading just by tweaking these files and seeing the results while the game is running (make sure you have -hotload on the command line).
  • GameOverGameOver Germany Join Date: 2003-10-15 Member: 21700Members, NS2 Map Tester, Reinforced - Shadow
    Wow, looks really good.
    It'd be great if you could implement your mod into workshop! :)
  • durdenns2durdenns2 Join Date: 2013-01-30 Member: 182634Members
    Can this be permanently implemented into the game?
  • aruametelloaruametello Join Date: 2012-11-08 Member: 168371Members
    Just for the comment, i went for a "brute force, unoptimized idea" for softer shadows, and tunned the quality values (think as a variable that bigger values increase the quality a little and decrease the performance a lot) but got to a point where my gpu setup can still run the game at mostly 60fps. (but then i always play at the 32 player server so performance wont be perfect anyway)

    i have a better plan based on this: http://http.developer.nvidia.com/GPUGems/gpugems_ch11.html that would use fragment coordinates (where the pixel will be rendered on the screen) to pick what samples to use (the "noise" offset of each sample)

    but right now i am busy with work, and dont have much idea how to get the "gl_fragcoord" equivalent in hlsl. (most of my knowledge is in opengl)


    Pretty insane. GJ dude I always LOVE mods like these. Wish there was a way to force MSAA.

    Edit: Hm when I tried it this evening the shadows look extremely pixelated and blocky. Guess it doesn't work for me.

    With the mod:
    untitlhnh.jpg

    Normal unmodded shadows:
    untitllel.jpg


    I am almost sure of what went wrong on your setup, and its not your fault in any way, basically there are a few separate pieces of code that "samples" the shadows and i basically just played with the code with "try and error" until finding the one my ns2 was using here, maybe the other (very similar) functions are used with different setups (like different brand of video card or video settings, etc).

    if i release a new (proper) version of this, it will be a steamworkshop mod (Thanks to max instructions) and most likely will be properly tested. (i can try to test on a few setups first)
  • GyroMeepoGyroMeepo Join Date: 2013-09-06 Member: 187906Members
    I don't know if there's a rule against bumping/necroing old threads here but in the recent build 255 update this mod broke. Its a shame because this mod made the shadows much better and more natural! If the creator is still around are you going to update the mod to work with 255 and maybe even improve the shadows further? It would be great if you did!
  • inveigleinveigle Join Date: 2004-01-07 Member: 25117Members, Constellation, NS2 Playtester, Reinforced - Shadow, WC 2013 - Supporter
    Great work, please put this on the Steam workshop.
Sign In or Register to comment.