script_intro

From Source Entities
Jump to navigation Jump to search
Both views in this scene are being rendered in realtime. One view is from the player's (the player and Gman are actually inside a black box together) and the other is from an entity moving around in the world.

Code classes:

Script intro blend modes.png

script_intro is a point entity present in the Hl2.pngHalf-Life 2 series and P2.pngPortal 2. This entity is used at some points in Half-Life 2 for special visual effects. It makes use of DirectX 9's Render-To-Texture features to blend together two views of the world. At minimum, the entity needs to be told where camera B is via SetCameraViewEntity (camera A is the player's regular view), and then Activated.

Tip: Valve used many moving light_dynamics in addition to these effects to make Gman look even trippier than usual.

Bug: Does not work properly on maps that contain 3D skyboxes. Depending on the engine version, they either won't be rendered at all (even in the player view), or worse, result in clipping of the 2D skyboxes, leaving the sky totally or partially black. To work around this problem, either don't use 3D skyboxes on the affected maps, or make sure the sky is not visible from the places where you intend to use this entity.

Fix: The skybox bug can be fixed by moving CSkyboxView's setup in CViewRender::RenderView() to occur after the secondary camera would be drawn in the intro scene, meaning it would be separated into one instance directly before CViewRender::ViewDrawScene() and another instance of the setup in CViewRender::ViewDrawScene_Intro() shortly after the m_bDrawPrimary block. Putting it right before g_pClientShadowMgr->PreRender() works. The clear color background should be removed as well, at least while the skybox is calculated to be visible.
Confirm: Does removing VIEW_CLEAR_COLOR cause VortWarp to stop working correctly?

Bug: Viewmodels, if present in the player view, are not rendered properly while script_intro is active (only the 2D parts are visible). One should make sure the player either does not possess any weapons, or is forced to hide them for the duration of the blend sequence.

Fix: Inside code, this can be fixed by disabling the regular call to CViewRender::DrawViewModels() in CViewRender::RenderView() when the script_intro is active and adding a separate call to CViewRender::ViewDrawScene_Intro() before intro_screenspaceeffect is composed. Putting it right after the main DrawWorldAndEntities works.

This is a list of the apparent function of the blend modes. These can be set in the entity by sending it SetNextBlendMode and SetNextBlendTime, or just SetBlendMode. To do: Descriptions are rough approximations which could use revising based on what's in the code.

  • 0: Camera A is normal color, camera B is inverted grayscale and brightened, multiplicatively blended (each pixel value in the resulting view is determined by multiplying the values of the corresponding pixels in A and B views). This is the default value.
  • 1: Camera A is inverted color, camera B is normal grayscale, additively blended (each pixel value in the resulting view is determined by adding up the values of the corresponding pixels in A and B views).
  • 2: Camera A is normal grayscale, camera B is normal color, multiplicatively blended.
  • 3: Camera A is normal grayscale, camera B is normal color. Mid-brightness pixels in camera A (not too dark, not too bright) become transparent and clearly show camera B pixels.
  • 4: Both A and B are normal color, otherwise the same as 3.
  • 5: Camera A is posterized color, camera B is normal color. The final view is only camera B, except for pure black pixels (exactly 0 0 0) which are replaced by camera A pixels.
  • 6: Both A and B are normal color, additively blended.
  • 7: Only camera B shows.
  • 8: Only camera A shows.
  • 9: Both A and B are normal color. Brighter pixels from camera B show mostly as camera B, but darker pixels show more and more of camera A.

Keyvalues[edit | edit source]

Match env_zoom's FOV transition (alternatefovchange) <boolean>
Makes the FOV blending use a spline blend like env_zoom does, instead of a simple linear blend. Zooming in/out will look noticeably smoother.

Inputs[edit | edit source]

Activate
Turns on the alternate view and blends between them.
Deactivate
Stops controlling the view.
SetCameraViewEntity <target_destination>
Sets what entity the camera B view should come from. Tip: Using point_viewcontrol, both cameras can be given the same view, although the effects aren't very interesting.
SetBlendMode <integer>
Sets how the two views should be blended together. See above.
SetNextBlendMode <integer>
Sets the blend mode that should be faded to. Follow this input with SetNextBlendTime.
SetNextBlendTime <float>
Sets how long the game should take to fade between the current blend mode and the one specified in the parameter of a SetNextBlendMode input, then starts fading to the new blend mode.
SetFOV <integer>
Sets the FOV of camera B. env_zoom can be used to control the FOV of camera A or both at once.
SetNextFOV <integer>
Sets the FOV that camera B should be zoomed to. Follow this input with SetFOVBlendTime.
SetFOVBlendTime <float>
Sets how long the game should take to zoom camera B from the current FOV to the one specified in the parameter of a SetNextFOV input, then stats zooming to the new FOV.
Bug: Always assumes the current FOV is the player's default setting.
SetFadeColor <color255>
Sets a color to apply across the whole screen, much like env_fade. Must be followed by a FadeTo input.
FadeTo <string>
Sets how strongly to apply the color specified in the parameter of a SetFadeColor input, and how quickly to fade the color in. Syntax is: <alpha> <duration>. The color will then fade in once sent.