By Millz Published: March 17, 2008 Updated: March 17, 2008 PrintEmail
Hey folks, I'm Emiel Regis - The New Era's coder. Although there are
many things I work on, I'd like to share my experience with dynamic
scope system I finally got to work lately.
Dynamic scope means
that there is a texture in appropriate place in the viewmodel (the
scope of course) which is a render target. What does that mean? The
current view of the character is drawn dynamically into the scope,
which, combined with ironsights, gives a very realistic feel for
zooming with scope-equipped weapons. Instead of just drawing a
full-screen zoomed overlay, you see a realistically zoomed image appearing
on the three-dimensional scope.
Question arises - how to do it? I started with
MirrorView article on developer.valvesoftware.com. Theoretically, the
code there would work for scopes with only little modifications. The
reality proved otherwise - after many hours of coding, changing the
render target texture (which needs to be compiled with an external
tool) and cursing over, it became apparent that the method lacks a
certain detail - initilization of the very render targets. Without
this, a purple checkboard or just a plain black texture would appear on
the scope. After searching the MP SDK which TNE is built on I was quite
puzzled: There wasn't any reference for render targets initilization in
the code - but it must be done somewhere, otherwise things like water
reflections would not work, while they did.
At this point I
started asking fellow coders from hlcoders mailing list. It was not
until I joined their IRC channel and talked with guy named omega, who
happened to have working render targets in his mod and willing to share
- huzzay I thought
After another few hours of work and cursing, the thing actually started
to work! Here are a few screens of dynamic scope on the A-280:
Looks
cool, doesn't it? The obvious disadvantage of this method over a simple
overlay is that all pixels in the view need to be drawn twice -
however, with current optimizations of Source Engine and moreover
multi-threaded Orange Box code, which is out there and waiting to be
merged with existing TNE codebase, the problem does not seem so acute
anymore and peformance decreases only slightly.