Welcome to PlagueFest.com! Log in or Sign up to interact with the Plague Fest community.
  1. Welcome Guest! to interact with the community and gain access to all the site's features.

Tutorial How To Create A Custom detail.vbsp

Discussion in Resources & Tutorials started by Tony the Tiger!! :D, Sep 7, 2013

  1. Feb 27, 2012
    Posts
    It took me a while to figure out how to do it this way and get all the calculations right. In this example, i will show you two different ways to make this VBSP. The first way will be pretty easy, and it will only use one custom texture/flower. The second way will use multiple textures/flowers and will take a little bit more work, and we will need to be doing a lot of calculations.

    Programs that I will be using:
    Photoshop CS5 (Find your own link :O)
    VTF Edit
    Windows Calculator
    Notepad++

    MAKE SURE YOU HAVE THE VTF PLUGIN FOR PHOTOSHOP: http://nemesis.thewavelength.net/index.php?c=154

    Part One: Single Texture
    To start, get all the images you want to use in your VBSP, in my case, i will be using these pretty little flowers that @sajak made. You MUST make sure they don't have a background, so if they do, start using your magic eraser tool or start clipping it out! Once you're done editing out the background, save it with a transparent background, which you can save it as a PNG or PSD (PSD being the Photoshop Format) NOTE: MAKE SURE YOUR IMAGE IS IN A POWER OF 2 DIMENSIONS (128x128 Pixels, 256x256, 512x512, 1024x1024, etc)

    If your image has multiple layers, make sure you merge them (select all layers, right click, merge layers.) Next, right click your layer (on the little image part of it), and click Select Pixels. When you do, it should have a dotted outline around your image. I like to make sure my image isn't right on the edge of the workspace, but it probably doesn't matter, i just like to be safe.
    [IMG]

    Next, you'll want to go to the channels tab (In between Layers and Paths on the right pane) and go all the way down to the bottom right corner. Click the New New Channel button (looks like a folded piece of paper) and it should create a channel called Alpha 1. Make sure you select the RGB channel again. I'm not sure if it matters, but i like to be safe.
    [IMG]

    Now, we're ready to save it as a VTF. Go to File>Save As and name it whatever you want. I prefer to name it detail_something.vtf, just to keep stuff organized. For this example, I'm going to save it as detail_flower.vtf. Make sure you change the format to VTF (should be near the bottom of the list.) Click save, and a menu should appear. On that menu, go to the Template drop down, and select Compressed Texture With Alpha. Now you can go ahead and close Photoshop. When it asks you if you want to save it, you can if you want, doesn't really matter, but it doesnt hurt to be safe (it did save it as a VTF already, but it wants you to save a PSD)

    Next, we're going to open up that VTF we just saved with VTFEdit. When you open it up, it will look like this
    [IMG]

    On the bottom right of the screen it shows you the co-ordinates of where your mouse is on the image. We will need this. Next we will need to open up Notepad++ and create a new file, and for this example, i'm going to call it detailflowers.vbsp.

    Here is an example template to start out with.
    Code:
    detail
    {
    		flower1 //Set detail material file for map to detail_flower.vtf to use.
    	{
    		"density" "750" //how often they appear inside material
     
    		Group1
    		{
    			"alpha" "1.0"
    		}
    		Group2
    		{
    			"alpha" "0.9"
    		}
    		Group3
    		{
    			"alpha" ".1"
     
    			Model1 //The Actual Flower Settings
    			{
    				"sprite"			"0 0 80 130 512"
    				"spritesize"		"0.5 0 15.5 26"
    				"spriterandomscale"	"0.3"
    				"amount"			"0.25"
    				"detailOrientation"	"2"
    			}
    		}
     
    	}
    }
    We will be changing the settings on the "sprite" line.

    "sprite" "0 0 80 130 512"

    This is what this means:
    "sprite" "Starting Coordinate X, Starting Coordinate Y, Length From Start X, Length from Start Y, Size of the VTF"

    So, our image starts at 0, 0, so we will leave it like that. You can edit the Size of the VTF now, in my case, it will be 256.

    Now we need to bring up out image and look at our coordinates. You will want to hold your mouse on the corner of the image, as close as you can, and look at your coordinates. I marked the mouse location with a little red dot, since Hyperdesktop doesn't screenshot my cursor. I also circled the coordinates.

    [IMG]

    This is where we edit our Length From Start X and Y. So now, our line will look like this:
    "sprite" "0 0 98 148 256"

    And our VBSP should look like this:
    [IMG]

    Save this somewhere, as the changes to this are complete.

    Next, we'll need to create a VMT File for our detail_flower.vtf, and we'll name it detail_flower.vmt
    Here is the template:
    Code:
    UnlitGeneric
    {
    	$baseTexture "detail\(vtf file name)"
    	$translucent 1
    	$nocull 1
    	$vertexcolor 1
    	$vertexalpha 1
    	$receiveflashlight 1
    	$singlepassflashlight 1
    }
    This is how mine will look in Notepad++
    [IMG]
    Again save this somewhere.

    Now we're going to start moving these files into the correct places.

    For the VBSP file, you'll want to move it to:
    C:\Program Files (x86)\Steam\SteamApps\common\Counter-Strike Source\cstrike
    For the VTF and VMT Files, you'll want to move them to:
    C:\Program Files (x86)\Steam\SteamApps\common\Counter-Strike Source\cstrike\materials\detail

    Now we need to open up Hammer and load our map. Next, make sure the area you want to have your custom VBSP file on is a displacement, as it will only show on displacements. Open up your material browser, and click once on the material you want to use. Click on Open source on the bottom of the material browser, and open it with Notepad or Notepad++, and add this flag after the last one on the VMT:
    "%detailtype" "(whatever your detail name is)"

    Your detail type is found in your VBSP, and in my case, i named it flower1, so it would look like this for me:
    [IMG]

    Last changes we have to make is setting our map to use the custom detail files. So navigate to the Map>Map Properties. We're going to change the Detail.vbsp File setting, and the Detail Material File setting. This is how it will look in my case.
    [IMG]

    Now we're ready to go and run our map. Let's get in game and see what it looks like!

    So i'm ingame, and the flowers successfully show up! So if you've followed everything correctly, yours should show up.
    [IMG]

    Part Two: Multiple Textures
    This is going to be very similar to Part One. Get all the textures you need together and make sure they don't have a background. Once you edit out your background, save it as a PNG or PSD. Now, start copy and pasting them into a new project in a power of 2 dimension, i will be using 512x512 pixel size, and i will be using 5 different flowers. When you place them onto the new workspace, make sure they have a decent amount of space between each other. Once you have everything on the same work piece, merge all of your layers.

    [IMG]

    Next we're going to Right click on the single layer and click Select Pixels (make sure you right click on the little picture part of the layer)
    [IMG]

    Next go to the channels tab, then go to the bottom right of photoshop and click Create New Channel button (looks like a folded piece of paper) and it will create an alpha mask. Then once that happens, select the RGB one again.

    [IMG]

    Now we can go ahead and save it and make sure to save it as a VTF, and when the menu appears select the template called Compressed Texture With Alpha
    [IMG]

    Now let's create our VBSP file. This one will be very different from the one in Part One.
    This is the template i will be using:

    Code:
    detail
    {
    	flower1 //Set detail material file for map to detail_flowers.vtf to use.
    	{
    		"density" "750" //how often they appear inside material
    		Group1
    		{
    			"alpha" ".1"
    			flower1
    			{	"sprite"			"0 0 0 0 512"
    				"spritesize"		"0.5 0 15.5 26"
    				"spriterandomscale"	"0.3"
    				"amount"			"0.25"
    				"detailOrientation"	"2"
    			}
    			flower2
    			{
    				"sprite"			"0 0 0 0 512"
    				"spritesize"		"0.5 0 15.5 26"
    				"spriterandomscale"	"0.3"
    				"amount"			"0.25"
    				"detailOrientation"	"2"
    			}
    			flower3
    			{
    				"sprite"			"0 0 0 0 512"
    				"spritesize"		"0.5 0 15.5 26"
    				"spriterandomscale"	"0.3"
    				"amount"			"0.25"
    				"detailOrientation"	"2"
    			}
    			flower4
    			{
    				"sprite"			"0 0 0 0 512"
    				"spritesize"		"0.5 0 15.5 26"
    				"spriterandomscale"	"0.3"
    				"amount"			"0.25"
    				"detailOrientation"	"2"
    			}
    			flower5
    			{
    				"sprite"			"0 0 0 0 512"
    				"spritesize"		"0.5 0 15.5 26"
    				"spriterandomscale"	"0.3"
    				"amount"			"0.25"
    				"detailOrientation"	"2"
    			}
    		}
    	}
    }
    For meaning on what the numbers mean under the "sprite" part, refer to this step in Part One.

    This is where all the calculating comes in, so open up your trusty calculator! Open up your VTF as well, we need to start finding coordinates. Our first one will be easy, so let's start with that. Using the coordinates that VTFEdit shows us at the bottom left, lets navigate our mouse to the bottom right corner of the mask of the first flower (for me the mask is blue, it could be any colour for you)
    [IMG]

    So with that, we will edit our first sprite line now. We will leave the first 2 zeros as zeros, as that's where this flower starts on the texture. We will replace the next 2 zeros with the coordinates we found at the bottom right of our screen.
    "sprite" "0 0 90 138 512"

    Now for the second one, and this is where we will need our calculator, or you can do it in your head, depending on how uneven your numbers are you might want to use the calculator. In this one, we will be changing the first zero to where this flower starts on the X (left to right) In my case, it's 103.
    [IMG]

    We won't need to change the 2nd zero, since it still starts at a Y of 0. We will need to change the next 2 zeros though. Point your cursor to the bottom right of the mask of that texture, and remember your X coordinate. I will have to subtract 103 from 191 in my case, and my Y coordinate will be 171. so 191-103=88, meaning my X Length with me 88.
    [IMG]

    This is how my sprite line will look for the second flower.
    "sprite" "103 0 88 171 512"

    The third flower is the same idea. Check how far over your X coordinate is, leave your Y coordinate 0, and then calculate your X length, and find your Y length. There will be no pictures for this one, because it's pretty much the exact same as the second flower. If i did this correctly, my line will look like this
    "sprite" "211 0 99 167 512"

    Next, is the 4th flower, which is a little bit different. This time we will be leave our first zero as a zero, and be changing the second one. Let's find out how far down the top of this flower is. For me, it is 196 pixels down, so that will be our Y starting point.
    [IMG]

    Next, lets find out how large this flower is by just like before, going to the bottom right of this flower.
    [IMG]

    Busting out our hand calculator, subtract 196 from 354 and you get 158. That will be our Y length, and 102 will be our X length, so it should look like this now:
    "sprite" "0 196 102 158 512"

    Now this one will be the most complicated. Find your X and Y starting points, which isn't too hard.
    [IMG]

    Now find your X and Y coordinate lengths of this flower.
    242 358
    [IMG]

    Now you're going to have to subtract 142 from 242, and 196 from 358. So that gets me 100 and 162. Lets put that into our VBSP, and it should look like this now.
    "sprite" "142 196 100 162 512"

    Finally! We're done with the hard part! Go ahead and save it somewhere safe, and now let's create our VMT file for this VTF. We'll be using the same template as in Part One.
    Code:
    UnlitGeneric
    {
    	$baseTexture "detail\(vtf file name)"
    	$translucent 1
    	$nocull 1
    	$vertexcolor 1
    	$vertexalpha 1
    	$receiveflashlight 1
    	$singlepassflashlight 1
    }
    Mine will look like this.
    [IMG]

    Save that somewhere safe, and lets get moving these files to their respective places!

    The VBSP file goes into this directory:
    C:\Program Files (x86)\Steam\SteamApps\common\Counter-Strike Source\cstrike
    And the VMT and VTF go into this directory:
    C:\Program Files (x86)\Steam\SteamApps\common\Counter-Strike Source\cstrike\materials\detail

    Now we can open up hammer and add our custom stuff to our map! So load up your map, and go to Map>Map Properties. and lets make our changes to the Detail.vbsp File setting and the Detail Material File setting, and rename it to the proper names of what we named our files.
    [IMG]

    Once that is done, open up your material browser, browse for the material you want to use it on, click on it once to select it, then click Open Source to open it in Notepad. Add this flag to the texture:
    "%detailtype" "(whatever your detail name is)"

    [IMG]

    Close the notepad, save changes, and lets run our map and see how sexy it looks!

    [IMG]

    That's it! If you did everything right, you should be able to see everything. If i made an error somewhere in this post, or missed a step or something, just let me know and i'll fix/add it.

    If you want to follow this guide exactly as a way to sort of teach yourself, here are the original PSD files i used.
    https://www.dropbox.com/s/zwepq7pbzwljb26/flowers.rar

    I hope this helped! :smile:

    Part Three: Resources
    If you want to do some playing around with VBSP files, here's a couple of links to some more information on them
    http://www.interlopers.net/tutorials/33402
    https://developer.valvesoftware.com/wiki/Detail_props
    Also, Tophattwaffle has a small tutorial on how to use already made VBSP files and whatnote.
    http://www.tophattwaffle.com/hammer-tutorial-47-sprites-on-world-spawn-detail-vbsp/
    • Mapping King Mapping King x 6
    • Useful Useful x 2
    • Like Like x 1
      Tony The Tiger, Sep 7, 2013 Last edited by Tony the Tiger!! :D, Sep 7, 2013
    • Feb 3, 2012
      Posts
      Thank you TonTon.
    • Feb 27, 2012
      Posts
      God damn you.
    • Feb 2, 2013
      Posts
      Merci beaucoup, TonTon.
      • Like Like x 1
      • Jun 11, 2012
        Posts
        Thank you TonTon for being so helpful

        [IMG]
        • Funny Funny x 3
        • Jul 8, 2012
          Posts
          TonTon! You're so helpful!
          • Agree Agree x 1
          • Apr 9, 2012
            Posts
            I used vbsp quite a lot lately, and this tutorial seems perfect for those unexperienced with it. Once you get the hang out of it it'll be a wonderful system, truly. For grass and such, it cheaply adds a lot of detail and realism to a scene.

            You can also add other options such as sway, but it becomes very quickly more heavy than anything else. Or also another very handy options for grass-like-sprites, you can add the option "upright 0 (or 1)" where with 0 or simply not adding it it'll orient itself at the angle of the face on the displacement it's sitting on, and with 1 it will always point upwards.

            Also, other common commands are "sprite_shape tri" to have a sprite existing out of 3 faces, rotated accordingly, or "sprite_shape cross" where it crosses one face with another in the middle.
            Great post!
            • Like Like x 2
            • Feb 27, 2012
              Posts
              Thanks Joris! :smile:

              Right now finished up the Part 2 of this tutorial, i've fucked it up somehow and i can't see my flowers, so i'm trying to figure out what i did wrong, lol. It's making me rather.... upset. According to my compile log, i get this error:
              Code:
              Valve Software - vbsp.exe (Jun 18 2013)
              4 threads
              materialPath: C:\Program Files (x86)\Steam\SteamApps\common\Counter-Strike Source\cstrike\materials
              Loading g:\users\p0p3y3z\documents\mapping\map files\test.vmf
              Could not locate 'GameData' key in c:\program files (x86)\steam\steamapps\common\counter-strike source\cstrike\gameinfo.txt
              fixing up env_cubemap materials on brush sides...
              KeyValues Error: RecursiveLoadFromBuffer:  got NULL key in file detailflowerss.vbsp
              detail, 
              It is almost the EXACT same as the one i made for sajak yesterday, since i pretty much just repeated what i did yesterday.
              [IMG]

              Can you see what i did wrong? Because i can't, and i'm getting irritated.
            • Apr 9, 2012
              Posts
              Not sure but if there's a NULL key there should be somewhere on a line either a forgotten " or a symbol like @ that is not recognized by the engine
            • Feb 27, 2012
              Posts
              For some reason it's reading it as a Macintosh file, and the working one as a Windows/Dos file... maybe that's my issue. Idfk how that happened. Lemme see if i can change it somehow.

              EDIT: BINGO! Idfk how it got to Macintosh format, but i just made a new text file, copy and pasted everything into it, and now it's working. Good thing i noticed that out of the corner of my eye. Time to finish this tutorial. :grin:
              Post Merged, Sep 7, 2013
              Finally done.

              I hate you all.
              • Funny Funny x 1
                Tony The Tiger, Sep 7, 2013 Last edited by Tony the Tiger!! :D, Sep 7, 2013
              • Jul 8, 2012
                Posts
                But TonTon...

                Sent from my SCH-R970 using Tapatalk 4
              • Jun 11, 2012
                Posts
                But TonTon you are so comfortable and I bet @Brettina would like to be inside you.

                [IMG]
                • Funny Funny x 2
                • Dec 6, 2011
                  Posts
                  Oh good, I thought I had to read this entire thread to get the joke. I was a little puzzled for a second.
                  • Funny Funny x 2
                  • Artistic Artistic x 1