SubViewCam

Overview

SubViewCam is a material proxy within SMOD that is useful for 3D weapon scopes, as it directly copies the players view using what is presumed to be a render-target-texture (RTT.)

Example VMT

The follow code goes under the proxies section of your material file.

1
2
3
4
5
6
7
8
9
10
11
        "SubViewCam" {
            "ReplaceTexture"    "$basetexture"
            "OverlayTexture"    ""
            "DefaultAlpha"        "1"
            "SightedAlpha"        ".1"
            "BufferID"            "0"
            "Size"            "512"
            "FOV"            ".35"
            "Filter1"            ""
            "Filter2"            ""
        }

Line 1 is the line that specifies the proxy being used. In this case, "SubViewCam."
Line 2 is the texture the proxy will overwrite. Typically $basetexture is used, but a file-path to a material file may work as well.
Line 3 is the overlay texture that will display over the scope lens when the weapon is not being aimed. DBDB: Does this actually disable the proxy as well? Maybe make a highly translucent overlay texture to test this.
Line 4 is the default alpha value, this should remain at 1. DBDB: Test what this actually does, I have a good idea but I'm not sure.
Line 5 is the alpha value while aiming, this should remain as .1. DBDB: Ditto
Line 6 is the BufferID value. Presumably to choose which virtual buffer the RTT copies. It is not very wise to change this, and possible alternative values are not known.
Line 7 is the size of the render texture. This is a texture resolution like any other, thus only multiples of 2 should be used to avoid stretching.
Line 8 is a multiplier that adjusts (using the camera FOV value) the FOV of the SubViewCam effect. An easy way of getting magnifications you want is take the factor you wish to magnify by and use it as a divisor under 1 and converting the fraction into a decimal. Ex: 4x magnification : 1/4 = 0.25
Line 9 & 10 are filter textures that can be applied over the render texture that will also be hidden by the overlay (line 3.) Some shader files in the 'materials\shader' folder can be used (specifically, vm_* shaders). Basic textures, such as sprites, can also be used. Good uses for this are applying chromatic aberration and refraction effects (vm_cafilter and vm_lens respectively), and a crosshair reticule for the scope.

Use

The SubViewCam proxy was designed for use on a weapon models to provide a functioning three-dimensional weapon scope. When using this proxy on any weapon model, the texture it replaces must be properly UV mapped for the mesh it is applied to, or stretching and distortion will occur. When using this material proxy, your base texture it replaces should be compiled as UnlitGeneric or the scope will be rendered difficult to use due to shadows being cast over it. It is possible to use this on other models such as props, but a practical use for this has yet to be shown.

Bugs/Issues

SubViewCam has been reported to cause minor to major issues in it's use. These issues range from shadow-texture errors, where NPC render-to-texture shadows are replaced by those of random props in the map, to random and unexplained system crashes. There is no official diagnosis of these issues and it has been explained by the author of SMOD that the code is experimental.

Video Tutorial

YouTube and Bsnooch.com user Pepsifan042 has made a tutorial on setting up the SubViewCam proxy. The tutorial covers importing a scope mesh, UV-Mapping and separating the lens, and exporting using Milkshape 3D. Finally, it also explains the process of setting up the VMT file and material proxy settings. The tutorial even has a discussion thread on bsnooch.com, where you can ask questions about parts you don't understand.

Notes:

  • It seems as though the tutorial author is not a native English speaker, and it may be hard to understand him at times. Use the discussion thread above to ask any questions you may have.
  • It is not necessary to have a duplicate lens mesh for the crosshair texture, but there's nothing truly "wrong" with doing so. You can also use the "Filter" parameter(s) to specify your crosshair texture, as long as it is compiled as a sprite or a similar shader. DBDB: test which ones work.. maybe?
  • The overlay texture data doesn't need to be stored in the model (nor does it require another duplicate mesh), using the "overlay" parameter will automatically apply an overlay texture when not using iron-sights. However, this method requires that the texture is opaque, and it cannot use vertex shader effects such as cubemapping, refraction, or phong. To make use of those shader effects to simulate glare or reflections, a separate mesh would be necessary, and must be placed in front of the SubViewCam texture as shown in the video. Obviously, it must be translucent to some degree in order to see SubViewCam's effect and make proper use of the scope.


Customization

Mapadd Command Reference (Non-LUA)Command Reference (LUA)Getting StartedPorts 'n' Doors
Alarm, Alarm!Color Correction in SMODDoor BreachingMobile APCsWorking With Dropships
Supply Drop (LUA)Countdown (LUA)
kh0rn3's Mapadd Generator
Scripts addcontentsoverride_classsmod_custom_explosivesmodaclistSMOD Soundscripts

npc_gib_modelnpc_replace_modelnpc_shieldsetnpc_weapon_randomizenpc_weaponweight

excludeweaponsweapon_categoryweapon_customConsole Command List
Other Crosshair CustomizationGenerating AI NodesUsing the NodemakerSubViewCam
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License