textures


(fanny cradock) #1

ive downloaded some really nice textures that i want to incorperate into my map - how do i convert jpg and gif files into files that can be used in radient, ie shader files??


(Orange) #2

Ok, now here’s a familiar question… let me remember… ohh, of course, I asked the same question about a week ago…
In fact, you can use your jpg images without a shader and apply them in Radiant without a problem. (not sure about the GIFs, I think they should be converted to JPGs)
The point is that when you do this, you miss a wonderful new world - Shader’s world.
A shader is kind of code, or instructions, telling the game engine how to treat this texture (and sometimes even the brush with this texture).

= I am bit tired but I can’t leave you like this, so go get some coffee (or should I do it myself? nahh… I don’t drink coffee) and set your brain to receive mode =

This is a step by step guide for creating a shader! :claps:

  1. Open Notepad (quick way: Start>Run… type notepad and click Enter)
  2. File>Save As…
  3. Go into your Enemy Territory folder, then etmain and then scripts and save as yourmapname.shader

Now, let’s say you have a nice grass texture you want to use in your map. To add this texture to your shader:

  1. Copy that texture file (say ground.jpg) from wherever you have it to your Enemy Territory folder\etmain extures\yourmapname (create a new folder in the textures folder with your map name if you don’t already have one).
  2. In your shader file (yourmapname.shader we have created before) add those lines:

textures/yourmapname/ground
{
    qer_editorImage textures/yourmapname/grass.jpg
    {
        map textures/yourmapname/grass.jpg
    }
}

The first line is the name of the shader, or the texture. You should replace “yourmapname” with, surprise surprise, the name of your map! and “ground” with whatever you want to call this shader.
Second line just tells the engine that it is time to begin receiving the instructions for that shader.
Third line tells Radiant what image to display for that shader when you browse your shaders in Radiant.
Fourth line tells the engine again that it is time to receive more instructions.
Fifth line tells the engine what image to display in the game.
Sixth and seventh lines tells the engine to stop receiving instructions.

This is all nice and good, but it doesn’t really do anything… Now it’s time to think (I know it hurts but we have to…)
And so you think “What’s missing? what can I do with grass? I know! we can put landmines on it!”
If you want to let the poor engineers put landmines on your grass, all you have to do is to add the line “surfaceparm landmine” to your shader and walla! engineers can put landmines on your grass.
Since this is grass, we also want to make it sound like grass, so we add the line “surfaceparm grasssteps” and when you’ll step on your grass (you didn’t see the sign huh?) it will make sounds of grass.
The final result would look like this:


textures/yourmapname/ground
{
    surfaceparm grasssteps
    surfaceparm landmine

    qer_editorImage textures/yourmapname/grass.jpg
    {
        map textures/yourmapname/grass.jpg
    }
}

Now let’s say you have another nice texture you want to use, this time it’s a rocky terrain texture…
No problem, in the same yourmapname.shader you add another shader, just like the grass shader, but this time we are talking about rocks…
First, we want to make it sound like rocks, and second, we don’t want to let engineers put landmines on it.


textures/yourmapname/rocks
{
    surfaceparm gravelsteps

    qer_editorImage textures/yourmapname/rocks.jpg
    {
        map textures/yourmapname/rocks.jpg
    }
}

Very similar to the grass shader, we’ve just removed the “surfaceparm landmine” and replaced the grasssteps with gravelsteps to make it sound like the player is walking on rocks.

Now yourmapname.shader should look like this:


textures/yourmapname/ground
{
    surfaceparm grasssteps
    surfaceparm landmine

    qer_editorImage textures/yourmapname/grass.jpg
    {
        map textures/yourmapname/grass.jpg
    }
}

textures/yourmapname/rocks
{
    surfaceparm gravelsteps

    qer_editorImage textures/yourmapname/rocks.jpg
    {
        map textures/yourmapname/rocks.jpg
    }
}

Now you can save again (same filename) and there one more thing left to do: adding your shader to shaderlist.txt

  1. Open your Enemy Territory>etmain>scripts folder.
  2. You should see a file called shaderlist.txt, open it.
  3. Go to the end of the file and type yourmapname (I suppose you understand your map should have a unique name other than yourmapname…)
  4. Save the file and open gtkRadiant
  5. On the file, edit toolbar (forgot the name for this toolbar) go to Textures and if there is no “V” near “shaderlist.txt only” click on it.
  6. Go to Textures again and look for yourmapname (again…) in the list, if it’s there, click on it and you can start texturing until you forget your girlfriend’s name…
    If not, you probably didn’t saved shaderlist.txt after you added your map name to the list or you have the same problem I had. In this case you’ll have to open shaderlist.txt in a hex editor and add some strange character that you can only see in the hex editor after the last map name and before your’s

That’s it, I hope it’s not too confusing… anyway, I’ll go through it tommorow’s (or should I say today’s?) morning and see if I can make it friendlier…

(Look at me, helping people at 2:45 AM… crazy world, crazy me…)

Almost forgot, here is a helpful site that would help you write your shaders:
http://www.shaderlab.com/q3map2/shader_manual/contents.html

And this too:
http://www.sikstrom.nu/rikard/tuts/

And of course, Q3ASE which is a program that helps you create your shader:
http://www.bpeers.com/software/q3ase/index.html

A guide for using Q3ASE:
http://www.bpeers.com/software/q3ase/q3asetutorial.html

Good Night…


(Mr_Tickles) #3

Nice post Orange, you crazy 2:45am’er.
But back to the topic of creating custom textures…

To change a picture format into another, open your picture in a picture editing program, then “Save As” and change the extension to the required formats. I can’t remember off the top of my head whether or not MS Paint can save in .tga format, I don’t think it can. You can use either .jpg or .tga format. Personnally I use .tga as I seem to remember reading in a post a while back by Sock, that .tga’s give fewer problems while trying to manipulate the file… or something like that.
Also, you need to make sure that these textures are of a certain size. They have to be a power of 2 pixels - X^2 pixels high, by Y^2 pixels wide. I.e. acceptable heigts and widths could be 32x32, 128x128, they don’t have to be square either, 256x512, or 1024x64 would also be acceptable.

Remember that the picture files also have to tesselate appropriately if that is the purpose you have created them for, i.e. they need to be repeatable, with no seams showing, but that’s totally up to you. I’ve recently seen a piece of software called “Seamless Factory” which appears to do this with amazing ease… if you can be persuaded to register it that is. (I have not, and so can’t save creations from it… do’h, haven’t tried screenshotting what I get yet though ;)). Although, there is always Photoshop, Paint Shop Pro etc. if you want to fiddle about further with the images. I did a nice tutorial on reflecting the texure in both the x and y axes which then enabled perfect seamless repetition but not many people liked it, but if your images aren’t too complex you could try that. I would post a link to it, but the images have expired and i’m in Uni at the moment and do not have access to my pics ;). If you want to know what the in’s and out’s of that method were post a reply, or use the search tools, or just search my posts… Oh, the keywords being “Smarties” and “Tree”. I would say PM me but I don’t know when I’ll next be at a terminal, could be a month or more, but unlikely.

Once you have the images sorted out, you’ll need to put them in an appropriate folder. I was fiddling about with some custom textures the other night and was miffed when they didn’t show up in Radiant, I think I worked out that they need to be only one level of folders up from the base ‘textures’ folder, unless they are called by a shader.

If you have had Radiant running while doing all this, it may not pick up whether or not there are new textures for it, I don’t know. You could “Flush and Reload Shaders” but I am unsure as to this is only for shaders, or the entire bank of textures Radiant uses. Best to restart Radiant if they don’t appear.

Ok, once you have your texture in the appropriate place, then you can start to have a look at shaders… if you want to. They aren’t essential, but do offer a great range of possibilities from water ripples to simply not allowing bullet marks to adorn the surface.

Have fun :wink:


(=ds=bart) #4

i love nice clean answers to a question .
thx for that quick explanation off how to creat texture.
:clap: :clap: .
when i do my terrain with easygen and use a mineble texture .
thy wont work only when i apply it in radiant weird .

textures/zwam/terrain_0to1
{
	q3map_baseshader textures/zwam/terrain_base
	{
		map textures/desert_sd/sand_wave_desert.tga
		tcMod scale 0.066 0.066
	}
	{
		map textures/desert_sd/rock_edged_smooth.tga
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		alphaGen vertex
		tcMod scale 0.066 0.066
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
	}
}

textures/zwam/terrain_base
{
	q3map_lightmapaxis z
	q3map_lightmapmergable
	q3map_lightmapsize 512 512
	q3map_tcGen ivector ( 969 0 0 ) ( 0 969 0 )
}
textures/zwam/terrain_0
{
	q3map_baseshader textures/zwam/terrain_base
	surfaceparm landmine
	surfaceparm gravelsteps
	{
		map textures/desert_sd/sand_wave_desert.tga
		tcMod scale 0.066 0.066
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
	}
}

textures/zwam/terrain_1
{
	q3map_baseshader textures/zwam/terrain_base
	surfaceparm landmine
	surfaceparm gravelsteps
	{
		map textures/desert_sd/rock_edged_smooth.tga
		tcMod scale 0.066 0.066
	}
	{
		map $lightmap
		blendFunc GL_DST_COLOR GL_ZERO
	}
}

and i do have the line landmine


(G0-Gerbil) #5

Orange - your last example shader file is much better to be like this:

textures/yourmapname/ground 
{ 
    surfaceparm grasssteps 
    surfaceparm landmine 

    implicitmap -
} 

textures/yourmapname/rocks 
{ 
    surfaceparm gravelsteps 

    implicitmap -
}

Reasons being:

  1. Where the shader name matches the image being used, you don’t have to supply the qer_editorimage parameter.
  2. The shaders as you list them won’t have any lighting information.
  3. Using implicitmap is a shortcut way of saying ‘make this like a normal texture, including lightmapping’. It has a lot of defaults, but they are over-ridden by any parameters you explicitly set in the shader. If you do implicitmap - then it basically sets the default ‘map’ line to use the texture the same as the shader name. If you want to use a different texture, jsut replace the - with the path/filename like you would if you were specifying a ‘map’ line.

HTH.


(Orange) #6

Gerbil, you should write references…
From all the explanations I read about implicitMap, this was the best :slight_smile:
All the others were just talking about technical details you don’t really have to know…


(shazmax) #7

I’m not sure if Q3ase would output updated code for ET - more or less the new q2map


(Mr_Tickles) #8
textures/zwam/terrain_0to1 
{ 
   q3map_baseshader textures/zwam/terrain_base 
   { 
      map textures/desert_sd/sand_wave_desert.tga 
      tcMod scale 0.066 0.066 
   } 
   { 
      map textures/desert_sd/rock_edged_smooth.tga 
      blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA 
      alphaGen vertex 
      tcMod scale 0.066 0.066 
   } 
   { 
      map $lightmap 
      blendFunc GL_DST_COLOR GL_ZERO 
   } 
} 

textures/zwam/terrain_base 
{ 
   q3map_lightmapaxis z 
   q3map_lightmapmergable 
   q3map_lightmapsize 512 512 
   q3map_tcGen ivector ( 969 0 0 ) ( 0 969 0 ) 
} 
textures/zwam/terrain_0 
{ 
   q3map_baseshader textures/zwam/terrain_base 
   surfaceparm landmine 
   surfaceparm gravelsteps 
   { 
      map textures/desert_sd/sand_wave_desert.tga 
      tcMod scale 0.066 0.066 
   } 
   { 
      map $lightmap 
      blendFunc GL_DST_COLOR GL_ZERO 
   } 
} 

textures/zwam/terrain_1 
{ 
   q3map_baseshader textures/zwam/terrain_base 
   surfaceparm landmine 
   surfaceparm gravelsteps 
   { 
      map textures/desert_sd/rock_edged_smooth.tga 
      tcMod scale 0.066 0.066 
   } 
   { 
      map $lightmap 
      blendFunc GL_DST_COLOR GL_ZERO 
   } 
}

You should really put the base shader at the very top, above all the other sections that are calling it… i.e. the shader should look more like:

textures/zwam/terrain_base 
{ 
   q3map_lightmapaxis z 
   q3map_lightmapmergable 
   q3map_lightmapsize 512 512 
   q3map_tcGen ivector ( 969 0 0 ) ( 0 969 0 ) 
} 

textures/zwam/terrain_0to1 
{ 
   q3map_baseshader textures/zwam/terrain_base 
   { 
      map textures/desert_sd/sand_wave_desert.tga 
      tcMod scale 0.066 0.066 
   } 
   { 
      map textures/desert_sd/rock_edged_smooth.tga 
      blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA 
      alphaGen vertex 
      tcMod scale 0.066 0.066 
   } 
   { 
      map $lightmap 
      blendFunc GL_DST_COLOR GL_ZERO 
   } 
} 

textures/zwam/terrain_0 
{ 
   q3map_baseshader textures/zwam/terrain_base 
   surfaceparm landmine 
   surfaceparm gravelsteps 
   { 
      map textures/desert_sd/sand_wave_desert.tga 
      tcMod scale 0.066 0.066 
   } 
   { 
      map $lightmap 
      blendFunc GL_DST_COLOR GL_ZERO 
   } 
} 

textures/zwam/terrain_1 
{ 
   q3map_baseshader textures/zwam/terrain_base 
   surfaceparm landmine 
   surfaceparm gravelsteps 
   { 
      map textures/desert_sd/rock_edged_smooth.tga 
      tcMod scale 0.066 0.066 
   } 
   { 
      map $lightmap 
      blendFunc GL_DST_COLOR GL_ZERO 
   } 
}

Also, I think in another thread, someone posted that it should be “surfaceparm landmines” with the “s” on the end. Shaderlab is down at the moment so can’t check it :slight_smile:

Edit:

I’m in uni at the moment so can’t check my own shaders, but I think you may need to alter the placement of the other sections of the shader as follows aswell, although I may be wrong.

textures/zwam/terrain_base 
{ 
   q3map_lightmapaxis z 
   q3map_lightmapmergable 
   q3map_lightmapsize 512 512 
   q3map_tcGen ivector ( 969 0 0 ) ( 0 969 0 ) 
} 

textures/zwam/terrain_0 
{ 
   q3map_baseshader textures/zwam/terrain_base 
   surfaceparm landmine 
   surfaceparm gravelsteps 
   { 
      map textures/desert_sd/sand_wave_desert.tga 
      tcMod scale 0.066 0.066 
   } 
   { 
      map $lightmap 
      blendFunc GL_DST_COLOR GL_ZERO 
   } 
} 

textures/zwam/terrain_1 
{ 
   q3map_baseshader textures/zwam/terrain_base 
   surfaceparm landmine 
   surfaceparm gravelsteps 
   { 
      map textures/desert_sd/rock_edged_smooth.tga 
      tcMod scale 0.066 0.066 
   } 
   { 
      map $lightmap 
      blendFunc GL_DST_COLOR GL_ZERO 
   } 
}

textures/zwam/terrain_0to1 
{ 
   q3map_baseshader textures/zwam/terrain_base 
   { 
      map textures/desert_sd/sand_wave_desert.tga 
      tcMod scale 0.066 0.066 
   } 
   { 
      map textures/desert_sd/rock_edged_smooth.tga 
      blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA 
      alphaGen vertex 
      tcMod scale 0.066 0.066 
   } 
   { 
      map $lightmap 
      blendFunc GL_DST_COLOR GL_ZERO 
   } 
}