[Released] Reflex sight shader

Update:

I’ve just released a new update for this shader pack, it now includes a holographic sight shader (demo here). In real life, a holographic sight makes use of a 3d image of a reticle, set at some finite distance in front of the sight window, that is captured on holographic film. When this film is illuminated with a laser, the image of the reticle becomes visible and appears to float in front of the sight window. Because the reticle is set at a finite distance, rather than at infinity (as with a reflex sight), it is effectively parallax free at that distance (note how the reticle “sticks” to the bullseye in the demo, its reticle distance matches the target distance exactly).

Additionally, I have optimized the angled reflex sight shader to run on shader model 2 graphics cards, and included a version of each shader with cubemap reflections.


Hi all,

I’ve just recently released my first package on the asset store, a shader that accurately reproduces the effect of a reflex sight.

This shader is perfect for modern FPS games or flight sim games (for a heads up display). If this sounds like something you could use in your project, have a look at the web player demo.

The shader is customizable; you can change the reticle image, colour, brightness and size, as well as the sight window transparency and colour. The package includes 6 reticles and the demo scene seen in the web player demo.

The package can be found here on the asset store.

Screenshot album

That is super uneasy to look at, might look realistic but god it just irks me trying to use it for targeting.

How do you mean “uneasy”? It might seem odd in the demo because the camera is moving with regard to the sight, in a game the sight/gun would be moving (swaying, moving between “hip fire” and “aimed” mode for example), in which case the reticle would stay still while the sight moves around it (assuming the gun is only moving and not rotating as well).

bought, works as expected and looks really good.

Two things I would like to see with an update:

1: Support for tilted sights (setting a basic offset angle) - like for glass of the revi sights in WW2 aircrafts.

Like the glass (B) on which it gets projected in Fig1:

Movie example: http://www.youtube.com/watch?v=Blem3FlkaMc

2: Option to keep scaling independent from camera distance. (currently when the pilot’s head is moving back or forward (trackir) the size of the “projection” on the glass grows and shrinks.)

Example: http://www.youtube.com/watch?v=NXsVg8F91t

For flight combat where the head moves because of g-forces and different views this kind of gunsight is absolutely necessary and realistic - without it you could actually not aim.

Can u post video on setup

Hi VIC20, thanks for the purchase and the rating. I’ve implemented your requested changes and have submitted the updated version, but it’s still pending review and may be a day or two before going live. In the meantime, here is a demo of the “rotated” shader without distance scaling.

I tried to keep it general so that you could specify the angle of the sight, however I ran into some problems with reticle stretching and in the end decided to go with a fixed angle instead (45 degrees) EDIT: Actually I managed to get it working with any angle, the demo has been updated. As for the distance scaling, I’ve added a copy of each shader with distance scaling disabled, however as far as I am aware, in real life the reticle should always appear to scale with distance (ie, remain the same size on the glass no matter the viewing distance) as the reticle is at infinity and therefore all light rays entering the eye are parallel to each other.

imtrobin, if you’re asking for a video of how to set it up, I don’t think that’s necessary. The shader behaves like a regular shader, just create a material, select the shader, pick the reticle texture and enter the other values by hand (reticle scale, brightness, sight window colour etc). The only real thing to note is that the reticle texture should have its wrap mode set to clamp (unless you want tiling reticles), and the model to which you are applying the material should have its surface lie in the XY plane in local space. You’ll have to set that up in your modeling app however.

how do u set target? I want to see how it can be used in a real game example with many planes, not just a 1 target demo. It can be hardcoded for all I know.

There is no target to speak of, the shader draws the reticle such that it is centred at the closest point on the surface to the camera. So the rotation of the surface/object along with the camera position relative to it determines where the reticle appears.

I have updated the web player demo with rotation controls so you can see how the shader reacts. Hopefully that will clear things up a bit.

Little Q : Would this be workable for an on-rails-shooter where it replaces the mouse ?

It wouldn’t work for that no, sorry. You could try something like this.

Thank you, excellent support!

Ok ,I think I understand more. So it’s a raycast to surface I define, and draws the reticle there.

Looks great, but isn’t the whole idea that it stays on target no matter what? In your demo it sways quite a lot depending on how you view it. It almost goes from the left side of the bullseye to the right side.

I think it’s referred to as parallax:

In you demo it’s way worse than what he’s describing as an unusable sight. :slight_smile: Seeing as you have no hardware limitations you can and should make it perfect or at the very least have a slider for parallax. :slight_smile:

I also thought that when trying the current demo. It worked in the original version - seems this error is a result of the latest update.

TwiiK, the shader is already “perfect” inasmuch as that it behaves like a real reflex sight; the movement of the reticle is normal, and happens to real reflex sights as well. From wikipedia:

and

What this basically boils down to is, your accuracy will vary by the size of the sight window, which is to say, if you are aiming at a target using a 10cm diameter sight, your bullets will hit within 10cm of where the reticle appears on the target. In the demo, the sight window is very large compared to the target, especially in the angled sights demo, where the window is around the size of the bullseye. In an actual game, the sights would be much smaller than the target and therefore the inaccuracy would be negligible.

I’ve released an update for this shader pack, see the first post for details

@mupped : This is an awesome package thanks for releasing it. I found one problem. DX11 breaks the rotated shaders. I don’t know why but when a project is using DX11 in Unity 4 only the rotated shaders have problems. They start to generate errors.

Material doesn’t have a texture property ‘_reticleTex’
Material doesn’t have a color property ‘_reticleColour’
Material doesn’t have a float or range property ‘_reticleBright’
Material doesn’t have a color property ‘_glassColour’’
Material doesn’t have a float or range property ‘_glassTrans’
Material doesn’t have a float or range property ‘_uvScale’
Material doesn’t have a float or range property ‘_angle’

I can fix all the errors for the float, color, slider fields simply by changing there values or moving a slider. However the only way to fix the _reticleTex error is by removing the texture to a null state in the inspector. This is just straight up weird. By having no texture the no texture error goes away, Aaaacckk!

I stumbled across this only because i was testing out some tessellation in a test project which is using DX11 when i imported the reflex sight package. So most users will not encounter this problem. I just thought it was strange and that you should know. All the other shaders work great in DX 11 and all shaders work in DX <11. I have no idea why the rotated versions don’t like DX11…

Again as far as i can tell this is a DX11 issue only. Or it may be an nvidia DX 11 problem?

new link i guess…

Does it work on Unity 2017?