Counter-Strike 2 Workshop Tools/BreakableWindows: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(14 intermediate revisions by the same user not shown)
Line 2: Line 2:
{{note|This tutorial assumes a basic familiarity with [[ModelDoc Editor]].}}
{{note|This tutorial assumes a basic familiarity with [[ModelDoc Editor]].}}
{{Bug|func_breakable does not spawn gibs on break in {{cs2|4}}. It's recommended to use prop_dynamic instead}}
{{Bug|func_breakable does not spawn gibs on break in {{cs2|4}}. It's recommended to use prop_dynamic instead}}
{{important|Glass material should have dynamic expressions configured, otherwise there would be no break pieces.}}
{{warning|Window can only be in shape of a box.}}
{{todo|add screenshots with in depth explanation}}


example model can be found in {{path|Counter-Strike Global Offensive\content\csgo\workshop\content_examples\breakable_glass\breakable_glass_01|vmdl}}
example model can be found in {{path|Counter-Strike Global Offensive\content\csgo\workshop\content_examples\breakable_glass\breakable_glass_01|vmdl}}
Line 17: Line 18:
====RenderMeshFile====
====RenderMeshFile====


{{KV|intn=name|Name|string|Name of the node}} = "window"
 
{{KV|intn=filename|Source file|string|Model to render}} = <empty>
::{| class=standard-table
!  Property Name || Value
|-
| Name || window
|-
| Source file|| <none>
|}


=== Adding box primitive ===
=== Adding box primitive ===
#add '''Mesh Operation Stack''' node as parent of '''RenderMeshFile'''
#add '''Mesh Operation Stack''' node as parent of '''RenderMeshFile'''
#add [[Box Primitive]] as child of [[Mesh Operation Stack]] , set desired `Box dimensions` (x-thickness,y-width,z-height), but keep `Position` at [0,0,0], for this example, use {{path|workshop/content_examples/breakable_glass/breakable_glass_01|vmat}} material
#add [[Box Primitive]] as child of [[Mesh Operation Stack]] , set desired `Box dimensions` (x-thickness,y-width,z-height), but keep `Position` at [0,0,0], for this example, use {{path|workshop/content_examples/breakable_glass/breakable_glass_01|vmat}} material
{{important|Glass model should be facing forward in {{code|X+}} direction.}}
#add [[UV map planar custom]] stretch it so only single part of window texture fills model (you need to unselect this node and compile to preview how uv will look)
#add [[UV map planar custom]] stretch it so only single part of window texture fills model (you need to unselect this node and compile to preview how uv will look)
 
{{important|Model should be facing forward in {{code|X+}} direction.}}




=== Adding physic properties ===
=== Adding physic properties ===
====PhysicsHullFromRender====
*add '''PhysicsHullFromRender''' with following properties:
*add '''PhysicsHullFromRender''' with following properties:
{{KV|intn=surface_prop|Surface Property|string|Surface Property}} = "glass"
::{| class=standard-table
{{KV|intn=collision_prop|Collision Property|list|Collision Property}} = window
!  Property Name || Value
|-
| Surface Property || glass
|-
| Collision Property|| window
|}


====prop_data====
*add '''prop_data''' with following properties:
::{| class=standard-table
!  Property Name || Value
|-
| Base Prop || Glass.Window
|-
| Allow As Static Prop|| yes
|-
| Health || 1
|}


*add prop_data with following properties:
This will make sure that the prop can be used as '''prop_physics'''
{{Quote|;
:Base Prop: Glass.Window
:Allow as static prop: true
:Health: 1}}


== Adding Break pieces to model ==
== Adding Break pieces to model ==
todo
===Base setup===
Broken glass shards are done procedurally inside of modeldoc, to do that:
#add '''BreakPieceEmbedded''' to model.
#set the following properties:
::{| class=standard-table
!  Property Name || Value
|-
| Ragdoll Applies Bind Pose Root || no
|-
| Collision Group || Debris
|-
| Fade Time || 3
|-
| Essential Piece|| yes
|-
| Material Group Mode|| Inherit Material Index
|-
| Spawn Piece Motion Disabled|| yes
|-
| Piece Health Override|| 0
|}
{{note|It will show an error and will not let you compile the model, this would be fixed by adding '''RenderMeshFile'''.}}
*add empty '''RenderMeshFile''' as child of '''BreakPieceEmbedded''' same way as described in 1.1 of this tutorial, error should disappear. Name it something like "window_broken"
 
===Creating shattered glass model===
====RenderMeshFile====
::{| class=standard-table
!  Property Name || Value
|-
| Name || window_broken
|-
| Source file|| <none>
|}
 
*Add '''Mesh Operation Stack''' as child node
Now add the following operators to it:
=====Voronoi Plane Primitive=====
Uses voronoi noise to slice model
{{important|Сopy '''Bounding Dimensions''' from box primitive created earlier.}}
{{important|Glass material should have dynamic expressions configured, otherwise there would be no break pieces.}}
 
Example configuration
::{| class=standard-table
!  Property Name || Value
|-
| <span style="color: yellow;">Bounding Dimensions</span> || [Copy from box primitive, leave x=0]
|-
| <span style="color: yellow;">Material</span> ||
{{path|workshop/content_examples/breakable_glass/breakable_glass_01_broken|vmat}}
|-
| Number of Points || 64
|-
| Random Seed || 2
|-
| Weld Distance || 0.5
|-
| Bias to Center || 0.1
|-
| Shrink Pieces || 0
|-
| Extra Border Points || 1
|-
| Add center Vertex || no
|-
|}
======Inflate======
Create '''Inflate'''  as child node, used to give thickness to glass shards
::{| class=standard-table
!  Property Name || Value
|-
| Inflation Amount || 0.75
|-
| Build Sides || yes
|-
| Build Backfaces || yes
|-
|}
 
{{todo|Box Select/ Vertex sine wave for distortion}}
 
 
=====Select All=====
=====Assign Vertex Pivot Data=====
Used to assign material expressions to break pieces
{{todo|Explain material creation}}
== Creating custom glass material ==
== Creating custom glass material ==

Latest revision as of 00:37, 4 October 2024

Note.pngNote:This tutorial assumes a basic familiarity with ModelDoc Editor.
Icon-Bug.pngBug:func_breakable does not spawn gibs on break in Counter-Strike 2 Counter-Strike 2. It's recommended to use prop_dynamic instead  [todo tested in ?]
Warning.pngWarning:Window can only be in shape of a box.
Todo: add screenshots with in depth explanation

example model can be found in 🖿Counter-Strike Global Offensive\content\csgo\workshop\content_examples\breakable_glass\breakable_glass_01.vmdl

model doc outliner setup for breakable glass

Making base window model

Tip.pngTip:it is not needed to have custom model file since primitive shapes are created inside of ModelDoc

Adding a root node

  • add RenderMeshFile to model, cancel the file selection and press Keep on popup , It should appear as empty node, change RenderMeshFile Name to something like "window". This would be used as root node to add modifiers as child later. It should have the following parameters in inspector:

RenderMeshFile

Property Name Value
Name window
Source file <none>

Adding box primitive

  1. add Mesh Operation Stack node as parent of RenderMeshFile
  2. add Box Primitive as child of Mesh Operation Stack , set desired `Box dimensions` (x-thickness,y-width,z-height), but keep `Position` at [0,0,0], for this example, use 🖿workshop/content_examples/breakable_glass/breakable_glass_01.vmat material
  3. add UV map planar custom stretch it so only single part of window texture fills model (you need to unselect this node and compile to preview how uv will look)
Icon-Important.pngImportant:Model should be facing forward in X+ direction.


Adding physic properties

PhysicsHullFromRender

  • add PhysicsHullFromRender with following properties:
Property Name Value
Surface Property glass
Collision Property window

prop_data

  • add prop_data with following properties:
Property Name Value
Base Prop Glass.Window
Allow As Static Prop yes
Health 1

This will make sure that the prop can be used as prop_physics

Adding Break pieces to model

Base setup

Broken glass shards are done procedurally inside of modeldoc, to do that:

  1. add BreakPieceEmbedded to model.
  2. set the following properties:
Property Name Value
Ragdoll Applies Bind Pose Root no
Collision Group Debris
Fade Time 3
Essential Piece yes
Material Group Mode Inherit Material Index
Spawn Piece Motion Disabled yes
Piece Health Override 0
Note.pngNote:It will show an error and will not let you compile the model, this would be fixed by adding RenderMeshFile.
  • add empty RenderMeshFile as child of BreakPieceEmbedded same way as described in 1.1 of this tutorial, error should disappear. Name it something like "window_broken"

Creating shattered glass model

RenderMeshFile

Property Name Value
Name window_broken
Source file <none>
  • Add Mesh Operation Stack as child node

Now add the following operators to it:

Voronoi Plane Primitive

Uses voronoi noise to slice model

Icon-Important.pngImportant:Сopy Bounding Dimensions from box primitive created earlier.
Icon-Important.pngImportant:Glass material should have dynamic expressions configured, otherwise there would be no break pieces.

Example configuration

Property Name Value
Bounding Dimensions [Copy from box primitive, leave x=0]
Material

🖿workshop/content_examples/breakable_glass/breakable_glass_01_broken.vmat

Number of Points 64
Random Seed 2
Weld Distance 0.5
Bias to Center 0.1
Shrink Pieces 0
Extra Border Points 1
Add center Vertex no
Inflate

Create Inflate as child node, used to give thickness to glass shards

Property Name Value
Inflation Amount 0.75
Build Sides yes
Build Backfaces yes
Todo: Box Select/ Vertex sine wave for distortion


Select All
Assign Vertex Pivot Data

Used to assign material expressions to break pieces

Todo: Explain material creation

Creating custom glass material