Sega 500 Precaching in UT2003 Jeff “Ezeikeil” Giles

Slides:



Advertisements
Similar presentations
Chapter 7 Constructors and Other Tools. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 7-2 Learning Objectives Constructors Definitions.
Advertisements

Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
An introduction to pointers in c
Stack & Queues COP 3502.
SE 313 – Computer Graphics Lecture 14: Armatures Lecturer: Gazihan Alankuş 1.
Asteroids Games and Simulations O-O Programming in Java The Walker School The Walker School – Games and Simulations
An Array-Based Implementation of the ADT List public class ListArrayBased implements ListInterface { private static final int MAX_LIST = 50; private Object.
Lists Introduction to Computing Science and Programming I.
Data Structures Topic #3. Today’s Agenda Ordered List ADTs –What are they –Discuss two different interpretations of an “ordered list” –Are manipulated.
Even More C Programming Pointers. Names and Addresses every variable has a location in memory. This memory location is uniquely determined by a memory.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
(c) University of Washingtonhashing-1 CSC 143 Java Hashing Set Implementation via Hashing.
Game Programming © Wiley Publishing All Rights Reserved. The L Line The Express Line to Learning L Line L.
Overview of Previous Lesson(s) Over View  OOP  A class is a data type that you define to suit customized application requirements.  A class can be.
11 A First Game Program Session Session Overview  Begin the creation of an arcade game  Learn software design techniques that apply to any form.
Python November 28, Unit 9+. Local and Global Variables There are two main types of variables in Python: local and global –The explanation of local and.
Variables, Functions & Parameter Passing CSci 588 Fall 2013 All material not from online sources copyright © Travis Desell, 2011.
Sega 500 More replication Jeff “Ezeikeil” Giles
Art 315 Lecture 5 Dr. J. Parker AB 606. Last time … We wrote our first program. We used a tool called GameMaker. The program we wrote causes a ball to.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Today  Table/List operations  Parallel Arrays  Efficiency and Big ‘O’  Searching.
Chapter 10 Strings, Searches, Sorts, and Modifications Midterm Review By Ben Razon AP Computer Science Period 3.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
IT253: Computer Organization Lecture 3: Memory and Bit Operations Tonga Institute of Higher Education.
Sega 500 Placing target boxes on the HUD Jeff “Ezeikeil” Giles
In the next step you will enter some data records into the table. This can be done easily using the ‘Data Browser’. The data browser can be accessed via.
English Conundrum s  In English, add “s” to end of word to make plural s  But for 1 special word, adding an “s” at the end:  Makes word go from plural.
CIT 590 Intro to Programming Lecture 4. Agenda Doubts from HW1 and HW2 Main function Break, quit, exit Function argument names, scope What is modularity!
Functions Introduction to Programming By Engr. Bilal Ahmad 1ITP by Engr. Bilal Ahmad.
Chapter 8 – Main Memory (Pgs ). Overview  Everything to do with memory is complicated by the fact that more than 1 program can be in memory.
Summer Computing Workshop. Introduction  Boolean Expressions – In programming, a Boolean expression is an expression that is either true or false. In.
Stacks. A stack is a data structure that holds a sequence of elements and stores and retrieves items in a last-in first- out manner (LIFO). This means.
Pointers Pointers are a unique class of variables whose purpose is to “point” to other variables Pointers allow programmers direct access to memory addresses.
Chapter 4 Grouping Objects. Flexible Sized Collections  When writing a program, we often need to be able to group objects into collections  It is typical.
1 Building Java Programs Chapter 7: Arrays These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may not be rehosted, sold, or.
Pointers: Basics. 2 What is a pointer? First of all, it is a variable, just like other variables you studied  So it has type, storage etc. Difference:
GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.
ArrayList By Neil Butcher. What is the difference between an ArrayList and an Array? An ArrayList is in many ways similar to an array, but has a few subtle.
Understanding Data Types and Collections Lesson 2.
Game Creation in XNA CS470 Final Project Chris Ragland.
Exceptions, cont’d. Factory Design Pattern COMP 401 Fall 2014 Lecture 12 9/30/2014.
1 How will execution time grow with SIZE? int array[SIZE]; int sum = 0; for (int i = 0 ; i < ; ++ i) { for (int j = 0 ; j < SIZE ; ++ j) { sum +=
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Computer Organization and Design Pointers, Arrays and Strings in C Montek Singh Sep 18, 2015 Lab 5 supplement.
Tutorial for Arrays and Lists. Description This presentation will cover the basics of using Arrays and Lists in an Alice world It uses a set of chickens.
Sega 500 Scripted events and Sequences Jeff “Ezeikeil” Giles
Week 12 - Friday.  What did we talk about last time?  Finished hunters and prey  Class variables  Constants  Class constants  Started Big Oh notation.
Sega 500 Combo Mutator Jeff “Ezeikeil” Giles
Variables and memory addresses
COMPUTER PROGRAMMING 2 ArrayLists. Objective/Essential Standard Essential Standard 3.00Apply Advanced Properties of Arrays Essential Indicator 3.02 Apply.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Chapter 7 Constructors and Other Tools Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Using the Eclipse Debugger Extra Help Session (Christina Aiello)
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
INF3110 Group 2 EXAM 2013 SOLUTIONS AND HINTS. But first, an example of compile-time and run-time type checking Imagine we have the following code. What.
1 How will execution time grow with SIZE? int array[SIZE]; int sum = 0; for (int i = 0 ; i < ; ++ i) { for (int j = 0 ; j < SIZE ; ++ j) { sum +=
Hello world !!! ASCII representation of hello.c.
Data Structures & Algorithms CHAPTER 2 Arrays Ms. Manal Al-Asmari.
F453 Module 8: Low Level Languages 8.1: Use of Computer Architecture.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Copyright © 2002 Pearson Education, Inc. Slide 1.
An Array-Based Implementation of the ADT List
Error Analysis Logic Errors.
Cheltenham Courseware
Some Assignments  Write a program which prints the following information about at least 5 persons: NAME MAIL-ID EMPLOYEE-CODE PHONE Eg. Umesh
How will execution time grow with SIZE?
Error Handling Summary of the next few pages: Error Handling Cursors.
Arrays in C.
Data Structures & Algorithms
Presentation transcript:

Sega 500 Precaching in UT2003 Jeff “Ezeikeil” Giles

Precaching Data As you no doubt have noticed, UT uses tones of textures, materials and meshes in the average game. And as you can well imagine, loading all these resources on the fly during runtime can be a bad idea.

Precaching Data But what happens when you absolutely have to create a complicated object at runtime? In a word….”Chug!!!”

Precaching Data What’s happening is, just like in C++, when an object is first created, all it variables have to be initialized and assets assigned. …and doing so can be a strain on the CPU.

Precaching Data What we see happen is that, for a brief second (sometimes more) the game seems to “hick-up” or pause as the data for this new object is loaded. And yeah…This can make game play suck!

Precaching Data So how do we prevent this from happening? Well the boys over at epic got clever on this one. They created functionality specifically to deal with this problem.

Precaching Data What do they do? The Precache ( pre-load ) the data into memory.

Precaching Data There are 2 key functions provided for this. AddPrecacheMaterial AddPrecacheStaticMesh

Behind the Scenes Both of these are defined in the LevelInfo class as simulated functions. Simulated, declares that a function may execute on the client-side when an actor is either a simulated proxy or an autonomous proxy. All functions that are both native and final are automatically simulated as well.

Behind the Scenes Looking at how it’s used simulated function AddPrecacheMaterial(Material mat) { local int Index; if (mat == None) return; Index = Level.PrecacheMaterials.Length; PrecacheMaterials.Insert(Index, 1); PrecacheMaterials[Index] = mat; }

Behind the Scenes Pass in the material we wish to store and it gets added to a list. Note that this list is a dynamically sized. Array. Index = Level.PrecacheMaterials.Length; PrecacheMaterials.Insert(Index, 1); PrecacheMaterials[Index] = mat;

Behind the Scenes It actually comes with Insert and remove functionality which is similar to the STL. Dynamic Arrays provide a way of having Static Array functionality with the ability to change the number of elements during run-time, in order to accommodate changing needs.

Behind the Scenes Insert(int index_to_insert_at, int how_many_elements_to_insert) – this allows us to tell the array to create more elements and create them starting at a specific location in the array. Inserting 5 elements at index 3 will shift up (in index value) all elements in the array starting at index 3 and up (shifting them up by the number of elements to insert).

Behind the Scenes Remove(int index_to_begin_removing_at, int how_many_elements_to_remove) – this allows us to remove a group of elements from the array starting at any valid index within the array. Note that any indexes that are higher than the range to be removed will have their index values changed, keep this in mind if you store index values into dynamic arrays.

Behind the Scenes Dynamic Arrays also have a variable called Length, which is the current length (number of elements) of the dynamic array. To access Length, using our example array, we would say -> IntList.Length.

Behind the Scenes We can not only read the Length variable, but we can also directly set it, allowing us to modify the number of elements in the array.

Behind the Scenes For more information on dynamic arrays, hit the UDN’s language reference. It’s all there

Bringing UT to it’s Knees Just to demonstrate the point, I’m going to do something I’d NEVER do for real. I’m going to load four 2048*2048 AND throw them at the screen at runtime when they are needed …not before.

Bringing UT to it’s Knees Watch that baby chug! I’m just going to create a simple game type with a custom trigger, that when tripped, all these textures get thrown to the screen.

Bringing UT to it’s Knees To further complicate things, I’m importing all the textures via the editor and not script to ensure that there is as little precaching as possible.

Bringing UT to it’s Knees Our textures. 2048*2048 bmp’s I all their butt ugly glory!

Bringing UT to it’s Knees To create a 21MB monstrosity! Import all these in via the editor and create a texture package.

Bringing UT to it’s Knees So in the HUD class, I add the following: function DrawHud(Canvas c) { super.DrawHud(c); if(showBigTextures) DrawBIGTextures(c); }

Bringing UT to it’s Knees At the other function if(DrawBIGTextures(canvas c) { c.SetPos(0,0); c.DrawIcon(texture'goober.bolt',0.16); c.DrawIcon(texture'goober.bolt1',0.08); c.DrawIcon(texture'goober.bolt2',0.04); c.DrawIcon(texture'goober.bolt2',0.02); }

Bringing UT to it’s Knees In effect just drawing these butt-ugly textures to the HUD if I’m touching a trigger. I simply us the Touch and untouch function calls…

Bringing UT to it’s Knees …And the Untouch function is almost exactly the same… So what happens? function Touch(actor Other) { super.Touch(other); if(other.IsA('pawn')) //one ugly cast to access the HUD PrecachHUD(playerController(pawn(other).Controller).myHud).ToggleBigTextures(); }

Bringing UT to it’s Knees The game totally lags out and hangs for about 3 seconds on my home box. An my PC is no slouch! And it still chugs!...HARD! P4 2.4gb cpu 533mhz fast bus 512 ddr ram G4 Ti ram

So what this means to us Even for a fairly powerful system, 21MB of textures is not a task to sneeze at as all this information still has to go from disk through the bus to the CPU then ram for processing by the game!

So what this means to us But notice that if I touch and untouch the trigger again and again, it doesn’t chug anymore. That’s because these textures are now in memory.

So what this means to us So how do we uses these new functions?

So what this means to us In my new HUD class I add the following prebeginplay function. (In the sample code it’s in the gametype…both work fine) simulated function PreBeginPlay() { Super.PreBeginPlay(); Level.AddPrecacheMaterial(Material'Goober.bolt'); Level.AddPrecacheMaterial(Material'Goober.bolt1'); Level.AddPrecacheMaterial(Material'Goober.bolt2'); Level.AddPrecacheMaterial(Material'Goober.bolt3'); }

So what this means to us In effect, we tell UT to load these textures into memory BEFORE the game starts. Watch it run now…

So what this means to us

It does still lags out a bit…but no where near as bad. In other words….precaching is your friend…especially for large objects.

How UT uses them If your curious to see how it’s used in UT2003 presently, look in the gametype classes (bombingrun, deathmatch…) for some good examples.

How UT uses them Remember, it’s good for both static meshes and materials (textures). Functionally doing the same thing.

End of Precache This should cover all your needs for precaching textures and meshes.