X-Ray Vision?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Exosphere
Posts: 168
Joined: Sun Jun 11, 2017 11:42 am
Location: New England, US

X-Ray Vision?

Post by Exosphere »

As the title says, could their be a way to implement a xray-vision-like effect and be able to see enemies behind walls? My goal would have it function similarly to the Light Amp Goggles powerup in that it would make monsters appear bright Red while the world is a very deep blue.
User avatar
Eliot_L
Posts: 38
Joined: Thu Mar 08, 2018 3:40 am

Re: X-Ray Vision?

Post by Eliot_L »

I have no clue how to do something like this with the Carmack renderer or if it's even possible, but with the GL renderer you might be able to do it with a shader mod. I am only just dipping my feet into GZDoom shader modding but I have done shaders before in other environments. It sounds like if you are going for a heat vision effect or something you may even be able to do this without alpha transparency - if we can figure out how to bypass depth testing for the monster sprites. Perhaps with a fragment shader like so. If I have time I might try to see if I can get this working, it sounds interesting.

EDIT:
I have been trying for a while and I got a custom hardware shader applied to an enemy sprite but i am running into some issues with this.
  • I don't see a way to apply a custom vertex shader to a sprite, and custom hardware shaders appear to be unable to write to gl_FragDepth - this may need to be done in the main fragment shader instead
  • Specification of hardware shaders in GLDEFS seem to require one shader definition per graphic - I think that means if I wanted to apply this shader to all monsters (or all sprites) I'd need to make a shader definition for each frame of each sprite in the game? Could be done quickly with an external script but kind of annoying. And also then it would not play nicely with custom sprites added via DECORATE, etc.
So unless there is some sort of other flag I am unaware of, or other sort of trickery that could be done here, I think you might need to modify the renderer to allow for this functionality. But interested to hear from more experienced folks.

I've attached a pk3 of how far I got - I was at least able to figure out the part about tinting the sprite red, although having to make one shader definition per animation frame is annoying so I only did them for the former human facing away sprites for this test.
I also tinted everything else blue which looks kinda cool - but I don't know how i'd go about passing uniforms to these sorts of hacked built-in shaders to toggle the effect. The way i've done it right now even the UI and stuff is blue... may need to do this as a postprocess shader instead, though you'd need to stencil out all the sprites or somehow do them as a second pass.
You do not have the required permissions to view the files attached to this post.
User avatar
Caligari87
Admin
Posts: 6248
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him

Re: X-Ray Vision?

Post by Caligari87 »

The problem is the "seeing through walls" part. That's not gonna happen with a shader. Theoretically I think Nash's SpriteShadow mod could be revamped to project fake monster sprites from the player toward each monster, but I'm not sure how good it would look.

8-)

Return to “Scripting”