S&box Wiki

Revision Difference

using_custom_sprites#547914

<cat>Dev.Particles</cat>⤶ <cat>Particle.Intro</cat>⤶ <title>Using custom sprites</title> ## Prerequisites All you need before we get started is your image file in `.tga`, `.psd`, `.png` or [.mks](https://developer.valvesoftware.com/wiki/Animated_Particles) format, placed somewhere inside your addon folder. <note>Both the width and height of your image file should be in the power of 2, otherwise the sprite won't render.</note> <note>If creating a sprite sheet, the maximum file size of the combined images in the sprite sheet cannot exceed 2mb, otherwise the engine will not compile the .vtex. This limitation may or may not have been changed or removed in s&box. Single-image .vtexs do not have this filesize/resolution limitation.</note> ## Creating the VTEX file The Particle Editor currently only renders sprites which are in `.vtex` format. To create your own `.vtex` sprite, copy the following code snippet into your favorite text editor, and change the `materials/snowflake.tga` value to point to your image file. ``` <!-- dmx encoding keyvalues2_noids 1 format vtex 1 --> "CDmeVtex" { "m_inputTextureArray" "element_array" [ "CDmeInputTexture" { "m_name" "string" "0" "m_fileName" "string" "materials/snowflake.tga" "m_colorSpace" "string" "srgb" "m_typeString" "string" "2D" } ] "m_outputTypeString" "string" "2D" "m_outputFormat" "string" "DXT5" "m_textureOutputChannelArray" "element_array" [ "CDmeTextureOutputChannel" { "m_inputTextureArray" "string_array" [ "0" ] "m_srcChannels" "string" "rgba" "m_dstChannels" "string" "rgba" "m_mipAlgorithm" "CDmeImageProcessor" { "m_algorithm" "string" "" "m_stringArg" "string" "" "m_vFloat4Arg" "vector4" "0 0 0 0" } "m_outputColorSpace" "string" "srgb" } ] } ``` Once you've changed the property, save it as a `.vtex` file. ## Selecting your sprite The `Render sprites` renderer has a property called `texture`, not to be confused with normal texture. Click the spyglass next to `texture` and select your sprite. You should now be able to see your custom sprite as pictured below: <upload src="3dc48/8d90821b106c7ec.png" size="373455" name="image.png" />