Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************************************************************/
- /*! \file Crosshair.usf
- *
- * Adds a crosshair to APBr
- *
- *
- * Owned by dreamss, some code stolen from tobii and spec
- *
- * variable crosshair size added by Kimiko
- * and pretty much every change after that ... DYNAMIC_COLOR, internal color options, and making it work on rtw/1.9.1 shaders
- * fuckshadercoding
- *
- * Thanks to blizzy for the alternative crosshairs ENABLE_CROSSHAIR_DOT_2 ENABLE_CROSSHAIR_CIRCLE ENABLE_CROSSHAIR_CROSS
- *
- *
- *
- * Usage:
- * Add '#include "Crosshair.usf"' to APBUberPostProcessBlendPixelShader.usf before the bottom closing "}".
- * view the included APBUberPostProcessBlendPixelShader.usf if you have questions
- *
- * DONT FORGET TO EDIT SCREEN_SIZE_X and SCREEN_SIZE_Y
- *
- * IF THE GAME CRASHES CROSSHAIR_SIZE IS WAY TO BIG!
- ****************************************************************************************/
- #define ENABLE_CROSSHAIR 1
- #define ENABLE_CROSSHAIR_DOT_1 0
- #define ENABLE_CROSSHAIR_DOT_2 0
- #define ENABLE_CROSSHAIR_CIRCLE 0
- #define ENABLE_CROSSHAIR_CROSS 0
- #define ENABLE_CROSSHAIR_CHEVRON 1
- #define SCREEN_SIZE_X 1920
- #define SCREEN_SIZE_Y 1080
- #define CROSSHAIR_DOT_1_SIZE .8
- #define IN_CROSSHAIR_DOT_1_COLOR float4( 0, 0, 0, 1)
- #define IN_CROSSHAIR_DOT_1_DYNAMIC_COLOR 1
- #define OUT_CROSSHAIR_DOT_1_COLOR float4( 255, 0, 0, 1)
- #define OUT_CROSSHAIR_DOT_1_DYNAMIC_COLOR 0
- #define CROSSHAIR_DOT_2_COLOR float4(0.0, 0.0, 0.0, 0.1)
- #define CROSSHAIR_CIRCLE_COLOR float4(255, 0, 0, 1.0)
- #define CROSSHAIR_CIRCLE_RADIOUS .03
- #define CROSSHAIR_CROSS_COLOR float4(1.0, 1.0, 1.0, 1.0)
- #define CROSSHAIR_CROSS_SIZE .005
- #define CROSSHAIR_CHEVRON_COLOR float4(1.0, 0, 0, 1.0)
- #define CROSSHAIR_CHEVRON_SIZE_A .01
- #define CROSSHAIR_CHEVRON_SIZE_B .001
- //I officially give the fuck up. Set this to SCREEN_SIZE_Y / SCREEN_SIZE_X manually, it refuses to work when calculated.
- #define chevronaspectRatio .5625
- // if someone figures out how to make this work let me know - it does not seem to make a difference
- #define IN_CROSSHAIR_ALPHA 1
- #define OUT_CROSSHAIR_ALPHA 1
- {
- #if ENABLE_CROSSHAIR
- #define aspectRatio SCREEN_SIZE_X/SCREEN_SIZE_Y
- #if ENABLE_CROSSHAIR_CIRCLE
- float newX = SceneUV.x * aspectRatio;
- float centerX = 0.5 * aspectRatio;
- float newY = SceneUV.y;
- float centerY = 0.5;
- float cDis;
- cDis = sqrt(pow(newX - centerX, 2) + pow(newY - centerY, 2));
- if (cDis >= CROSSHAIR_CIRCLE_RADIOUS && cDis <= (CROSSHAIR_CIRCLE_RADIOUS+ 0.002f))
- {
- OutColor = CROSSHAIR_CIRCLE_COLOR;
- }
- #endif
- #if ENABLE_CROSSHAIR_CROSS
- if (SceneUV.x >= 0.5 - CROSSHAIR_CROSS_SIZE && SceneUV.x <= 0.5 + CROSSHAIR_CROSS_SIZE && SceneUV.y >= 0.499 && SceneUV.y <= 0.501)
- {
- OutColor = CROSSHAIR_CROSS_COLOR;
- }
- else if (SceneUV.x >= 0.4995 && SceneUV.x <= 0.5005 && SceneUV.y >= 0.5 - (CROSSHAIR_CROSS_SIZE * aspectRatio) && SceneUV.y <= 0.5 + (CROSSHAIR_CROSS_SIZE * aspectRatio))
- {
- OutColor = CROSSHAIR_CROSS_COLOR;
- }
- #endif
- #if ENABLE_CROSSHAIR_CHEVRON // CROSSHAIR_CHEVRON_SIZE
- // seriously, shoot me
- //this works still...
- //if (SceneUV.x >= 0.5 - CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x <= 0.5 + CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x >= SceneUV.y - CROSSHAIR_CHEVRON_SIZE_B && SceneUV.x <= SceneUV.y + CROSSHAIR_CHEVRON_SIZE_B && SceneUV.y >= 0.5)
- //Static aspect ratio 16:9
- //if (SceneUV.x >= 0.5 - CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x <= 0.5 + CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x >= .5625 * SceneUV.y + ( 1 - .5625 ) / 2 - CROSSHAIR_CHEVRON_SIZE_B && SceneUV.x <= .5625 * SceneUV.y + ( 1 - .5625 ) / 2 + CROSSHAIR_CHEVRON_SIZE_B && SceneUV.y >= 0.5)
- if (SceneUV.x >= 0.5 - CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x <= 0.5 + CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x >= chevronaspectRatio * SceneUV.y + ( 1 - chevronaspectRatio ) / 2 - CROSSHAIR_CHEVRON_SIZE_B && SceneUV.x <= chevronaspectRatio * SceneUV.y + ( 1 - chevronaspectRatio ) / 2 + CROSSHAIR_CHEVRON_SIZE_B && SceneUV.y >= 0.5)
- {
- OutColor = CROSSHAIR_CHEVRON_COLOR;
- }
- //static aspect ratio 16:9
- //else if (SceneUV.x >= 0.5 - CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x <= 0.5 + CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x >= 1 - .5625 * SceneUV.y - ( 1 - .5625 ) / 2 - CROSSHAIR_CHEVRON_SIZE_B && SceneUV.x <= 1 - .5625 * SceneUV.y - ( 1 - .5625 ) / 2 + CROSSHAIR_CHEVRON_SIZE_B && SceneUV.y >= 0.5)
- else if (SceneUV.x >= 0.5 - CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x <= 0.5 + CROSSHAIR_CHEVRON_SIZE_A && SceneUV.x >= 1 - chevronaspectRatio * SceneUV.y - ( 1 - chevronaspectRatio ) / 2 - CROSSHAIR_CHEVRON_SIZE_B && SceneUV.x <= 1 - chevronaspectRatio * SceneUV.y - ( 1 - chevronaspectRatio ) / 2 + CROSSHAIR_CHEVRON_SIZE_B && SceneUV.y >= 0.5)
- {
- OutColor = CROSSHAIR_CHEVRON_COLOR;
- }
- #endif
- #if ENABLE_CROSSHAIR_DOT_2
- if (SceneUV.x >= 0.498 && SceneUV.x <= 0.502 && SceneUV.y >= 0.498 && SceneUV.y <= 0.502)
- {
- OutColor = CROSSHAIR_DOT_2_COLOR;
- }
- #endif
- #if ENABLE_CROSSHAIR_DOT_1
- float2 ScreenSize = float2( CROSSHAIR_DOT_1_SIZE / SCREEN_SIZE_X , CROSSHAIR_DOT_1_SIZE / SCREEN_SIZE_Y );
- if(SceneUV.x >= 0.5 - ScreenSize.x && SceneUV.x <= 0.5 + ScreenSize.x && SceneUV.y >= 0.5 - ScreenSize.y && SceneUV.y <= 0.5 + ScreenSize.y)
- {
- #if IN_CROSSHAIR_DOT_1_DYNAMIC_COLOR
- OutColor = 1 - OutColor;
- OutColor.a = IN_CROSSHAIR_ALPHA;
- #else
- OutColor = IN_CROSSHAIR_DOT_1_COLOR ;
- #endif // IN_CROSSHAIR_DOT_1_DYNAMIC_COLOR
- }
- else if (SceneUV.x >= 0.5 - ScreenSize.x * 2 && SceneUV.x <= 0.5 + ScreenSize.x * 2 && SceneUV.y >= 0.5 - ScreenSize.y * 2 && SceneUV.y <= 0.5 + ScreenSize.y * 2 )
- {
- #if OUT_CROSSHAIR_DOT_1_DYNAMIC_COLOR
- OutColor = 1 - OutColor;
- OutColor.a = OUT_CROSSHAIR_ALPHA;
- #else
- OutColor = OUT_CROSSHAIR_DOT_1_COLOR;
- #endif // OUT_CROSSHAIR_DOT_1_DYNAMIC_COLOR
- }
- #endif //ENABLE_CROSSHAIR_DOT_1
- #endif // ENABLE_CROSSHAIR
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement