Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //"ReShade.fxh" is a header that defines some common things like the main texture, called "BackBuffer".
- //It's also defined with a namespace, so keep that in mind.
- #include "ReShade.fxh"
- /*
- This is a PixelShader, it returns float4 because we're writing to a float 4D vector: (red, green, blue, alpha).
- "SV_Position", "TEXCOORD" and "SV_Target" are information we get from the GPU, don't really worry about them for now.
- Just know that "TEXCOORD" stores the current coordinate of the fragment we're working on.
- Also, usually "TEXCOORD" is a shortening for "TEXCOORD0", as there can be multiple GPU registers for coordinates.
- Remember that in HLSL/CG and in ReShadeFX the coordinates are normalized (0.0-1.0) as opposed to GLSL.
- The ':' indicates what register we're writing to, in this case it's the screen render target.
- Anything screen-related in DirectX is denoted by 'SV_' if I recall correctly.
- Note that this function could also be a void, using an "out float4 color : SV_Target" as a pointer parameter.
- But I find it simpler to just be a returning function.
- */
- float4 PS_Example(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
- /*
- ReShade::BackBuffer is the main texture of the screen, we can write to and read it freely.
- But normally other textures can only be either writen or read in separate shaders/passes.
- tex2D() reads a texture with the specified coordinate and returns a float4.
- Since we're not interested in the alpha (which could be useful in some cases)
- we specify we only want the RGB components with .rgb. This is also called 'swizzling'.
- Swizzling in shader languages allows us to freely manipulate components of a vector.
- For example, we could switch the order of colors using .bgr.
- .xyzw and .rgba are synonymous, though you cannot use them together.
- I usually only use .rgba when referring to values that I know are regular colors.
- Otherwise I use .xyzw when it's other kind of information, like normals, coordinates etc.
- */
- float3 col = tex2D(ReShade::BackBuffer, uv).rgb;
- return float4(col, 1.0); //We need to return float4, so we append a 1.0 alpha to the float3 color, making it a float4!
- }
- /*
- Techniques are a HLSL/CG standard where we can specify how effects are to be done in our pipeline.
- Although these do not natively exist in GLSL (we have to manually specify in code how to manipulate OpenGL shaders)
- ReShade is capable of making these work with OpenGL out of the box.
- On an side note, you could use a scripting language like Lua together with C++ to manipulate effects like techniques
- in OpenGL, as C++ can be cumbersome and Lua can be modified post program compilation.
- */
- technique Example {
- //A technique can have many passes, optionally with a name.
- pass {
- /*
- VertexShader and PixelShader allow us to specify what shaders to use.
- This is a simplified version of how you do it in HLSL/CG.
- Also, PostProcessVS is a vertex shader defined in 'ReShade.fxh',
- though for reasons unknown to me it does not follow the namespace rule anymore.
- (it used to in older versions of ReShade, you had to do ReShade::VS_PostProcess)
- */
- VertexShader = PostProcessVS;
- PixelShader = PS_Example;
- /*
- We could define other things here, but doesn't matter now.
- For example, ReShade automatically writes to the backbuffer if no render target is specified.
- The same as:
- RenderTarget = ReShade::BackBufferTex;
- "RenderTarget" can be followed by a number, it defaults to "RenderTarget0" if it's not specified.
- This allows for multiple render target rendering, though all of them must be of the same resolution.
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement