Skip to content

JSISteerableCamera

MOARdV edited this page May 25, 2016 · 2 revisions

The JSISteerableCamera background handler provides an enhanced camera, allowing buttons in IVA to control not only the camera zoom, but pan as well (aiming the camera side-to-side and up-and-down). Zoom and pan features are smooth and continuous while the associated buttons are held down. The JSISteerableCamera can also optionally display a target icon on the screen to indicate the direction of the current target. Post-processing effects shaders can be enabled, and their parameters controlled by RasterPropMonitor.

Multiple cameras (with different configurations) can be tied to JSISteerableCamera by listing multiple names in cameraTransform, separated by the pipe symbol '|'. The user can then cycle between the cameras by pressing the button associated with nextCamera or prevCamera.

			BACKGROUNDHANDLER
			{
				name = JSISteerableCamera
				... required settings omitted...
				cameraTransform=ExtCam1|ExtCam2
				fovLimits=40,60|10,60
				zoomRate=10|15
			}

In this example, the handler will use ExtCam1 and ExtCam2. ExtCam1 will have fovLimits of 40 and 60, while ExtCam2 has limits of 10 and 60. The zoom rates are 10 and 15, respectively. The cameraTransform list controls configuration of multiple cameras. If any of the other configuration parameters have longer lists (such as 4 zoom rates, but only 3 cameras configured), the extra parameters are ignored. Configuration parameters are applied in the same order as the camera names. If there are not enough configuration parameters, defaults will be used for the remaining cameras.

When the homeCrosshairColor parameter is set with a non-zero alpha value, a crosshair is drawn on the screen to indicate where the "home" position of the camera is. The home position represents the location where yaw and pitch are both zero. This crosshair also changes in size to represent the zoom level of the camera. The size of the crosshair is controlled by iconPixelSize. If the seekHome button is hooked up, pressing it will cause the camera to automatically center the crosshair.

The parameter skipMissingCameras can be used to have JSISteerableCamera automatically skip over missing cameras. This way, the user doesn't have to cycle over a bunch of blank screens to find functional cameras. If the missing camera later is found, it will show up again when the user selects next / previous camera. One application of this would be to have space station cameras listed on a ship's IVA, so the crew can use those station cameras when the ship's docked.

Caveats:

  • Cameras mounted on a ship can clip through the surface of the ship, which looks pretty bad. This is especially easy to see when using negative pitch values, so remember to check how things look at all of the pan extents.

  • This module makes use of global buttons. It needs at least one to do anything interactive, and really needs at least two.

      		BACKGROUNDHANDLER
      		{
      			name = JSISteerableCamera
      			method = RenderCamera
      			pageActiveMethod = PageActive
      			showNoSignal = yes
      			buttonClickMethod = ClickProcessor
      			buttonReleaseMethod = ReleaseProcessor
      			...configuration options go here.
      		}
    

Configuration options:

  • cameraInfoVarName -- An optional string naming a custom variable that will be used to contain information about which camera is active. See below for details.
  • cameraPixelSize -- An optional parameter listing the pixel size of the camera as width, height. This value can be different than the size of the display, for instance to make a low-resolution camera. When omitted, the camera inherits the size of the RasterPropMonitor module that includes it. Recommend sizes are powers-of-2 (eg, 128, 256, 512, etc). The width and height do not need to match, but if the camera aspect ratio does not match the display aspect ratio, the image will be distorted (stretched to fit).
  • cameraTransform -- Name of the camera transform that will be used to draw the background for the page. The reserved name CurrentReferenceDockingPortCamera also applies.
  • flickerChance, flickerRange -- Chance the camera has to randomly lose signal, defaults to zero. The syntax and rules are the same as for normal cameras.
  • fovLimits -- <maximum>,<minimum> the maximum and minimum field-of-view for the camera, in degrees. The default is (60, 60).
  • homeCrosshairColor -- The color of a crosshair that is drawn to mark the "home" position of the camera (where yaw and pitch are both zero).
  • iconPixelSize -- The size of the target icon.
  • nextCamera, prevCamera -- The globalButtons that will select the next camera or previous camera connected to this background handler.
  • pitchDown -- Number of the globalButton that will pan the camera down.
  • pitchLimits -- <up>,<down> the maximum amount the camera can pan up and down. Negative values are down. The down limit must be zero or less, while the up limit must be zero or more. The default is (0, 0).
  • pitchRate -- controls how quickly the camera pans up and down, in degrees-per-second. The default is 0.
  • pitchUp -- Number of the globalButton that will pan the camera up.
  • seekHome -- The globalButtons ID that will cause the current camera to seek "home" (return the yaw and pitch to the default 0 setting). It does not affect zoom (unless there's enough demand for that to reset, too).
  • showTargetIcon -- A Boolean (true/false) that controls whether an icon is drawn on the screen in the direction of the currently targeted item. Defaults to false.
  • skipMissingCameras -- A Boolean that controls whether this module will skip over missing cameras when selecting next/previous camera. When true, JSISteerable camera will automatically display the next/previous active camera, instead of a blank screen. If the camera later becomes available, it will be visible the next time it is selected.
  • targetIconColor -- The color of the target icon. Defaults to (255, 0, 255, 255) magenta.
  • toggleTargetIcon -- The number of the globalButton that toggles drawing the target icon.
  • yawLimits -- <left>,<right> the maximum amount the camera can pan to the left and right. Negative values are to the left. The left limit must be zero or less, while the right limit must be zero or more. The default is (0, 0).
  • yawLeft -- Number of the globalButton that will pan the camera left.
  • yawRate -- controls how quickly the camera pans from side-to-side, in degrees-per-second. The default is 0.
  • yawRight -- Number of the globalButton that will pan the camera right.
  • zoomIn -- Number of the globalButton that will zoom the camera in.
  • zoomOut -- Number of the globalButton that will zoom the camera out.
  • zoomRate -- controls how quickly the zoom transitions, in degrees-per-second. The default is 0.

Post-processing effects

RasterPropMonitor can use one of several different shaders to provide post-processing effects on the camera image. Each of these shaders is included in the RasterPropMonitor distribution, and each has one or more variables that can be adjusted in the config file, as described below. Post-processing effects are configured with three variables that go in the JSISteerableCamera config (the same as the parameters above):

  • cameraEffectShader -- The name of the RPM post-processing shader to apply (detailed below).
  • cameraEffectVariables -- A '|'-delimited list of shader variables and value pairs (eg, _Gain,MAPPED_RANDOM_GAIN|_Blend,RANDOM). The available variables are described with the shaders below.
  • cameraEffectTextures -- A '|'-delimited list of additional textures used by the shader comprised of shader variable and texture URL pairs (eg, _Noise,MOARdV/FlightSystemsRedux/FlightManagementSystem/noise). Again, the available variables are described with their shaders below.

As the examples above suggest, camera effect variables can use any Defined Variables or Custom Variables, in addition to using a constant value (_Gain,1.1).

Monochrome Shaders

Monochrome shaders convert the color image into either a grayscale image (like a black-and-white television) or a "green" image (like "night vision" effects). There are two monochrome shaders:

  • RPM/Grayscale
  • RPM/Greenscale

Variables:

  • _Gain - This variable controls the brightness of an image. By default, it is 1.0. Any value of 0 or higher is permitted. The _Gain value is multiplied by the brightness of the pixel to provide the final brightness, so a _Gain < 1.0 will make the image darker, while a _Gain of > 1.0 will make the image brighter (washing out details if it is high enough).

Textures:

None.

Blur Filter

This shader applies a 5x5 Gaussian Blur to the image, softening edges.

  • RPM/Blur

Variables:

  • _Gain - This variable controls the brightness of an image. By default, it is 1.0. Any value of 0 or higher is permitted. The _Gain value is multiplied by the brightness of the pixel to provide the final brightness, so a _Gain < 1.0 will make the image darker, while a _Gain of > 1.0 will make the image brighter (washing out details if it is high enough).

Textures:

None.

Noise Effect

This shader blends the camera view with a config-specific noise texture, allowing static and other effects involving blending another image with the camera view to be simulated (like maybe watermarking?). This shader has more configuration options.

  • RPM/Noise

Variables:

  • _Gain - This variable controls the brightness of an image. By default, it is 1.0. Any value of 0 or higher is permitted. The _Gain value is multiplied by the brightness of the pixel to provide the final brightness, so a _Gain < 1.0 will make the image darker, while a _Gain of > 1.0 will make the image brighter (washing out details if it is high enough). Gain is applied to the camera image - it does not affect the brightness of the noise.
  • _Blend - This variable controls the blending of the camera image with the noise texture. By default, it is 1.0. Any value between 0.0 and 1.0 is valid (values < 0 become 0, and values > 1 become 1). A Blend of 1.0 displays only the camera image, while a blend of 0 displays only the noise texture.
  • _NoiseOffset - This variable can be used to shift the noise texture vertically, so the noise changes from frame to frame. By default, it is 0.0. Reasonable values are between 0.0 and 1.0, although any number can be used (although very large numbers may cause the offset to stop working).

Textures:

  • _Noise - The URL of the noise texture to be blended with the camera view. The texture does not have to match the size of the camera view.

Example post-processing config

Assuming the rest of the JSISteerableCamera is set up correctly, the following will add a noise effect to the camera view.

cameraEffectShader = RPM/Noise
cameraEffectVariables = _Blend,MAPPED_MOARdV_BLEND_NOISE|_NoiseOffset,RANDOM
cameraEffectTextures = _Noise,MOARdV/FlightSystemsRedux/FlightManagementSystem/noise

With mapped variables defined elsewhere in the config file as

RPM_MAPPED_VARIABLE
{
   sourceVariable = RANDOM
   sourceRange = 0,1
   mappedVariable = MOARdV_BLEND_NOISE
   mappedRange = 0.75,0.9
}

This effect will apply some noise (10% to 25% noise, or 75% to 90% image, per MAPPED_MOARdV_BLEND_NOISE) to the camera image, with the noise texture randomly shifted vertically every single frame (defined variable RANDOM). The noise texture is at 'MOARdV/FlightSystemsRedux/FlightManagementSystem/noise'. Since _Gain was not specified, it defaults to 1.0.

Reading Camera Information Variables

NOTE: This feature is currently disabled.

When cameraInfoVarName is defined, the current JSISteerableCamera will record which camera is active each time the player changes active cameras. The index of the active camera is stored in a per-prop persistent variable, with the first camera identified as '1'. To access the value on the same prop (for instance, as a text overlay on top of the camera display), use the variable PROP_(cameraInfoVarName)_ID (eg, if cameraInfoVarName is "MyCamera", the variable would be "PROP_MyCamera_ID"). Note that this value applies only to the prop JSISteerableCamera is installed on. You are strongly encouraged not to use the same cameraInfoVarName on multiple pages on the same prop.