Difference between revisions of "Detail props"

From Valve Developer Community
Jump to: navigation, search
m
(SDK Beta implications)
Line 104: Line 104:
  
 
However, though Day of Defeat: Source has the necessary code for interpreting detail shapes, the current version of the SDK does not appear capable of correctly compiling detail shapes. It is likely that this will change in a future update to the SDK, which may also allow mod authors to use detail shapes in their mods.
 
However, though Day of Defeat: Source has the necessary code for interpreting detail shapes, the current version of the SDK does not appear capable of correctly compiling detail shapes. It is likely that this will change in a future update to the SDK, which may also allow mod authors to use detail shapes in their mods.
 +
 +
With the release of the latest [[SDK Beta]], the bundled compile tools can now correctly interpret the new configurations for setting detail shapes and will create the detail_prop entities accordingly. Note that this will only work for Day of Defeat: Source, as the other Source-based games have not yet been updated to handle the display of detail shapes.
  
 
==Types of Detail Shapes==
 
==Types of Detail Shapes==

Revision as of 06:07, 25 November 2005

Introduction

Models of type prop_detail can be set to be randomly emitted from surfaces based upon the material assigned to the surface. The file detail.vbsp describes detail prop groups. Each detail prop group specifies which prop_detail models are emitted from that group. A material can indicate which detail prop group is assigned to it by adding this line to the .vmt file:

%detailtype = "detail_group_name"

Where detail_group_name is the one of the detail prop group entries in detail.vbsp.

Usage

Here's an simple example of a detail prop group, as defined in detail.vbsp:

   swamp_grass_and_rocks 
   { 
      "density" "800.0" 
      Group1 
      { 
        "alpha" "1.0" 
        Model1 
        { 
           "model" "models/junk/rock1.mdl" 
           "amount" "0.3" 
        } 
        Model2 
        { 
           "model" "models/junk/rock2.mdl" 
           "amount" "0.3" 
        }    
      } 
      
      Group2 
      { 
        "alpha" "0.0" 
        Model1 
        { 
           "model" "models/foliage/Grass_tuft_003a.mdl" 
           "amount" "0.1" 
        } 
        Model2
        { 
           "model" "models/foliage/Grass_tuft_004b.mdl"
           "amount" "0.3"
        } 
      } 
   } 

"Density" describes how many points to randomly generate on all surfaces that have materials that use this detail prop group. Larger numbers will generate more detail props.

Then, you can specify as many groups of detail props as you like. Materials on non-displacement surfaces will only use one group, but displacement surfaces may use multiple groups. Each group specifies a list of the models that will be randomly emitted. The model fields above describe which studio model to use, and the "amount" field describes how many to emit relative to the other models in the list. For advanced users: If the amounts of all the models within a single group add up to less than 1, then the system will actually emit less than the maximum number of models described by "density".

The "alpha" field is only used for displacement surfaces. When a displacement surface is using a material that blends between two textures, the alpha describes how much of each texture to use. The detail system looks at that alpha to choose which group to select models from. For example, lets say you've got a displacement with two textures on it, one is road (alpha = 1 for the road) and the other is grass (alpha = 0 for the grass). In the example above, it would emit rocks on the road and grass tufts on the grass, since the group with "alpha" "1.0" contains rock models and the group with "alpha" "0.0" contains grass models. Note that you can make as many groups as you want; for example, if you were to add a group with "alpha" "0.5", this would create detail props using that group's models wherever the displacement is blending halfway between the rocks and grass.

Using the detail prop system with .MDLs can actually be fairly expensive owing to a high per-model overhead that currently exists in DirectX. To avoid this, you may also use sprites with the detail prop system, which doesn't have this overhead and is consequently at least 10x faster than using .MDLs. Here's how to specify a detail model group that uses detail sprites:

Group1
{
	"alpha" "1"
	Model1
	{
		"sprite" "288 0 128 128 512" 
		"spritesize" "0.5 0.0 19 25"
		"spriterandomscale" "0.2"
		"amount" "0.2"
		"detailOrientation" "2"
	}
	Model2
	{
		"sprite" "0 0 128 128 512"
		"spritesize" "0.5 0.0 23 30"
		"spriterandomscale" "0.2"
		"amount" "0.1"
		"detailOrientation" "2"
		}
}

The textures for detail sprites must all be placed in sub-regions of the texture "materials\detail\detailsprites.vtf".

The first two numbers in the "sprite" field shown above specify the (X, Y) coordinate of the upper left corner of the sprite as it lies within the detailsprite.vtf texture. The next two numbers specify the width and height of the sprite. The final number is the size of the detailsprite.vtf texture in pixels.

The first two numbers in the "spritesize" line specifies the rotational center of the detail sprite in normalized coordinates: (0,0) specifies the lower left, and (1,1) specifies the upper right. In the example above, the rotational center of the sprite is halfway along the lower edge of the sprite. The final two numbers in the "spritesize" line indicate the width and height of the sprite in world units when it gets drawn.

"spriterandomscale" specifies a random amount to scale the width and height of the detail sprite (in the example, the sprite will be between 80% and 120% of the size indicated in the "spritesize" line).

Finally, "detailOrientation" specifies how the detail sprite will move. A value of 0 indicates that it will not rotate; 1 means that it will always face the camera, and 2 means it will rotate around its Z-axis to try to face the camera as best it can.

Detail Shapes

Detail Shapes are a new way for the engine to place auto-emitted detail props on a surface, as specified by the detail.vbsp file. Introduced in the Day of Defeat: Source release, Detail Shapes allow normal sprites to be placed in a variety of shapes.

In addition, sprites can now have a "swaying" motion, where the sprite leans forward and back.

Finally, these sprites are capable of being "displaced". That is, they will move away from players upon contact and then bounce back to their original orientation. Note that sprites will continue to "sway" even when pushed out of their original position.

Usage

Currently, detail shapes only appear functional for Day of Defeat: Source. Other Source-based games lack the cl_detail_ console commands which appear necessary for the correct functioning of detail shapes.

However, though Day of Defeat: Source has the necessary code for interpreting detail shapes, the current version of the SDK does not appear capable of correctly compiling detail shapes. It is likely that this will change in a future update to the SDK, which may also allow mod authors to use detail shapes in their mods.

With the release of the latest SDK Beta, the bundled compile tools can now correctly interpret the new configurations for setting detail shapes and will create the detail_prop entities accordingly. Note that this will only work for Day of Defeat: Source, as the other Source-based games have not yet been updated to handle the display of detail shapes.

Types of Detail Shapes

Detail shape of "tri"
Another "tri"
Detail Shape Comment
cross "cross" This makes a criss-cross shape.


Places two sprites which cross over one-another in the middle.

triangle "tri" This makes a detail in the exploded prism shape .


Places three sprites sitting equidistant from each other in a triangle formation.


Refining Detail Shapes

There are several propeties for the detail.vbsp file which refine the shape of the detail sprites, as well as enhacing their aesthetic quality (such as the sway).


Propety Comment
"sway" Percentage of cl_detail_max_sway ( default 5 ).


Value: 0.0 => 1.0

"shape_angle" Specific to "tri" shape. Degrees to angle out each of the leaves.


Value: 0 => 90 (Untested)

"shape_size" Specific to "tri" shape. Percentage of sprite width to separate each leaf. near 0 for a triangle shape, near 1 for a closer, criss-cross shape.


Value: 0, 1 (Untested)


Related Console Commands

There are several client console commands you may use to alter the behavior of detail sprites.


Command Comment
"cl_detail_avoid_force" Force with which to avoid players.
"cl_detail_avoid_radius" Radius around sprite to avoid players.
"cl_detail_avoid_recover_speed" How fast to recover position after avoiding players.
"cl_detail_max_sway" Amplitude of the detail prop sway.