Text Decals for Signs etc.: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(Drop inapplicable mention of surface inspector, refer to textscale instead. Add pp, for photos)
Line 3: Line 3:




This article describes how to add non-graphic simple text to signs, signposts, walls etc. using gui decals. In this image you can see some examples. This method only provides the application of the text itself (ie, does not include the signs, signposts etc.) For the latter, one starting point is the model collection under darkmod/decorative/signs.
This article describes how to add non-graphic simple text to signs, signposts, walls etc. using gui decals. In this image you can see some examples. This method only provides the application of the text itself (ie, does not include the signs, signposts etc.) For the latter, one starting point is the model collection under darkmod/decorative/signs (avoiding any sign that has an embedded GUI).


<center>[[Image:text_decals.jpg]]</center><br><br>
<center>[[Image:text_decals.jpg]]</center><br><br>
Line 29: Line 29:
by Geep, 2020
by Geep, 2020


To change the size of the text:
To change the size of the text, just resize the patch. To do this, first press the TAB key. Remember to press TAB again to get back.
* Just resize the patch. To do this, first press the TAB key. Remember to press TAB again to get back.
* An alternative is to rescale the texture in Surface Inspector
* An alternative is to rescale the texture in Surface Inspector


Since you can't see the rendered text content results directly in DR, you will have to iterate to get what you want. The gui_parm1 value takes a single line of text (with no enveloping quotes). It is without a way to indicate line breaks; "\n" will not do it. The examples shown here rely entirely upon word-wrapping for multiline text. In practice, that means inserting spaces to force wordwrap (or see Tip below).
Since you can't see the rendered text content results directly in DR, you will have to iterate to get what you want. The gui_parm1 value takes a single line of text (with no enveloping quotes). It is without a way to indicate line breaks; "\n" will not do it. The examples shown here rely entirely upon word-wrapping for multiline text. In practice, that means inserting spaces to force wordwrap (or see Tip below).


Often, you need to resize the Entity GUI patch to cover a larger area than the visible sign; the patch size and aspect ratio will affect font size and aspect ratio, and wordwrap. The decal patch is non-solid and invisible - except for the text itself - so can overlap any visible surface with no problem.
Often, you need to resize the Entity GUI patch to cover a larger area than the visible sign; the patch size and aspect ratio will affect font size and aspect ratio, but not wordwrap and number of visible lines. The decal patch is non-solid and invisible - except for the text itself - so can overlap any visible surface with no problem.


You can offset the Entity GUI with respect to the underlying sign to adjust left and top margins, including to fake centering.
You can offset the Entity GUI with respect to the underlying sign to adjust left and top margins, including to fake centering.


Tip: Rather than relying on wordwrap for multilining, you can create multiple overlapping, offset Entity GUIs, one per desired line, and adjust them independently. This technique also allows different lines to have different fonts and/or scalings.
To demonstrate some of this, here's a series of signs on a wall, all of which have:
* the same empty wall plaque
* an Entity GUI with 1:2 ratio (so the aspect ratio of the font characters is kept constant)
* use of a common font family: Carleton
The top photo shows the series in DR, the second photo in-game. Each row of signs has the same Entity GUI size and placement. Each column of signs has the same text string and choice of font size. The top left sign is an plaque-centered placement of a 16x32 "Carleton" Entity GUI. This results in poor placement, so all the other signs move the upper-left corner of the Entity GUI down and slightly to the right. Going down the first column, as the Entity GUI becomes larger (20x40 in the 3rd row, 28x56 in the 4th row), the font enlarges proportionately to the Entity GUI size, so wordwrap is the same in all cases. In the second column, the text counts up to ten, but some of it is not rendered due to the Entity GUI boundary. Again, this line clipping is the same in all cases. The third and fourth columns repeat all that, but with the "Carleton Small" font. This allows both more words per line, and more lines. The specifics of those will vary with font family chosen.
[PHOTOS TO DO]
 
{{infobox|Tip: Rather than relying on wordwrap for multi-lining, you can create multiple overlapping, offset Entity GUIs, one per desired line, and adjust them independently. This technique also allows different lines to have different fonts and/or scalings.}}


==Customising and Making your Own==
==Customising and Making your Own==


To make your own text decals or customise the ones provided:
To make your own text decals or customise the ones provided (for instance, to use a different font size by changing the gui's "textscale" value):





Revision as of 22:00, 11 June 2020

From Fidcal's 2010 Posting. Updated by Geep, 2020.

Introduction

This article describes how to add non-graphic simple text to signs, signposts, walls etc. using gui decals. In this image you can see some examples. This method only provides the application of the text itself (ie, does not include the signs, signposts etc.) For the latter, one starting point is the model collection under darkmod/decorative/signs (avoiding any sign that has an embedded GUI).

Text decals.jpg



The assets used are provided from Dark Mod update 1.03 onward. But that is just a convenience; you can create your own easily (see #Customising and Making your own below.)

For other types of in-game text see Text


Ready-made Prefabs

This is by far the easiest method. You simply insert a prefab and change the default text and size to what you want:

  • This is described for the Dark Radiant editor.
  • For general use all you need do is to find or make your blank wall, sign, etc.
  • RMB in grid view, select "insert prefab", and navigate to readables/sign_text_decals/.
  • Select a prefab with a desired font (eg, sign_text_carleton.pfb) and one of two sizes (with or without "_small" suffix).
  • Of the Dark Mod fonts shown in Fonts Screenshots, two-thirds are available as prefabs; for others, see #Customising and Making your Own below.
  • You now have a working text decal, seen in DR as a blue rectangular "Entity GUI".
  • To set your text, change the spawnarg value gui_parm1 in Entity Inspector to whatever you want.
  • The defaults are all black text with 66% transparency so they blend well onto most surfaces but see #Customising and Making your Own below for how to change this.

Text Size, Text Composition, and Multi-line Text

by Geep, 2020

To change the size of the text, just resize the patch. To do this, first press the TAB key. Remember to press TAB again to get back.

  • An alternative is to rescale the texture in Surface Inspector

Since you can't see the rendered text content results directly in DR, you will have to iterate to get what you want. The gui_parm1 value takes a single line of text (with no enveloping quotes). It is without a way to indicate line breaks; "\n" will not do it. The examples shown here rely entirely upon word-wrapping for multiline text. In practice, that means inserting spaces to force wordwrap (or see Tip below).

Often, you need to resize the Entity GUI patch to cover a larger area than the visible sign; the patch size and aspect ratio will affect font size and aspect ratio, but not wordwrap and number of visible lines. The decal patch is non-solid and invisible - except for the text itself - so can overlap any visible surface with no problem.

You can offset the Entity GUI with respect to the underlying sign to adjust left and top margins, including to fake centering.

To demonstrate some of this, here's a series of signs on a wall, all of which have:

  • the same empty wall plaque
  • an Entity GUI with 1:2 ratio (so the aspect ratio of the font characters is kept constant)
  • use of a common font family: Carleton

The top photo shows the series in DR, the second photo in-game. Each row of signs has the same Entity GUI size and placement. Each column of signs has the same text string and choice of font size. The top left sign is an plaque-centered placement of a 16x32 "Carleton" Entity GUI. This results in poor placement, so all the other signs move the upper-left corner of the Entity GUI down and slightly to the right. Going down the first column, as the Entity GUI becomes larger (20x40 in the 3rd row, 28x56 in the 4th row), the font enlarges proportionately to the Entity GUI size, so wordwrap is the same in all cases. In the second column, the text counts up to ten, but some of it is not rendered due to the Entity GUI boundary. Again, this line clipping is the same in all cases. The third and fourth columns repeat all that, but with the "Carleton Small" font. This allows both more words per line, and more lines. The specifics of those will vary with font family chosen. [PHOTOS TO DO]

Tip: Rather than relying on wordwrap for multi-lining, you can create multiple overlapping, offset Entity GUIs, one per desired line, and adjust them independently. This technique also allows different lines to have different fonts and/or scalings.

Customising and Making your Own

To make your own text decals or customise the ones provided (for instance, to use a different font size by changing the gui's "textscale" value):


The Decal

  • Create a patch and give it the texture: textures/darkmod/decals/signs/decal_gui . This is only available fromDark Mod update 1.03 onward but if you want it earlier this is what to do:
    • Use textures/common/entityGui instead if it doesn't matter if the decal is solid.
    • Create the custom texture listed below at #Custom Texture
  • In Surface Inspector, use these in order: natural, fit, flip horizontal, rotate left 180 degrees.
  • You should now see a single occurrence of the words Entity GUI on the patch and the words should be upright and not mirrored. If not, adjust, rotate, until they do.
  • Note that the text size will be affected by the size of the patch
  • Convert the patch to a func_static entity
  • Give it the spawnarg gui with the path and name of your gui (see #The Gui below as its value.
  • Give it the spawnarg gui_parm1 with your own text as its value.


Note: Instead of using a hard-coded English text, consider using "#str_20000" and create a custom FM dictionary. See here for details.

The GUI

This is the gui file that defines the font. If you have Dark Mod update 1.03 you can modify an existing one. Alternatively, just copy and paste the one below into a text file and save it with your map in a guis folder as eg, my_stone_text.gui. You will need to add that path and name to the gui spawnarg of the decal entity above, eg, gui guis/my_stone_text.gui


windowDef Desktop
{
	rect 0, 0, 640, 480
	backcolor 0, 0, 0, 0

	windowDef SignText
	{
		rect 0, 0, 640,480
		backcolor 0, 0, 0, 0
		text	"gui::gui_parm1"
		font "fonts/stone"
		textscale 2
		forecolor 0, 0, 0, 0.8
		visible 1
	}
}

In the above definition, these are some of the things you can change:

  • Set your font in the font line as shown, it must be in quotation marks as above eg "fonts/stone". And to change the font just replace the word stone with the new font name - font choices are shown in Fonts Screenshots. Eg in my case Carleton - "fonts/carleton"
  • Change the font size in textscale. Fractions can be used, eg, 1.5 but remember, resizing the patch or texture scale in Dark Radiant also changes the font size.
  • Change the colour and transparency of the text in the forecolor line. Because of the way Doom 3 blends imagery, for all practical purposes this is limited to very dark colours because they do not react to local game lighting. If you choose lighter colours then they will glow in the dark. (it might be possible to match a colour to a static light situation.) The forecolor values are:
    • red, green, blue, transparency; each in the range 0 to 1.
    • For colours, 0 to 1 is zero to full intensity; for transparency it is invisible (0) to fully opaque (1)
    • For example:
      • 0.9, 0.9, 0, 1 would be high red, high green, no blue, and fully opaque. Red and green light make yellow so this would give glowing yellow text that would not blend well with its background.
      • 0.1, 0, 0, 0.66 This is more practical and would give a dark red that blends well onto its background with 66% opacity.
  • A background colour can be set with the backcolor line exactly the same as for forecolor but is probably of limited use for our purposes. 0.9, 0.9, 0, 1 would have the text on a solid bright yellow background that glows in the dark. 0, 0.1,0, 0.33 would give a faint green background of 33% opacity.

The Texture

This is the non-solid decal gui texture. Copy and paste it into a text file and save it with your map in a materials folder as eg, mymap.mtr. You will need to reload shaders if you already have Dark Radiant running before you can select it.

textures/mymap/decals/signs/decal_gui
{
	qer_editorimage	textures/editor/entityGui.tga
	DECAL_MACRO
	noShadows
	nonsolid
	noimpact
	discrete
	guiSurf	entity
}


See also