Random Sprite Placement

Tutorial collection, comprehensive listings on main site.

Random Sprite Placement

Postby Tutorial on Mon Mar 07, 2005 5:51 pm

category
General Half-Life 2/Other

description
Put plant sprites on your own textures.

keywords
random, sprite, grass, bush, bushes, place, placement.

OK, so in this tutorial I will tell you how to make the HL2 map compiler place sprites randomly on your displacement textures. This tutorial presumes you have looked at my previous one on making custom blending textures, although this is not 100% necessary.

So, to start, we make our own VMT file which consisted of this:

Code: Select all
"WorldVertexTransition"
{
   "$basetexture"    "brick/brickfloor001a"
   "$basetexture2" "concrete/concretefloor005a"
   "%tooltexture" "nature/blendsandgrass008a_tooltexture"
   "$detail" "overlays/macro01a"
   "$detailscale" .1
   "$basetexturetransform" "center .5 .5 scale 1 1 rotate 0 translate 0 0"
        "$basetexturetransform2" "center .5 .5 scale 1 1 rotate 0 translate 0 0"
        "%detailtype" "smiff_test"
}


Now, the important part of this is the "%detailtype". As you can see, mine is called smiff_test, but you can put whatever you want here. This %detailtype is linked to a file called "detail.vbsp" which is used by the compiler for the random sprite placement. So, make a detail.vbsp file in your SDK mod dir. mine is;

Code: Select all
D:\Steam\SteamApps\my@address.com\sourcesdk\hl2mp_sample_content


The contents of my detail.vbsp file is as follows:


Code: Select all
============= (these are just to break it up so you know where it starts ;P)

details

{

   smiff_test

   {

      "density" "500.0"

      Group1

      {

         "alpha" "1.0"

         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"

         }

            Model3

         {

            "sprite" "0 144 128 128 512"

            "spritesize" "0.5 0.0 23 30"

            "spriterandomscale" "0.2"

            "amount" "0.1"

            "detailOrientation" "2"

         }

      }

      
   }

}

=============== (end of the detail.vbsp)


Now, what this does, is tell the compiler which sprites, from the sprite file to use. Now, you might be saying "what sprite file??" well. HL2 has a default one, called detailsprites.vtf - Don't worry, you don't need to edit this file (although you could if you wanted...)

Image

That is a copy of what is contained within the file (without the pink numbers - they were for me!)

So, now I will explain the detail.vbsp file in more depth;

You make a group (in this case called smiff_test), inside this group is the information about the different groups of sprites to use. Each main group (smiff_test) can have a subgroup (group1) - and these subgroups can be filled with "models" (even though they are sprites - the random model placement doesnt seem to work

yet..)

This line;

Code: Select all
"sprite" "288 0 128 128 512"


is the important one for now.

The first number ( 288 ) is how many pixels across from the left hand side (the x axis), the compiler should start reading from. The next number is how many down from the top (y axis) it should start reading from.

The next 2 numbers are the size of the sprite, and the final number is the size of the detailsprite.vtf in pixels. But really, all we need are the first two numbers.

Now, take a look at the my sprite picture example. Each sprite is 128x128 pixesl and each sprite has a 16 pixel gap inbetween it. So, if you wanted the middle sprite (numbered 5) you would want these numbers;

Code: Select all
x axis = 128 + 16
y axis = 128 + 16


Which gives us 144 for both.

Code: Select all
"sprite" "144 144 128 128 512"


In theory, this would start reading from the label on the image (the really badly drawn star thing).

Another example, for the bottom middle sprite, we would want:

Code: Select all
x axis = 128 + 16 = 144
y axis = 128 + 16 + 128 + 16 = 288


So we'd end up with;

Code: Select all
"sprite" "144 144 128 128 512"



So. Thats the sprite line of the .vbsp file.....

Also "amount" is the percentage of this certain sprite that will be put on the terrain. For example, 0.1 would mean that 10% of the sprites would be this one. 0.2 would mean 20%.. etc etc. I'd guess having all of the amounts in a group adding up to one might be a good idea, though i've had no problems with it not (as in the above example!)

The others aren't really important for now, but you can look into them at:

http://www.valve-erc.com/srcsdk/Levels/prop_types.html
(right down the bottom)

Ok, so we've set up our 1st "group" called smiff_test - Inside smiff_test is group1, which contains 3 different sprites to scatter randomly about on our alpha painted displacement brush.

Have fun, and remember - don't be scared to experiment

And now, a screenshot of what you could come out with if you follow this and the last tutorial!

Image

(using my dodgy brick and concrete blend, and some random sprites)

Have Fun!

supersmithy
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Postby skidz on Sat Mar 26, 2005 1:09 am

awsome tutorial, now I can finally make a field full of grass :-D
~skidz
User avatar
skidz
Dumpling
Dumpling
 
Joined: Fri Jan 28, 2005 6:23 am

Postby M@sterT on Mon May 30, 2005 9:50 am

dont realy get this how do you actualy make the vmt files and were do you put them
M@sterT
Regular
Regular
 
Joined: Wed Nov 10, 2004 10:13 pm

Postby Grim Reaper on Mon May 30, 2005 1:07 pm

Are all those numbers and things in the tut coding?
Grim Reaper
May Contain Skills
May Contain Skills
 
Joined: Mon May 02, 2005 9:40 am
Location: Its this place, with air, and buildings, and there is lots of concrete...

Postby TheMiede on Tue Jun 21, 2005 8:52 pm

M@sterT wrote:dont realy get this how do you actualy make the vmt files and were do you put them


Same Question

How do u make a vmt file?
TheMiede
1337 p0st3r
1337 p0st3r
 
Joined: Wed Apr 20, 2005 4:11 am

Postby Spartan on Tue Jun 21, 2005 9:04 pm

Same Question

How do u make a vmt file?


With this program.

http://www.interlopers.net/downloads/fi ... v0_7_1.zip
Spartan
Veteran
Veteran
 
Joined: Sat Oct 09, 2004 2:58 pm

Postby TheMiede on Tue Jun 21, 2005 9:35 pm

Thanks
btw, what directory did u install it under

C:\Program Files\Valve\Steam\SteamApps\*****@********.com\half-life 2 deathmatch\

or

C:\Program Files\Valve\Steam\SteamApps\*******@******.com\half-life 2 deathmatch\hl2mp\

or

Insert Directory Here
TheMiede
1337 p0st3r
1337 p0st3r
 
Joined: Wed Apr 20, 2005 4:11 am

Postby A1armedassailant on Tue Jul 05, 2005 4:01 pm

ive noticed that certain textures(nature/grassblends/xxxxxxx...)have grass sprites already in them. as long as you dont use any displacement on the bruah they show just fine. however...once you create displacement on your terrain, they dissapear. why is this? and more importantly, how can i have the displacement, and keep the grass and weeds that are on the texture already?
anyone else ever wonder what we would look like without lips? not too pretty i think.
A1armedassailant
Regular
Regular
 
Joined: Wed Jun 29, 2005 7:07 am

Postby nefandus on Sat Sep 24, 2005 2:48 am

i keep getting this error in my log
----------------------
KeyValues Error: RecursiveLoadFromBuffer: got EOF instead of keyname in file detail.vbsp
detail, (*grass*), (*Group1*), (*Model3*),
----------------------
:? any one got any suggestions?
yeah just started fooling around with the sprite system anything you could do would help :-D
Image
I pitty the fool who messes with sdk!
User avatar
nefandus
Dumpling
Dumpling
 
Joined: Sat Sep 24, 2005 2:46 am
Location: Michigan, USA

Postby Hellraz0r on Wed Aug 02, 2006 3:44 am

WTF I DONT FUCKING GET WHAT TO DO
Hellraz0r
Pheropod
Pheropod
 
Joined: Sun Oct 23, 2005 10:42 pm

Postby wakey1512 on Sun Aug 06, 2006 4:07 pm

I dont either - it looks too complicated. Try and make things easier to understand next time.
wakey1512
Member
Member
 
Joined: Sat Aug 05, 2006 11:46 pm
Location: Weston super mare - Bristol

Postby FireMarshal on Sun Aug 13, 2006 5:54 pm

I think I fully have this down, but I don't know where to place the detail.vbmp file, I think this might be the only thing holding me up. I'm making a DoD:S map.

I found one in the "..../....@..../day of defeat source/dod" folder, and I picked one that looks interesting, and edited my custom grass blend vmt file (which works great) like so:

"WorldVertexTransition"

{

"$basetexture" "mycustom/mycustomgrass1"

"$basetexture2" "nature/dirtfloor013a"

"%tooltexture" "mycustom/mycustomgrass1"

"%keywords" "mycustom"

"%detailtype" "grass01"

}


I even tried placing the detail.vbsp file in various places, and it never worked, the sprites never showed up in game.
I'm new to mapping, be gentle!
FireMarshal
Just Joined
Just Joined
 
Joined: Sat Aug 12, 2006 8:50 pm

Postby Jeeves on Mon Jan 26, 2009 7:12 pm

Very useful tutorial.
Undue Punishment : 'An experimental FP Fighting game with stealth elements. ' -- TBD
Torn : 'A First Person RTS ' -- In Development as of 03/2014
Jeeves
Regular
Regular
 
Joined: Mon Sep 01, 2008 9:53 pm

Re: Random Sprite Placement

Postby arklansman on Mon Jan 26, 2009 10:08 pm

Detail.vbsp is usually in the mod/game's base folder, but it doesn't really matter because you can choose a detail.vbsp file in your map's properties.
I finally got around to changing my sig!
User avatar
arklansman
Regular
Regular
 
Joined: Mon May 21, 2007 11:39 pm
Location: USA

Return to Tutorials

Who is online

Users browsing this forum: No registered users