Scripted textures

This is a way to draw pixels directly to a surface.

Note

When you draw to a texture, all surfaces using that texture will be updated. You will therefore need one ScriptedTexture per "canvas" you want to draw onto.

Prerequisites:

Script

First, create a controller that draws stuff:

class DynamicTextureController extends Info;

var() Texture ScriptedTexture;

simulated function PostPostBeginPlay()
{
    if(ScriptedTexture != None)
        ScriptedTexture(ScriptedTexture).NotifyActor = Self;
}

simulated function Destroyed()
{
    if(ScriptedTexture != None)
        ScriptedTexture(ScriptedTexture).NotifyActor = None;
}

simulated event RenderTexture(ScriptedTexture Tex)
{
    local Color Col;

    // Parameters: x, y, width, height, source x, source y, source width, source height, source texture, masked
    Tex.DrawTile(10, 40, 20, 20, 0, 0, 1, 1, Texture'Solid', False);

    Col.R = 255;
    Col.G = 255;
    Col.B = 255;

    Tex.DrawColoredText(20, 20, "TEST!", Font'FontMenuExtraLarge', Col);
}

defaultproperties
{
    RemoteRole=ROLE_SimulatedProxy
    bStatic=False
    bAlwaysRelevant=True
    bNoDelete=True
}


UnrealEd

  1. Create an instance of your DynamicTextureController in your map
  2. Import a 256x256 texture into a texture package (usable colours will be limited to those present in the palette)
  3. Create a new image in your texture package of the type "ScriptedTexture"
  4. In the new properties window, expand ScriptedTexture and set SourceTexture to the one you created in step 2
  5. Save your texture package
  6. Apply your ScriptedTexture onto a surface in your map
  7. Open the properties for your DynamicTextureController actor and assign the ScriptedTexture to the ScriptedTexture property
  8. Build and run

Overview

This is a little checklist to ensure everything is hooked up correctly.

Your texture package:

Your texture controller:

Your brush: