[SKYRIM] Modular Shader Library, updated to V5

share shaders here
  • Author
  • Message
Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

[SKYRIM] Modular Shader Library, updated to V5

This is just my, in the works, library of shaders and shader functions, with an easy approach to inject them into any .fx, .txt file ENBSeries have.

Download Link of shader files, updated 2015-01-26
http://www.mediafire.com/download/3i5fe ... rary_v5.7z

Nexus, updated 2015-03-29;
http://www.nexusmods.com/skyrim/mods/61955/?


Shader Library content
  • elepHelpers.fxh - Contains useful helper functions such as Time and Location value "splitters", Yxy and HSL color space conversions, multiple average luminance functions etc.
  • elepAdaptation.fxh - Contains Adaptation Min, Max range controls. Which have been applied to all relevant effects in this library.
  • elepBloomControl.fxh - Some simple ENB bloom controls, can be used for Vanilla game bloom as well or both with a bit of code tinkering
  • enbAGCC.fxh - Default APPLYGAMECOLORCORRECTION shader code
  • elepAGCC.fxh - Customizable APPLYGAMECOLORCORRECTION inspired by Prod80
  • enbPP1.fxh - Default ENBSeries Post-Process v1 shader code
  • enbPP2.fxh - Default ENBSeries Post-Process v2 shader code
  • enbPP3.fxh - Default ENBSeries Post-Process v3 shader code
  • enbPP4.fxh - Default ENBSeries Post-Process v4 shader code
  • elepNXS.fxh - NXS Dynamic color correction shader code
  • elepHDRToning.fxh - My personal favorite tonemapping effect, uses Local Reinhard tonemapping as well as Uncharted2D tonemapping
  • elepTonemapMethods.fxh - A collection of the more common tonemapping methods used in game post-processing
  • elepNightEye.fxh - My personal Night Eye effect for use when AGCC is not used, preferably. Uses Visual Acuity based tonemapping along with some other useful settings
  • elepPCC.fxh - My own personal version of Procedural Color Correction effects
  • enbPalette.fxh - Boris default Palette effect
  • enbPCC.fxh - Boris default Procedural Color Correction effects
  • enbVanillaTechnique.fxh - Boris default Vanilla technique effect
All controls have been Day, Night and Interior separated.
All files contains useful info on what is available to add/include where those things should included into each file.

Preview of some of the files content
Image


A simple showcase on how to include one of those files and use it's functions.
All .fxh files is designed to use the elepHelpers.fxh, so that has to be included into the file you are including one of the shader effects.



enbeffect.fx
First you need to include the files into the enbeffect.fx, you do that with this code line, elepHelpers.fxh and enbAGCC.fxh will be used for this example.

Code: Select all

   #include "/ELEP Additional Shaders/elepHelpers.fxh"  // This code line needs to be added after the register section inside enbeffect.fx, this is only true for the enbeffect.fx file
   #include "/ELEP Additional Shaders/enbAGCC.fxh"
There, you have now successfully added/included the helper function library and the APPLYGAMECOLORCORRECTION effect library into your file.


Now you need to include it into the rendering stage so it will have an effect on the render output.

For that you need to add this code line for the AGCC code to take affect;

Code: Select all

    color.rgb = enbAGCC(color, vadapt, vbloom);  // This code line goes into the Pixel shader (PS_D6EC7DD1) after all initialization code is done
Like this;

Code: Select all

float4 PS_D6EC7DD1(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
// Initialize various variables used in this shader file
  float4 color  = 0.0f;
  float4 _v0    = 0.0f;
  _v0.xy        = IN.txcoord0.xy;      /// Texture coordinates
  color         = tex2D(_s0, _v0.xy);  /// ENBSeries color output
  float4 vbloom = tex2D(_s1, _v0.xy);  /// Vanilla bloom effect
  float4 vadapt = tex2D(_s2, _v0.xy);  /// Vanilla adaptation effect
  float4 ebloom = tex2D(_s3, _v0.xy);  /// ENBSeries bloom effect
  float4 eadapt = tex2D(_s4, _v0.xy);  /// ENBSeries adaptation effect

// Main ENBSeries Post-Processing computations and injections
    color.rgb = enbAGCC(color, vadapt, vbloom);  // AGCC injection code line

----

  color.w = 1.0f;
  return color;
}
Now you should see that the AGCC effect is active and in use after you have saved the enbeffect.fx file changes and in game you have pressed the <<<<<APPLY CHANGES>>>>> button found at the of the GUI window.


To make it so you can easily enable or disable the AGCC effect, add this code into the file;

Code: Select all

// Add the below GUI annotation at the top of the file
  bool ENABLE_AGCC <
    string UIName = "Enable Game Post-Processing";
  > = {true};

----

  if (ENABLE_AGCC==true)
  {
    color.rgb = enbAGCC(color, vadapt, vbloom);  // AGCC injection code line
  }


I'll add more info later on but this should be enough to start off with.
None of these codes have been "set in stone" and I consider them all WIP as I always find something to improve or do differently, they are however 100% working and without issues.


Change Log

v5;
- Added NXS post-processing
- Fixed a code error in elepAGCC
- Added the new string feature, to better organize the GUI window and add in short info notes
- Created a new shader file for Adaptation with Min, Max range clamp/"limiting" controls, and attached to all relative shader effects

v3;
- Added Boris default Palette effect
- Added Boris default Procedural Color-Correction effect
- Removed unnecessary code from various files
- Added Split Screen to the elepTonemapMethods.fxh shader file
- Even added the Vanilla technqiue/FLIP_TECHNIQUE, mainly to show inexperienced coders that it's possible to do so.
- General/misc. alterations to all files in some way.

v2;
- Cleaning and general fixes to previous files, all controls have Day, Night and Interior separation now.
- Added ENBSeries four original Post-Process methods into the library, with Day, Night and Interior separation.
- Made the Tonemapping methods from v1 to be accessible through the TECHNIQUE drop down window found at the top of the enbeffect.fx GUI window. Thanks for the tip kingeric1992.
- Included a enbseries.ini for recommended settings, bloom is necessary for the HDR Toning to work as intended. Also a slightly modified enbbloom.fx, additional bloom coding is from Prod80's bloom shader.

Offline
User avatar
Posts: 27
Joined: 02 Jan 2015, 17:58

Re: [HLSL CODE] Modular Shader Library

Awesome. Thank you for sharing these. As someone who's just now getting into building an ENB Preset from the ground up, these are a godsend. :D

I'm finding the tone mapping to be a lot more powerful than what I've tried earlier.

Until now I've just been messing about, and I'm slowly learning. Do you have any reading (or better yet, video tutorial) suggestions, for getting into HLSL as a novice?

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: [HLSL CODE] Modular Shader Library

Glad you are finding this resource useful :)

The tonemapping is quite unique among ENBSeries shader codes, as far as I know this is the only one containing Local Tonemapping, all the other contains Global tonemapping.
I have combined Local Reinhard tonemapping for the main function of handling the bright spots in the image, and then I combined it with Uncharted2D to allow better tone curve control. So I, and end-users alike, would be able to tweak as much as possible without degrading the image in terms of quality by using LDR effects like contrast to achieve high quality ENB presets.

As for HLSL coding then I can only suggest Google "HLSL tutorials", there are quite a few good ones at the top after such a search. But I've learned my "skills" through looking at the files and using my common sense of "this goes there and that goes there, and I get that result, rework it, get another result, rework it again" etc, etc. Haven't followed any tutorial just searched for things like "HLSL function_name" when I needed to. And gotten help when asked for from fellow coders, most of which is on here.

But here are some links anyway;
http://rbwhitaker.wikidot.com/hlsl-tutorials
http://www.rastertek.com/tutindex.html
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
http://www.catalinzima.com/xna/tutorial ... e-in-hlsl/
http://ask.metafilter.com/264269/Learni ... -non-coder

Just some random gathered links there, maybe you get some more info out of them than nothing at least.

Offline
User avatar
Posts: 27
Joined: 02 Jan 2015, 17:58

Re: [HLSL CODE] Modular Shader Library

Cool. That's often how I learn the best as well. Thanks for the links. Plenty of useful stuff there. :)

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: [HLSL CODE] Modular Shader Library

Have some happy coding endeavors ;)

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

Re: [HLSL CODE] Modular Shader Library

How about utilize technique selection, <resourcename="custom technique";>;
and pack the header files with techniques.

much easier to pick desired tonemapping method if it works. :)
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: [HLSL CODE] Modular Shader Library

Thanks for reminding me, totally forgot about that annotation :P

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: [HLSL CODE] Modular Shader Library

Well the idea is good but the implementation, the only i can see for now, is a bit out of my league or at least in interest. I need to work with a new type of coding method which I have never done before. Code it like Boris coded the ORIGINALPOSTPROCESS code in the second technique found in the default enbeffect.fx file
I have yet to look into another method for this though.

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

Re: [HLSL CODE] Modular Shader Library

It doesn't have to be in assembly code.
And sorry about the wrong annotation, didn't check the .fx then.

Code: Select all

float4 PS_Test(VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
{
    return 0;
}

technique Shader_TEST <string UIName="test";>
{
	pass p0
	{
		VertexShader  = compile vs_3_0 VS_Quad();
		PixelShader  = compile ps_3_0 PS_Test();

		ColorWriteEnable=ALPHA|RED|GREEN|BLUE;
		ZEnable=FALSE;
		ZWriteEnable=FALSE;
		CullMode=NONE;
		AlphaTestEnable=FALSE;
		AlphaBlendEnable=FALSE;
		SRGBWRITEENABLE=FALSE;
	}
}
Image

and FX Composer can generate assembly code.
Image
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: [HLSL CODE] Modular Shader Library

Ok got it to work, but as far as I remember Boris have said that enbeffect.fx only can use one pixel sader. Or am I forgetting something here? most likely I have.
Thanks for the tip about the assembly option in FX Composer.

EDIT;
Well 7 pixelshaders and 7 techniques later, all is working and there is propably a better way of doing what I've done but it works at least and now it is a bit easier to understand which tonemapping operator is active. Thanks for the suggestion and helpful approach kingeric :)
Post Reply