Ru/Detail props: Difference between revisions

From Valve Developer Community
< Ru
Jump to navigation Jump to search
No edit summary
No edit summary
Line 24: Line 24:
Detail props могут быть размещены в ручную в паре с [[prop_detail]] и [[prop_detail_sprite]] энтити, но это редкая практика.
Detail props могут быть размещены в ручную в паре с [[prop_detail]] и [[prop_detail_sprite]] энтити, но это редкая практика.


{{tip|Стандартный VBSP файл находится в root\detail.vbsp (например Half-life 2/ep2/detail.vbsp), но вы можете создать и свой собственный, только не забудьте изменить в Valve Hammer переменную “Detail vbsp file” во вкладке (Map > Map Properties…)
{{совет|Стандартный VBSP файл находится в root\detail.vbsp (например Half-life 2/ep2/detail.vbsp), но вы можете создать и свой собственный, только не забудьте изменить в Valve Hammer переменную “Detail vbsp file” во вкладке (Map > Map Properties…)
.}}
.}}


{{tip|Используйте брашевую энтити {{l4D add|[[func_detail_blocker]]}}  (впервые появился в Left 4 Dead) для подавления генерации detail sprites в нежелательных зонах.
{{совет|Используйте брашевую энтити {{l4D add|[[func_detail_blocker]]}}  (впервые появился в Left 4 Dead) для подавления генерации detail sprites в нежелательных зонах.
.}}
.}}


Line 217: Line 217:
: Это имя дитейла указанного в VMT материала <code>%detailtype</code>.
: Это имя дитейла указанного в VMT материала <code>%detailtype</code>.
:; <code>density <[[float]]></code>
:; <code>density <[[float]]></code>
:: Плотность генерации detail пропов на поверхности материала. {{tip|<code>Значение 1000000</code>означает, что на каждом юните будет по 1 пропу. Средняя плотность детейлов 1000-1500. (128 юнитов - 2 пропа - 256 плотность)
:: Плотность генерации detail пропов на поверхности материала. {{совет|<code>Значение 1000000</code>означает, что на каждом юните будет по 1 пропу. Средняя плотность детейлов 1000-1500. (128 юнитов - 2 пропа - 256 плотность)
}}
}}
; Group
; Group
Line 234: Line 234:
; <code>minangle <float></code>
; <code>minangle <float></code>
; <code>maxangle <float></code>
; <code>maxangle <float></code>
: Used to control emission on steep surfaces. Default values for both are 180 (no restriction). {{tip|By setting a high <code>minangle</code> you can target overhangs.}}
: Регулирует генерацию на крутых поверхностях. Стандартное значение для обоих 180 градусов (без ограничений). . {{совет|Если выставить 180 и 180 (min-max) Ваша трава будет расти даже на потолке. Если выставить 0 и 180, трава будет расти всюду, кроме потолка. 45 и 180, стена под косым углом ВНИЗ - редкая растительность. 180 и 45, стена под косым углом ВВЕРХ - редкая растительность. Значение 0 и 90 - трава только на земле и  склонах, но на прямой стене и потолке её не будет.
}}


==== Sprites ====
==== Sprites ====
Line 263: Line 264:
Detail shapes are only available in some games, for example [[Day of Defeat: Source]], [[Counter-Strike: Source]], [[Counter-Strike: Global Offensive]], [[Garry's Mod]] and the SDK source code. If you try to create shapes in a game without support for them, the detail props will not be created at all.
Detail shapes are only available in some games, for example [[Day of Defeat: Source]], [[Counter-Strike: Source]], [[Counter-Strike: Global Offensive]], [[Garry's Mod]] and the SDK source code. If you try to create shapes in a game without support for them, the detail props will not be created at all.


{{tip|To enable shapes in your mod, either compile with <code>SDK_DLL</code> or open <code>\game\client\detailobjectsystem.cpp</code> and remove the <code>#ifdef</code> from line 27.}}
{{совет|To enable shapes in your mod, either compile with <code>SDK_DLL</code> or open <code>\game\client\detailobjectsystem.cpp</code> and remove the <code>#ifdef</code> from line 27.}}


; <code>sprite_shape <choices></code>
; <code>sprite_shape <choices></code>
Line 272: Line 273:
:: Two sprites which cross over one another in the middle.
:: Two sprites which cross over one another in the middle.
; <code>sway <[[normal]]></code>
; <code>sway <[[normal]]></code>
: Percentage of <code>cl_detail_max_sway</code> that the prop bends to. {{tip|The prop doesn't need a <code>sprite_shape</code> to sway, but you ''do'' need shape support in your game.}}
: Percentage of <code>cl_detail_max_sway</code> that the prop bends to. {{совет|The prop doesn't need a <code>sprite_shape</code> to sway, but you ''do'' need shape support in your game.}}
; <code>shape_angle <[[float]]></code>
; <code>shape_angle <[[float]]></code>
: ''sprite_shape tri only.'' Number of degrees outward at which to angle the individual sprites. Unfortunately it is not possible to angle inward, for some reason! Useful range is 0-45.
: ''sprite_shape tri only.'' Number of degrees outward at which to angle the individual sprites. Unfortunately it is not possible to angle inward, for some reason! Useful range is 0-45.
Line 300: Line 301:
: A [[model]] to use; must be [[$staticprop]] and <code>[[UnlitGeneric]]</code> (ALL skins). Include <code>\models</code> and <code>.mdl</code> in the path.
: A [[model]] to use; must be [[$staticprop]] and <code>[[UnlitGeneric]]</code> (ALL skins). Include <code>\models</code> and <code>.mdl</code> in the path.


{{tip|To allow <code>[[VertexLitGeneric]]</code> models, open <code>game\client\detailobjectsystem.cpp</code>
{{совет|To allow <code>[[VertexLitGeneric]]</code> models, open <code>game\client\detailobjectsystem.cpp</code>
  and remove the conditional block from <code>CDetailObjectSystem::UnserializeModelDict()</code>.}}
  and remove the conditional block from <code>CDetailObjectSystem::UnserializeModelDict()</code>.}}



Revision as of 03:52, 2 February 2020

English (en)Русский (ru)Translate (Translate)
Detail prop на этом скриншоте взят из Dear Esther.
Detail props отражается на воде в Orion скрине. Обратите внимание на склон холма вдали, который находится за пределами затухания .
Detail props смешан с static props в Prison Island.

Detail props это дешевые, бесплотные объекты, которые случайным образом появляются на поверхности специальных материалов. Они исчезают из вида на определенном расстоянии от игрока (по умолчанию это 1200 юнитов). Это значит, что они годятся только для небольших объектов, таких как трава или прочая мелкая растительность.


Detail props бывает двух типов:


Спрайты
двух полигональный плоский квадрат, использующий параметр $translucent внутри материала. Объект может быть настроен так, чтобы он всегда “смотрел” в сторону камеры игрока, покачивался на ветру (что уже будет ресурсоемко) и прогибался под шагами идущего. Спрайт не может проходить сквозь водную поверхность.
Модели
3д модели следует использовать очень редко, если вообще использовать. Каждая модель расходует видео ресурсы DirectX, вне зависимости от того, сколько у модели полигонов, нагрузка всегда будет выше приемлемой.

Использование

Типы покрытия detail prop ("detail types") определяются скриптом файла .vbsp (Формат ANSI), и описаны в материалах с помощью параметра %detailtype. Затем VBSP рандомно генерирует detail props на поверхностях, покрытых этим материалом, при компиляции карты.

Detail props могут быть размещены в ручную в паре с prop_detail и prop_detail_sprite энтити, но это редкая практика.

Template:Совет

Template:Совет

Базовые типы detail

Эти типы detail доступны Source SDK Base:


Type View
swamp_land_002
grass01 Grass01.jpg
grass02 Grass02.jpg
coastline_grass01 Coastline grass01.jpg
coastline_grass02 Coastline grass02.jpg
coastline_redgrass01 Coastline redgrass01.jpg
coastline_redgrass02 Coastline redgrass02.jpg
coastline_redgrass03 Coastline redgrass03.jpg
citygrass01 Citygrass01.jpg
redgrass Redgrass.jpg
redgrass_light Redgrass light.jpg
short_redgrass Short redgrass.jpg
canal_reeds Canal reeds.jpg
PerfTest1
lostcoast_grass
lostcoast_grass2

Эти типы detail присутствуют, но доступны только на 3D моделях:

  • swamp_land_001
  • swamp_water_001
  • grassland1
  • grassland2
  • grassland3
  • rocks3
  • test
  • coast_pebbles
  • street_junk

Новые типы detail

Здесь отображен пользовательский VBSP файл. Требуется поддержка detail shape. используется эта текстура с этим шаблоном.

detail
{
	forest_floor_01
	{
		density 1600
		GrassTex
		{
			alpha 0
			RoseFlower
			{
				sprite "0 0 83 128 512"
				spritesize "0.5 0.05 7 13"
				spriterandomscale .3
				amount 0.02
				detailorientation 2
				sway 0.2
				upright 1
				maxangle 70
			}
			FernShrub
			{
				sprite "120 0 136 256 512"
				spritesize "0.5 0.05 17 28"
				spriterandomscale .15
				amount 0.03
				sprite_shape tri
				shape_size 0
				sway 0.3
				upright 1
				maxangle 50
			}
			GrassTuft
			{
				sprite "0 199 120 57 512"
				spritesize "0.5 0 20 10"
				spriterandomscale .2
				amount .6
				sprite_shape cross
				sway .1
				maxangle 95
			}
			PinkFlower
			{
				sprite "83 0 38 128 512"
				spritesize "0.5 0 6 18"
				spriterandomscale .1
				amount 0.02
				detailorientation 2
				sway 0.3
				upright 1
				maxangle 70
			}
			LushShrub
			{
				sprite "256 128 172 128 512"
				spritesize "0.5 0 32 21"
				spriterandomscale .3
				amount 0.01
				sprite_shape tri
				shape_size 0.1
				sway 0.1
				maxangle 40
			}
		}
		LeavesTex
		{
			alpha 1
			DriedGrass
			{
				sprite "256 0 92 120 512"
				spritesize "0.5 0 13 17"
				spriterandomscale .15
				amount .3
				sprite_shape cross
				sway .3
				maxangle 95
			}
			GrassTuft
			{
				sprite "0 199 120 57 512"
				spritesize "0.5 0 20 10"
				spriterandomscale .2
				amount .6
				sprite_shape cross
				sway .1
				maxangle 95
			}
			RoseFlower
			{
				sprite "0 0 83 128 512"
				spritesize "0.5 0.05 7 13"
				spriterandomscale .3
				amount 0.02
				detailorientation 2
				sway 0.2
				upright 1
				maxangle 70
			}
		}
	}
}

Простой Шаблон:

detail
{
	<Detail type>
	{
		density <float>

		<Group>
		{
			alpha <normal>

			<Prop>
			{
				<settings>
			}
		}
	}
}

Обозначение команд::

Detail type
Это имя дитейла указанного в VMT материала %detailtype.
density <float>
Плотность генерации detail пропов на поверхности материала. Template:Совет
Group
Даже если вам требуется определить всего один detail prop, вам все равно необходимо создать группу (group). Имя вряд ли где-то используется, оно нужно просто для справки.
Note.pngПримечание: поверхности Non-displacement используют только первую группу detail!
alpha <normal>
Значение сдвига alpha, при котором генерируется данная группа detail проп. Каждый раз при генерации detail проп VBSP выбирает группу с ближайшим значением alpha к текущему в данной локации (месте). Если alpha не определена, все группы появятся во всех областях.
Prop
Определяет detail prop. И хотя у него есть уникальное имя, нет возможности ссылаться на существующий проп позже в .VBSP: он должен быть переопределен всякий раз, когда он нужен. И все же использовать понятные имена это неплохая идея.

Prop настройки

amount <normal>
Доля от общего числа всех моделей (спрайтов) относительно указанной плотности из переменной density Обычно 0.1.
upright <bool>
Если указано (не важно какое значение) модель всегда будет “смотреть” вверх. Если переменной нет, модель будет ориентироваться относительно материала поверхности на которой она должна генерироваться. (расти из земли вертикально)
minangle <float>
maxangle <float>
Регулирует генерацию на крутых поверхностях. Стандартное значение для обоих 180 градусов (без ограничений). . Template:Совет

Sprites

sprite <int|X, Y, W, H, VTF width>
The subregion of the map's detail material to use for this prop.
  • X/Y are the top-left position
  • W/H are the dimensions of the prop in texels
  • VTF width is the X-axis resolution of the whole detail texture.
    Icon-Bug.pngБаг:In Valve's code any custom texture must be of the same aspect ratio as detail\detailsprites! Get the fix here.  [нужно проверить в ?]
spritesize <normal|U, V> <float|W, H>
The origin (U/V) and size in units (W/H) of the sprite when it is in the world.
spriterandomscale <normal>
The sprite's size will vary from 100% by this degree. A value of 1 means that the sprite could be generated at anything between 0% and 200% of its normal size.
detailOrientation <int>
How the sprite will react to the camera:
  • 0: It will not rotate.
  • 1: It will rotate around its origin to always face the camera head-on
  • 2: It will rotate around its Z-axis only to face the camera. This is the most common setting, as it foreshortens the sprite while keeping it otherwise head-on.

Shapes

sprite_shape tri
sprite_shape cross

Shapes are props where two or three sprites are arranged in a 3D shape. They can be made to sway as if in a breeze, and can bend away from intersecting players.

Warning.pngПредупреждение:Shapes place more load on the GPU, while sway places more load on the CPU. Use both as sparingly as possible. (The Dear Esther team have developed GPU-accelerated sway which is faster and more realistic, but their code is unreleased.)

Detail shapes are only available in some games, for example Day of Defeat: Source, Counter-Strike: Source, Counter-Strike: Global Offensive, Garry's Mod and the SDK source code. If you try to create shapes in a game without support for them, the detail props will not be created at all.

Template:Совет

sprite_shape <choices>
Creates a set of sprites at different angles, allowing for a pseudo-3D effect.
tri
Three sprites sitting equidistant from each other in a triangle formation.
cross
Two sprites which cross over one another in the middle.
sway <normal>
Percentage of cl_detail_max_sway that the prop bends to. Template:Совет
shape_angle <float>
sprite_shape tri only. Number of degrees outward at which to angle the individual sprites. Unfortunately it is not possible to angle inward, for some reason! Useful range is 0-45.
shape_size <normal>
sprite_shape tri only. Percentage of the sprites' width to put between them and the centre of the triangle. 0 means that the sprites cross at the prop's origin.

There are several console commands which affect shapes:

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.

If you can't find these, then there is no detail shape support.

Models

Remember that models have a performance overhead that sprites do not. Use them only when needed!

Good candidates for models are contiguous objects that need to spread out along the ground, like small rocks, fallen branches and ground-covering plants including ivy and brambles. Things that stand upright are better off as sprites or shapes.

model <string>
A model to use; must be $staticprop and UnlitGeneric (ALL skins). Include \models and .mdl in the path.

Template:Совет

New detail materials

The sample .VBSP's detail texture.

There are a few hoops to jump through when creating new detail sprite materials:

  • Leave at least a one-pixel gap between subregions, or you may find parts of one sprite bleeding over into the next.
  • The material must be UnlitGeneric. You'll probably want to use the $vertexcolor, $receiveflashlight, $nocull and $translucent parameters.
  • Unless you are overwriting detail\detailsprites.vmt, mappers must remember to select the correct material in Map > Map Properties....
Icon-Bug.pngБаг:In Valve's code, detail textures at custom locations must be of the same aspect ratio as detail\detailsprites. You can fix this if you are shipping your own binaries.  [нужно проверить в ?]

Blocking detail props

If you do not want to have detail props being generated in a specific area, use func_detail_blocker (Only available in Portal 2, Alien Swarm, Left 4 Dead 2, Counter-Strike: Global Offensive, and Garry's Mod.)