Modifying entity effects

A great feature of the Source engine is the ability to control special entity properties such as render modes. We can dynamically change parameters such as the alpha, or transparency of entities. We can manipulate two overlapping light model's alpha to trick the player into believing a light model is actually casting light when the point light beneath it turns on. If a model has a skin, it can easily be changed by sending a skin = number input, but some entities don't have different skins so we need to play some tricks with the render modes.

Place a prop_dymanic entity on the ceiling above the light in the second room and name it room02_light01_mdl_off. Assign the prop_dynamic entity the light_domelight02_off.mdl model and change its render mode to solid.

The entity name might seem long, but following a consistent naming convention will help you will stay organized, and it could make your life much easier when your maps have lots of entities. Assigning the prop a render mode of solid will let us change the alpha property with triggers. Make a copy of the prop_dynamic entity by holding Shift and dragging it and rename it to room02_light01_mdl_on.

Assign the copied prop_dynamic the light_domelight02_on.mdl model and set the FX amount to 0. When FX amount of a solid-rendered model is 0, it will be invisible when the map is first loaded. When FX amount is 255, the model will be 100 percent opaque. Any value between these two values will render the model as semi-transparent.

Modifying entity effects

Rendering artifacts occur when multiple objects occupy the same planes. The preceding screenshot was taken within Hammer, but the same effect occurs within the game. We don't have to worry about this artifact occurring in game because our triggers prevent both models from rendering at the same time.

When the light is off, we want the on model to have an alpha target of 0, and we want the off model to have an alpha of 255.

Modifying entity effects

When the light is on, we want the on model to have an alpha of 255, and the off model to have an alpha of 0.

Tip

We can remove the off model from the world by passing the Kill input. Because this light is triggered via a trigger_once entity, the light will remain on permanently, and there is no reason to keep the off model anymore. Since prop_dynamic entities require a relatively large amount of resources, killing them can help the game run smoother. Passing the alpha parameter will keep the model in the map, and we will retain the ability to change the render states in the future.

Thus, we have not been using the Parameter Override field in our outputs because we have not triggered anything that required a parameter setting. When we send the alpha command to an entity, we need to specify the amount of alpha we want the model to render with. Placing a number between 0 and 255 into the parameter override field will control the render amount.

Modifying entity effects
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.35