Guest User

NvCommon.fxh

a guest
May 18th, 2025
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. /*
  2. Modified version of ReShade.fxh for Ansel/FreeStyle specific requirements
  3. */
  4.  
  5. #pragma once
  6.  
  7. #define BUFFER_PIXEL_SIZE float2(BUFFER_RCP_WIDTH, BUFFER_RCP_HEIGHT)
  8. #define BUFFER_SCREEN_SIZE float2(BUFFER_WIDTH, BUFFER_HEIGHT)
  9. #define BUFFER_ASPECT_RATIO (BUFFER_WIDTH * BUFFER_RCP_HEIGHT)
  10.  
  11. //NvCamera capture state enum
  12. //use with following code in effect file
  13. // uniform int captureState < source = "capture_state"; >;
  14. //not present in common file as uniforms use memory
  15.  
  16. #define CAPTURE_STATE_NOT_STARTED 0
  17. #define CAPTURE_STATE_REGULAR 1
  18. #define CAPTURE_STATE_REGULARSTEREO 2
  19. #define CAPTURE_STATE_HIGHRES 3
  20. #define CAPTURE_STATE_360 4
  21. #define CAPTURE_STATE_360STEREO 5
  22.  
  23. namespace NV
  24. {
  25. //standard texture inputs wrapped into namespace
  26. texture ColorInputTex : COLOR;
  27. texture DepthInputTex : DEPTH;
  28. sampler ColorInput { Texture = ColorInputTex; };
  29. sampler DepthInput { Texture = DepthInputTex; };
  30.  
  31. //only create texture if filter requires it
  32. #ifdef RESHADE_EFFECT_REQUIRES_HUDLESS
  33. texture HudlessInputTex : HUDLESS;
  34. sampler HudlessInput { Texture = HudlessInputTex; };
  35. #endif
  36. #ifdef RESHADE_EFFECT_REQUIRES_COLORBASE
  37. texture ColorBaseInputTex : COLOR_BASE;
  38. sampler ColorBaseInput { Texture = ColorBaseInputTex; };
  39. #endif
  40.  
  41. #ifdef RESHADE_EFFECT_REQUIRES_DEPTH
  42. uniform bool g_sldInvertedDepth <
  43. ui_type = "bool";
  44. ui_label = "Depth input is reversed";
  45. //can maybe reuse localization? Only "Invert Depth" is translated.
  46. > = 1;
  47.  
  48. float GetLinearizedDepth(float2 uv)
  49. {
  50. float depth = tex2Dlod(DepthInput, float4(uv, 0, 0)).x;
  51. depth = g_sldInvertedDepth ? 1.0 - depth : depth;
  52.  
  53. //not user adjustable in FreeStyle anyways
  54. const float N = 1.0;
  55. const float F = 1000.0;
  56. depth /= F - depth * (F - N);
  57. return depth;
  58. }
  59. #endif
  60.  
  61. //using Rec.709 at the moment, needs extension for different input formats
  62. float GetLuma(float3 color)
  63. {
  64. const float3 luma_weights = float3(0.299, 0.587, 0.114);
  65. return dot(luma_weights, color);
  66. }
  67. }
  68.  
  69. struct VSOut
  70. {
  71. float4 pos : SV_POSITION;
  72. float2 uv : TEXCOORD0;
  73. };
  74.  
  75. VSOut VSMain(in uint vid : SV_VertexID)
  76. {
  77. VSOut o;
  78. o.uv.x = (vid == 2) ? 2.0 : 0.0;
  79. o.uv.y = (vid == 1) ? 2.0 : 0.0;
  80. o.pos = float4(o.uv * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
  81. return o;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment