Welcome, Guest.
Username: Password: Remember me

TOPIC: Pixel area detection?

Pixel area detection? 1 year 5 months ago #1

Is it possible to detect an area of red to black pixels like the HP orb in Guild Wars 2?
I would really love to have a bloody screen as texture overlay which gets bigger as my HP drops lower.

wiki.guildwars2.com/images/2/20/Health_orb.png

wiki.guildwars2.com/images/5/5a/Player-HP.jpg

Is it possible to detect when a red pixel is not existing anymore or got black?

I want to create such a script myself, but I do not know what arguments ReShade takes.
Last Edit: 1 year 5 months ago by Nekres.
The administrator has disabled public write access.

Pixel area detection? 1 year 5 months ago #2

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2536
  • Thank you received: 1452
Yes, that's possible. Something like this pseudocode (just guessed the position of that HP orb on the screen now to be at around (0.5, 0.94-0.98), would need more experimenting):
float strength = 0;
strength += tex2D(RFX_backbufferColor, float2(0.5, 0.94)).r
strength += tex2D(RFX_backbufferColor, float2(0.5, 0.96)).r
strength += tex2D(RFX_backbufferColor, float2(0.5, 0.98)).r
strength /= 3;

finalcolor.rgb += tex2D(bloodyScreenSampler, texcoord).rgb * strength;
Cheers, crosire =)
The administrator has disabled public write access.

Pixel area detection? 1 year 5 months ago #3

My resolution is 16:9 (1920x1080) Can you explain me the arguments in your pseudocode?

I created a perfect 16:9 uiMask for GW2: i.imgur.com/WOYz9YO.png
The HP orb is in the bottom center.

I would love you if you created me the snippet of code (maybe with commentary) where it checks the circle so I can learn my way around.
(I would even consider paying you a small fee.)

Another question is, I can't seem to find a prober C++ source file (*.h) Wiki site with a list of arguments.
Last Edit: 1 year 5 months ago by Nekres.
The administrator has disabled public write access.

Pixel area detection? 1 year 5 months ago #4

  • Ganossa
  • Ganossa's Avatar
  • Offline
  • 최정장군
  • Posts: 790
  • Thank you received: 838
The shader files are ending on .h because the syntax is similar but the language is hlsl.

If you need a testing environment I recommend the Custom.h in CustomFX suite which can be used to create new shader.
The administrator has disabled public write access.

Pixel area detection? 1 year 5 months ago #5

Is the pseudocode by cosire above detecting a circle?

Where is "RFX_backbufferColor" defined? Where can I check what it does?

I added my stuff to the pseudocode
texture bloodTex < source = "ReShade/CustomFX/Textures/CFX_bloodyScreen.png"; > { Width = 1920; Height = 1080; MipLevels = 1; Format = RGBA8; };
sampler2D bloodSampler { Texture = bloodTex; };

float strength = 0;
strength += tex2D(RFX_backbufferColor, float2(0.5, 0.94)).r
strength += tex2D(RFX_backbufferColor, float2(0.5, 0.96)).r
strength += tex2D(RFX_backbufferColor, float2(0.5, 0.98)).r
strength /= 3;

finalcolor.rgb += tex2D(bloodSampler, texcoord).rgb * strength;

I get errors in line 24, 7: global variables are considered uniform by default and line 25, 1: unexpected identifier

EDIT: I created a simple bloody screen texture for 16:9 res: i.imgur.com/1kWYsec.png
Last Edit: 1 year 5 months ago by Nekres.
The administrator has disabled public write access.

Pixel area detection? 1 year 5 months ago #6

  • jas01
  • jas01's Avatar
  • Offline
  • Posts: 79
  • Thank you received: 10
Nekres wrote:
EDIT: I created a simple bloody screen texture for 16:9 res: i.imgur.com/1kWYsec.png

You can try this.
Last Edit: 1 year 5 months ago by jas01. Reason: quote
The administrator has disabled public write access.

Pixel area detection? 1 year 5 months ago #7

Thanks, but I need more help with the hlsl shader language. I need some sort of Wiki where I can look up individual arguments and functions of the language or someone who codes the detection of the circle from above.
The administrator has disabled public write access.

Pixel area detection? 1 year 5 months ago #8

bump
The administrator has disabled public write access.