Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- // ENBSeries Fallout 4 hlsl DX11 format, sample file
- // visit http://enbdev.com for updates
- // Author: Boris Vorontsov
- // It's similar to effect.txt shaders and works with ldr input and output
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- // This is a demo file on bare-bone enbsmaa.fx implementation
- //+++++++++++++++++++++++++++++
- //external enb parameters, do not modify
- //+++++++++++++++++++++++++++++
- //x = generic timer in range 0..1, period of 16777216 ms (4.6 hours), y = average fps, w = frame time elapsed (in seconds)
- float4 Timer;
- //x = Width, y = 1/Width, z = aspect, w = 1/aspect, aspect is Width/Height
- float4 ScreenSize;
- //changes in range 0..1, 0 means full quality, 1 lowest dynamic quality (0.33, 0.66 are limits for quality levels)
- float AdaptiveQuality;
- //x = current weather index, y = outgoing weather index, z = weather transition, w = time of the day in 24 standart hours. Weather index is value from weather ini file, for example WEATHER002 means index==2, but index==0 means that weather not captured.
- float4 Weather;
- //x = dawn, y = sunrise, z = day, w = sunset. Interpolators range from 0..1
- float4 TimeOfDay1;
- //x = dusk, y = night. Interpolators range from 0..1
- float4 TimeOfDay2;
- //changes in range 0..1, 0 means that night time, 1 - day time
- float ENightDayFactor;
- //changes 0 or 1. 0 means that exterior, 1 - interior
- float EInteriorFactor;
- //+++++++++++++++++++++++++++++
- //external enb debugging parameters for shader programmers, do not modify
- //+++++++++++++++++++++++++++++
- //keyboard controlled temporary variables. Press and hold key 1,2,3...8 together with PageUp or PageDown to modify. By default all set to 1.0
- float4 tempF1, tempF2, tempF3; //1, 2, 3, 4, 5, 6, 7, 8, 9, 0
- // xy = cursor position in range 0..1 of screen;
- // z = is shader editor window active;
- // w = mouse buttons with values 0..7 as follows:
- // 0 = none
- // 1 = left
- // 2 = right
- // 3 = left+right
- // 4 = middle
- // 5 = left+middle
- // 6 = right+middle
- // 7 = left+right+middle (or rather cat is sitting on your mouse)
- float4 tempInfo1;
- // xy = cursor position of previous left mouse button click
- // zw = cursor position of previous right mouse button click
- float4 tempInfo2;
- //+++++++++++++++++++++++++++++
- //mod parameters, do not modify
- //+++++++++++++++++++++++++++++
- Texture2D TextureOriginal; //color R10B10G10A2 32 bit ldr format
- Texture2D TextureColor; //color which is output of previous technique (except when drawed to temporary render target), R10B10G10A2 32 bit ldr format
- Texture2D TextureDepth; //scene depth R32F 32 bit hdr format
- //temporary textures which can be set as render target for techniques via annotations like <string RenderTarget="RenderTargetRGBA32";>
- Texture2D RenderTargetRGBA32; //R8G8B8A8 32 bit ldr format
- Texture2D RenderTargetRGBA64; //R16B16G16A16 64 bit ldr format
- Texture2D RenderTargetRGBA64F; //R16B16G16A16F 64 bit hdr format
- Texture2D RenderTargetR16F; //R16F 16 bit hdr format with red channel only
- Texture2D RenderTargetR32F; //R32F 32 bit hdr format with red channel only
- Texture2D RenderTargetRGB32F; //32 bit hdr format without alpha
- SamplerState Sampler0
- {
- Filter = MIN_MAG_MIP_POINT;//MIN_MAG_MIP_LINEAR;
- AddressU = Clamp;
- AddressV = Clamp;
- };
- #define SMAA_UINAME 1
- #define PASSNAME0 SMAA
- #define PASSNAME1 SMAA1
- #define PASSNAME2 SMAA2
- #define PASSNAME3 SMAA3
- #include "enbsmaa.fx"
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //RETRO FX shader code starts here
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- /*
- Multipass technique groups have such structure:
- MYAWESOMETECHNIQUENAME <- name of technique group. The techniques you can select in the UI are the starter techniques like this one
- MYAWESOMETECHNIQUENAME1 <- consecutive technique name so ENB knows to append this one after MYAWESOMETECHNIQUENAME
- MYAWESOMETECHNIQUENAME2 <- consecutive technique name so ENB knows to append this one after MYAWESOMETECHNIQUENAME1
- We are using SMAA, SMAA1, SMAA2 now, so as we want to use SMAA and Retro (or do we?), we have to use SMAA3 now, to append it after SMAA2.
- */
- #define PASSNAME3 SMAA3
- /* Kingeric's SMAA port uses own vertex shaders. Vertex shaders determine the area where the pixel shader runs, among other things
- such as expensive calculations that are uniform on all pixels so calculating them in the vertex shader is faster.
- As we don't need such things, we're reimplementing Boris' standard vertex shader here. */
- struct VS_INPUT_POST
- {
- float3 pos : POSITION;
- float2 txcoord : TEXCOORD0;
- };
- struct VS_OUTPUT_POST
- {
- float4 pos : SV_POSITION;
- float2 txcoord0 : TEXCOORD0;
- };
- VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
- {
- VS_OUTPUT_POST OUT;
- float4 pos;
- pos.xyz=IN.pos.xyz;
- pos.w=1.0;
- OUT.pos=pos;
- OUT.txcoord0.xy=IN.txcoord.xy;
- return OUT;
- }
- int EColorCount
- <
- string UIName="Retro:: Amount of singular colors";
- string UIWidget="spinner";
- int UIMin=1;
- int UIMax=255;
- > = {16};
- float EResolutionDiv
- <
- string UIName="Retro:: Resolution scale";
- string UIWidget="spinner";
- float UIMin=0.0;
- float UIMax=16.0;
- float UIStep=0.1;
- > = {4.0};
- float4 PS_Retro(VS_OUTPUT_POST IN, float4 v0 : SV_Position0) : SV_Target
- {
- float2 screenresRescaled = ScreenSize.xx * float2(1.0,ScreenSize.w) / EResolutionDiv;
- float2 texcoord = floor(IN.txcoord0.xy * screenresRescaled) / screenresRescaled;
- float4 color = TextureColor.Sample(Sampler0, texcoord);
- //Do Vibrance
- float VibranceIntensity = 1.0;
- float VibranceR = 1.0;
- float VibranceG = 1.0;
- float VibranceB = 1.0;
- float3 VibCoeff = float3((VibranceR * VibranceIntensity), (VibranceG * VibranceIntensity), (VibranceB * VibranceIntensity));
- float3 VibColor = color.rgb;
- float3 LumCoeff = float3(0.2127, 0.7152, 0.0722);
- float Luma = dot(LumCoeff, VibColor.rgb);
- float VibMaxColor = max(color.r, max(color.g, color.b));
- float VibMinColor = min(color.r, min(color.g, color.b));
- float VibSaturation = VibMaxColor - VibMinColor;
- VibColor.rgb = lerp(Luma, VibColor.rgb, (1.0 + (VibCoeff * (1.0 - (sign(VibCoeff) * VibSaturation)))));
- color.rgb = VibColor.rgb;
- //
- //Levels
- float3 RGB_Lift = float3(1.30,1.30,1.30);
- float3 RGB_Gain = float3(1.00,1.00,1.00);
- float3 RGB_Gamma = float3(1.00,1.00,1.00);
- color.rgb = color.rgb * (1.5-0.5 * RGB_Lift) + 0.5 * RGB_Lift - 0.5;
- color.rgb = saturate(color.rgb);
- color.rgb *= RGB_Gain;
- color.rgb = pow(color.rgb, 1.0 / RGB_Gamma); //Gamma
- color.rgb = saturate(color);
- //
- color.rgb += 0.12;
- float graymax=max(color.r, max(color.g, color.b));
- float3 ncolor=color.rgb/graymax;
- graymax=floor(graymax * EColorCount)/EColorCount;
- color.xyz*=graymax;
- color.a = 1.0;
- return color;
- }
- technique11 PASSNAME3 // <- preprocessor will substitute "PASSNAME3" with the "SMAA3" we declared above
- {
- pass McFlysSimpleRetroShit //arbitrary name
- {
- SetVertexShader(CompileShader(vs_5_0, VS_PostProcess())); // <- we're using Boris' vertex shader from above
- SetPixelShader(CompileShader(ps_5_0, PS_Retro()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement