3
\$\begingroup\$

In first-person-shooters like Call of Duty, the hologram only appears when it is behind the glass portion of the sight.

In OpenGL, would it be implemented by rendering the glass to the stencil buffer and then rendering the hologram, but masked by the stencil buffer?

\$\endgroup\$
4
  • 1
    \$\begingroup\$ I doubt it is something that complicated. It is very likely just a 2D sprite. img1.wikia.nocookie.net/__cb20120119074042/callofduty/images/2/… \$\endgroup\$
    – glampert
    Jul 3, 2014 at 20:16
  • \$\begingroup\$ continuing on @glampert: .. where the sight only appears (2D) after the zoom-animation has finished. \$\endgroup\$
    – Jean-Paul
    Jul 3, 2014 at 20:29
  • \$\begingroup\$ @Jean-Paul, based on my memory of COD4, if you partially aim, you can still see the sprite, but only the part that's "inside" the glass. In MW2 and MW3, they definitely only show the part "inside" the glass. \$\endgroup\$
    – Victor
    Jul 5, 2014 at 3:05
  • \$\begingroup\$ Very similar to a Portal portal... \$\endgroup\$ Sep 4, 2015 at 19:32

2 Answers 2

1
\$\begingroup\$

i think you mean the 3 dimensional offset of the holographic sight that is positioned relative to the actual frame. i think the best way to simulate the reflected projection of the dot / cross is to offset a sprite from the glass a little bit to the front of the gun ( but still ceeping it inside the frame / housing of the sight ). Also render it from the viewers side only. that way the holograph appears to be projected and positioned depending on the view angle. I hope that makes sense.

\$\endgroup\$
-3
\$\begingroup\$

Calculating UV in vertex shader:
uv.xy = mul(world2object, cameraWorldPos-mul(object2world, (0,0,0,1)))+(0.5,0.5)

\$\endgroup\$
3
  • 4
    \$\begingroup\$ Maybe you can expand on this answer to describe what you're doing and why it solves the problem. \$\endgroup\$
    – House
    Jul 11, 2014 at 4:21
  • \$\begingroup\$ It's project camera position onto sight XY plane. So if we sample texture with this coordinates and draw surface with alpha blend or add mode is will look exactly like reflector sight. \$\endgroup\$
    – mouurusai
    Jul 11, 2014 at 5:46
  • \$\begingroup\$ While it's an understandable answer, a much more elaborate explanation is probably needed. I believe that's also HLSL code, not GLSL. \$\endgroup\$ Sep 4, 2015 at 22:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .