Speed up the 3D Application Production Pipeline
Dr. Oskar Guilbert
Head of Developer Relations, France
• Outline
– Criterion Software
– RW solutions – RW support – Products
• RW Studio
• RW AI
• RW graphics
• RW Physics
• RW Audio
– Graphics Training
• Familiarization with components
– Exporter
– Plugin example
• Platfom
– PC/XBOX/PS2/GC specificities
– HLSL pipeline example
Criterion Software Criterion Software
Created in 1993.
Offices in Guildford & Derby (UK), Austin (US), Tokyo and Paris.
More than 200 employees.
Two focused business units :
Criterion Games, our internal game development studio which already released 12 games. Used to work with Ubi Soft, Acclaim, Sony...
Criterion Software focused on middleware technology : RenderWare Platform and RenderWare Studio
A production-proven technology A production-proven technology
• More than 150 titles already released,
• More than 20 AAA,
• On current generation consoles and PC,
• 4 titles released with Ubi Soft
• More than 200 titles in current development,
With the main actors of our industry : Sony Computer Entertainment, Electronics Arts, Activision, Namco, Atari, CapCom, Konami, Midway, Take 2, Ubi Soft, Sega…
Christmas 2003 – Spring 2004 Christmas 2003 – Spring 2004
• Activision
– Call of Duty, The Movies
• Sega
– Sonic Heroes, HeadHunter: Redemption
• Rockstar
– Max Payne 2, ManHunt, Vice City XBox
• Lucas Art
– Secret Weapons Over Normandy
• Namco
– Dead To Rights 2, Kill.switch
• THQ
– BrokenSword: The Sleeping Dragon
• VUG
– ColdWinter
• Konami
– Turtles Ninjas
Criterion Fundamentals Criterion Fundamentals
An integrated development platform rather than a game engine :
- To build easily a game engine specific for each of your games, - To allow you to customize your tools respecting your workflow, - To allow you to concentrate on the special effects which will make your game unique ( lightmap for Rayman R, Specularity for Burnout 2,
Management of an important number of objects for GTA3 ...), - To build and increase the skill of the team
We are challenged on :
- Learning curve,
- Immediate « Waouu » effect and flashy demo,
A modular and complete solution A modular and complete solution
• Low level API for Rendering, Physic, Audio and AI.
• Authoring tools to build quickly your production workflow.
– Each component is independant and can be integrated with your own tools, – Each component is optimized to work with the other components.
A dedicated support team A dedicated support team
• 30 engineers dedicated to support our customers with a commitment of quality and delay.
• Support system helps us to respect our commitment and to keep a permanent communication with our customers,
• In Year 2003, +15K questions were posted on a worldwide basis :
• For 55 % the answer was given under 4 hours,
• For 40%, the answer was given under 24hours,
• For 5 %, the answer was given under 4 days,
PC Host
Target
Producers Artists
Programmers Designers
Management
Technology Overview Technology Overview
RenderWare Studio
RenderWare Studio
RenderWare Studio RenderWare Studio
• Acquired Realimation IP and engineering group in July 2000
• 2 years of design, R&D and feedback
• Staff of 25 developing RwStudio
• Shipped 1.0 in September 2002
• Next release: 2 in March 2003
Target Hardware
RenderWare Studio RenderWare Studio
• 3 Major Components
– Game Framework – Workspace
– Manager
Game Framework Game Code Manager
Workspace
Custom Developer
Tools
Custom Controls
RwStudio – Game Framework RwStudio – Game Framework
• Collaborative tool for
– Developers – Artists
– Game Designers – Producers
• Accelerate the game production pipeline :
– Share assets
– Tune in real time
– Game visibility from day 1
– Interactive preview on PC/XBOX/PS2/GC
RwStudio – Game Framework RwStudio – Game Framework
• Provides an application framework for developers to build their game on top of
• Think of it as an implementation of the Manager comms interface
– Class factory, resource management, memory manager, event system
• Abstracts hardware-specific and design-time details of comms and file systems
• Provides a set of functionalities
– Rendering, animation, particles, controllers, triggers, cameras
RwStudio – Workspace RwStudio – Workspace
• Development environment for editing game data, placing game objects, tweaking game attributes
• Soft user interface
– Dockable windows, stacked dialogs, floating palettes – Authoring tool for form design and scripting
– COM/VBScript-driven
• Hosts developer’s custom ActiveX controls
• Designed to be customized to the specifics of the game engine and developer’s workflow
RwStudio – Manager RwStudio – Manager
• Back-end of RwStudio
• Maintains game database
– Persisted in XML
– Asset-controlled by NXN AlienBrain
– Exposes data object model for access through COM or DLL
• Provides communications to running targets
– TCP/IP-based, connect to target anywhere
• Performs source-code parsing to generate list of available behaviors in game engine
RwStudio – Fundamentals RwStudio – Fundamentals
• Two-way, real-time connection to running game on multiple targets
• Automatic game editor UI generation via behavior source code mark-up
• Integrated asset management for team environments
• Encourages component-base game engine design (flexible)
• Encourages data-driven game engine design (content-oriented)
Renderware Studio demo : Renderware Studio demo :
• UI
• Examples framework
• Game Genre Pack : FPS
• Behavour structure
RenderWare AI
RenderWare AI
Game / simulation engine
Scenario Graphics Animations Kinematics
Sound
Behaviour
Network 3D engine
Sound engine Interfaces
Physic engine
Virtual Character behavior
Pathfinding
Perception
Emotions
Cooperation
Adaptability
Learning
…
RenderWare AI has been developed by RenderWare AI has been developed by
Kynogon, Criterion Software partner Kynogon, Criterion Software partner
for AI
for AI
To give behaviors to Non Player Characters To give behaviors to Non Player Characters via a fast and efficient production process via a fast and efficient production process
Perception Decision Action
Perception is key: bad perception leads to wrong behavior
Decision is only one part of NPC behavior
3D Pathfinding is the foundation of NPCs behavior
Understand situation Decide what to do Do it
NPC topology analysis is usually limited (blind man with a stick)
Games do not need completely autonomous NPCs (scenario)
Action portfolio must be rich enough to implement diverse behaviors
Production constraints
Production tools to accelerate production and empower game designers
High level performance
Multi-platform environment
Behavior generation paradigm
RenderWare AI 3.7 offers functionalities for RenderWare AI 3.7 offers functionalities for NPC in-depth perceptions
NPC in-depth perceptions
• Classic perceptions (see, hear, smell) including optimized visibility tests between entities
• Topology advanced understanding :
– Modeling: PathData automatic generation & edition – Advanced 3D topology analysis
Sound Demo Pathdata Generator Pathdata Editor AccessWays Demo
Sound Manager Automatic PathData
Generator PathData Editor 3D topology dynamic analysis
RenderWare AI 3.7 offers decision &
RenderWare AI 3.7 offers decision &
team functionalities team functionalities
• Scripting
– C brains support – C++ brains support
– LUA script brains support
• Team
– Dynamic team composition
– Communication between team-mates
Hide Team Demo
Team hide
Body Guards Demo
Body guards
Hide Team Demo
Hide & Shoot
Advanced 3D Pathfinding : dynamic constraints, Advanced 3D Pathfinding : dynamic constraints, game engine objects management and high level game engine objects management and high level performance
performance• Complex 3D topology support
• Advanced trajectory identification
– Shortest path – Stealthiest path
– Dangerous zone avoidance – Custom constraints support
• Multiple path following modes / multiple Heuristics modes
• Dynamic avoidance between entities.
• Dynamic PathObjects (doors, elevators, ladders, barrels, boxes, ...).
Constraints Demo Random Constraint Demo PathObjects Demo
Path constraints Random Path PathObjects
A set of ready-to-use agents (high A set of ready-to-use agents (high
level actions) level actions)
• Movement agents
– Goto – Follow – Flee – Wander – Follow path
– Hide (relative or absolute)
• Imitator agents
• Fighting agents
– Contact attacks – Shoot
• Custom agent support
• Formation (next release)
– Triangle – Column – Square
• Cooperation agents (next release)
– Body guards
– Opposite flank assault – Ambush
RwAi Demo
Agents
RenderWare AI has been designed for RenderWare AI has been designed for
high performances on consoles high performances on consoles
• Time-slicing mechanisms
• Customizable memory management
Spiders Demo
Spiders
RenderWare AI offers easy-to-use RenderWare AI offers easy-to-use
production tools production tools
• Architecture Configuration
• Automatic PathData Generator
• PathData Editor
• Automatic Behavior Generator via cloning
A powerful integration in RenderWare A powerful integration in RenderWare
Studio via RwAi toolkit Studio via RwAi toolkit
• Encapsulation of all RenderWare AI concepts inside RenderWare Studio behaviors
• Easy parameters edition of RenderWare AI in RenderWare Studio workspace including
runtime capabilities
• Integration of RenderWare AI tools in RenderWare Studio layouts
• Ready-to-use NPCs with AI capabilities
RwAi Toolkit default behaviors
RwsAiWorl d behavior
attributes
RwsAiWorl d Behavior
object
Specific game behaviors
for AI driven
NPCs
CAIMonste r AI behavior attributes (pathfindin
g)
CAIMonste r Behavior
object
RenderWare AI core technology can be split RenderWare AI core technology can be split into 4 layers open for customization
into 4 layers open for customization
Agents Elementary behavior (hide, go to, over-take)
Services CPU demanding algorithms
Algorithms shared by Agents
Decision
Articulation of agents
Script
Autonomous decision
Architecture
Integration
Performance
Openness
Layer Definition
behavior production
Automatic behavior generator through player cloning
data production
Automatic PathData generator
PathData Editor
Automatic CircuitData Generator
CircuitData editor
decision design
Script language compiler
Tools
Architecture configuration
Architecture configuration tool
RenderWare AI 3.7 represents a RenderWare AI 3.7 represents a
massive development massive development
• 4 platforms: PC (Windows & Linux), Playstation 2, Xbox, GameCube
• 8 compilers: Visual C++, Code Warrior, SN System, GCC
• 3 brains
• 6 tools
• 11 services
• More than 50 agents
• 200 script functions
• 200 parameters
• Over 600 pages of documentation
Next RenderWare AI release Next RenderWare AI release
• Racing functionalities
– Automatic CircuitData generation – Ergonomic CircuitData editor
– Automatic car characteristics extraction
– Trajectory computation
– Dynamic avoidance of other vehicles – Overtaking
• Streaming of pathfinding
• Finite State Machine
• On the shelf team behaviors
• Formation agents
Constraints Demo
PathData streaming
AccessWays Demo
local topology dynamic analysis
RenderWare AI is a multi-genre RenderWare AI is a multi-genre
technology technology
Automatic behavior generation via player cloning
3D pathfinding including:
Constraints (furtiveness, etc…)
Dynamic obstacle avoidance
Classic perception
Seeing
Hearing
Smelling
3D topology dynamic understanding
Modeling
Topology dynamic analysis
FPS Action/Adventur e
RTS / RPG Sport Racing
Speed
Over take
Follow path
Hide
Circuit perception
Circuit data automatic generation
Circuit data edition
Script
Team
Automatic pathdata generation
Pathdata edition
AI Configuration (CPU consumption, etc…)
Architectu re
Perceptio n
Decision Pathfindin
g &
Behavioral
Agents Shoot
Flee
Go to Follow character Team agents
Close combat
Formation
Fish tail
Bump
Path objects management (doors, etc…)
Streaming
Finite State Machine
Production process improvement Production process improvement
Selection
AI on critical path
Without RWAI
AI developments
Pre-prod Prod Tuning Test &
debug
On the shelf solutions
Open architecture
Parameter driven solutions
Production tools
With RWAI
Developments IA AI developments
PRODUCTION PROCESS
FOCUS ON CORE BUSINESS (application
dev.)
Earlier AI developments
Easy prototyping
More time for tuning
INCREASE PROFITABILITY
Innovative technology
Budget control
Flexible costs
AVOID EXPERTISE DEVELOPMENT
RISKS
Turnover
Feasability
Marketing constraints
INNOVATION
Dynamic 3D pathfinding
Complex topology
Automatic animation
Group strategy modeling
Emotion modeling
Automatic data generation
Automatic behavior generation
Etc…
Developer s hot buttons
RenderWare Graphics
RenderWare Graphics
RenderWare Graphics RenderWare Graphics
• Runtime Technology
– Rendering Pipelines – Low-level Services – Toolkits
• Toolchain Technology
– Exporters – Tools
RwGraphics – Rendering Pipelines RwGraphics – Rendering Pipelines
• General
– Static mesh, skinned mesh, multi-texturing
• Special-cased
– Cloning, particles, optimized lighting setups, reduced weight skinning, bezier patch primitives, lightmaps
• Platform-optimized
– Over 150 hand-written VU pipelines for the PS2 – Optimizing vertex/pixel shaders for DX9 and XBOX – Hand-optimized assembler pipelines for the
GameCube, hardware skinning when available
• Custom-built pipelines
RwGraphics – Low Level Services RwGraphics – Low Level Services
• DMA Manager with API
• Texture cache management
• Pipeline construction kit
• PDS pipeline delivery system
• Dynamic vertex buffer management
• Renderstate cache
• Native geometry/texture instancing
• Plug-in architecture
• Overloadable file system
• Overloadable memory manager with freelists and memory hinting
• Cameras, rasters, render targets
• Video-mode selection (including anti-aliased)
• Streaming toolkit
RwGraphics – Toolkits RwGraphics – Toolkits
• Animation
• Scene Management
• Platform-optimized file systems
• Streaming, asynchronous loading
• 2D shapes, animation, interactivity
• Particle Systems
• Math (quaternion, quantization, barycentric, splines, random, …)
• File-packaging (dictionaries)
• Intelligent Pipeline Selection
RwGraphics – Exporters for Artists RwGraphics – Exporters for Artists
• Support latest versions of Max and Maya
• Exports geometry,
animation, materials, lights, cameras, splines, user data
• Create partitioning hints
• Create particle effects
• Support dual-pass,
normal maps, emboss, environment maps,
toonshading, UV
animation, normal map
• Use standard materials or RenderWare materials
• Xbox and GameCube specific materials
• Support Bezier patches
• Preview on-target using Visualizer (with metrics)
• Use lightmaps generated by art package
• Scriptable
RwGraphics – Exporters for Programmers RwGraphics – Exporters for Programmers
• XML template-driven export settings (per-asset and per- project)
• Export directly to binary
runtime format (RWS) or to
intermediate XML format (RF3)
• Mipmap generation
• Customizable through OpenExport SDK
• Tri-stripping, partitioning, conditioning, UV limiting
• Platform-specific instancing
• Integration into build process
3D Model in Max or Maya
Intermediate XML
Runtime Binary Stream
Export Templates Textures
R U N T I M E Asset Compiler
RwGraphics Exporter
RwGraphics – Tools RwGraphics – Tools
• SWF-to-Maestro
• PVS editor
• Instancer
• Toonshader editor
• Xbox/GameCube Material Editors
• Visual Build Tool
• RF3 Compiler
• Light map editor
RenderWare Physics
RenderWare Physics
RenderWare Physics RenderWare Physics
• Partnership with MathEngine beginning in early 2002
• Acquired MathEngine IP and hired MathEngine engineers in June 2003
• Using MathEngine’s physics expertise and solver technology for RenderWare Physics
RwPhysics – Basics RwPhysics – Basics
• Rigid-body dynamics
• Constraint-based iterative solver
• Collision primitives
– Sphere, capsule, triangle, box, cylinder, plane, convex polyhedra
– Aggregates, grids, triangle lists
• Joint types
– Ball-and-socket, hinge, wheel hinge, zero-twist, universal, constrained angular, sliding/prismatic
• Pipeline-oriented physics step
– Find active pairs, generate contacts, partition, generate fixed volume contacts,
update velocities, update friction, update positions, find moving objects
• Pipeline steps are
optional, customizable
pipeline pipeline
Object
Manager Generate
candidate pairs find
intersections
Calc pos and vel corrections
Update pos and
velocity Render
RwpObjs Candidate pairs
ContactQuads
and joints Position changes and
forces
New TMs
RwPhysics – Features RwPhysics – Features
• Optimized ragdoll object based on particle physics
– 11 parts, 10 joints
– Joints are limited ball-and- socket or hinge
• Pre-built vehicle SDK
– optimized for speed not realism
– Get up-and-running quick with robust, stable vehicles
• VU0/CPU tightly synchronized
– VU0 in micromode
– Inner loop has no D$/I$ misses – Data completely stored in
scratchpad if under 320 row constraints
– GJK collision completely VU0 (faster than SCEI’s)
• x86 and SSE optimizations for data structures, loops
RenderWare Audio
RenderWare Audio
RenderWare Audio RenderWare Audio
• Dolby Digital (where available in hardware), Dolby Pro Logic I/II
• Streaming audio
– Multiple streams divided into multiple segments divided into multiple sub- streams
• Unlimited virtual voices
– Dynamically mapped to hardware voices based on audibility and/or priority
• Listener-oriented
– 2D
• Frequency, gain, pan (left- to-right)
– 3D adds…
• Position, velocity
• Minimum/maximum distance
• Doppler, reverb, roll-off
RwAudio – RwaEditor RwAudio – RwaEditor
• Converts WAVs to
platform-specific formats
• Packages wave dictionaries
• Assembles streams, segments, sub-streams
• Set audio format details
RW Graphics training RW Graphics training
• Familiarization with components
– Rendering core
– Plug-ins and toolkits – Exporter and visualizer
• Platforms
– Multiplatform architecture optimized for each platform – Specific features by platform (PC/XBOX/GC/PS2)
– DX9, Pixel/Vertex shader and HLSL support
• Code example : writing a HLSL pipeline
RenderWare Graphics Architecture RenderWare Graphics Architecture
• How the RenderWare Graphics library fits into a typical application.
Hardware RwCore RpWorld RW plugin
RW plugin
RW toolkit RW toolkit plugin toolkit Application
Rendering Core Rendering Core
• Glue that joins all the components together
– Stream management : RwStreamOpen, – Memory management : RwMalloc
• Basic rendering functionality.
– Engine initialization
• RwEngine
– Camera Management
• RwCamera
– …
• Platform specific rendering functions :
• RwD3D9CreateVertexBuffer
• RwD3D9IndexBufferCreate
• RwSkySetTrueCliper
• …
RenderWare Plugins
RenderWare Plugins
• RpADC Address Control flag generation• RpAnisot Anisotropy extension for extending textures
• RpCollision Collision-detection extensions
• RpDMorph Delta morphing and delta animation extensions
• RpHAnim Hierarchical animation plugin
• RpLODAtomic Level Of Detail extensions for RpWorld's "RpAtomic“ object
• RpLtMap Render geometry using detailed static lighting information from lightmap textures.
• RpMatFX Multi-pass special effects, such as environmental mapping, bump mapping, 2-pass
• RpMipmapKL Texture mipmap "K" and "L" value extensions
• RpMorph Morph-target animation extensions
• RpPatch Bézier patch rendering engine
• RpPrtStd Particle animation plugin
• RpPTank Creation, management and rendering of usercustomizable particles
• RpPVS Fast visibility culling extension for RpWorld, usingPotentially Visible Sets
• RpRandom Platform-neutral random number generator
• RpSkin Skinned model rendering extensions with multiple bone weights per vertex
• RpSpline Spline manipulation extensions
• RpUserData Provides functionality for storing user defined data with geometry
• RpUVAnim Attaches UV animations to materials
• RpWorld Provides RenderWare Graphics' Retained Mode API –specifically, the scene graph portion of it
• The keys to RenderWare Graphics extensibility.
• Extend existing objects in both the Core Library and other
Plugins – and add their own objects.
• RenderWare Graphics‘ high- level APIs are all implemented as Plugins.
Renderware Toolkits Renderware Toolkits
• Don’t extend but
• to make use of RenderWare
Graphics features.
– conversion – optimization – management
– on-line and off-line
Rt2d Advanced 2D Graphics API utilizing underlying 3D graphics hardware Rt2dAnim Animation of 2D objects
RtAnim Create, stream and play keyframe animation.
RtBary Mapping points between the barycentric space and Cartesian space RtBezPat Bézier patch generation utility library
RtBMP Microsoft® Windows® Bitmap image format handling RtCharset A bitmapped character library
RtCmpKey Keyframe system supporting compressed matrix animation RtDict Generic containers of named objects
RtFSyst File system manager and custom file systems RtGCond Geometry Conditioning
RtIntersection Polygon and line intersection testing functions RtLtMap Generation of lightmap textures - used with RpLtMap RtMipK Texture mipmap "K" value calculation functions RtPick Object-picking functions
RtPITexd Platform independent texture dictionary streaming RtPNG Portable Network Graphics image format handling RtQuat Quaternion manipulation functions
RtRAS Sun® Raster image format handling RtRay Ray-casting functions used for picking
RtSkinSplit Skin & Geometry splitter for large bone count models RtSlerp Spherical Linear Interpolation functions
RtSplinePVS Utility functions to allow PVS generation using spline paths RtTIFF Tag Image File Format image format handling
RtTile Tiled rendering functions (used mainly for very highresolution renderings)
RtTOC Table Of Contents for a stream RtVCAT Vertex Cache Aware Tri-stripper RtWing Winged edge/half-edge
RtWorld Utility functions to be used in conjunction with RpWorld RenderWare Graphics Architecture
RtWorldImport Utilities for creating RpWorld objects from foreign data formats
Using RW plugin Using RW plugin
• Use the default memory handler with freelists and set arena size : RwEngineInit( NULL, 0, resArenaSize)
• Attach plugins :
/* Attach Plugins */
if (!RpWorldPluginAttach()) {
/* Something went wrong so, */
/* either display an error message, */
/* or just crash.*/
return FALSE;
}
• Code to choose display device, format and other parameters :
RwEngineOpen(&openParams);
/* Start Engine */
RwEngineStart(); /* "We have ignition!" */
• With the plugins attached, calling their functions is now possible:
...
/* Render World */
RpWorldRender(); /* Render the RpWorld object. */
...
• As with toolkits, plugins also have to have associated libraries and header files that must be included in your build. Merely attaching them is not enough.
Creating your own Plugin Creating your own Plugin
• 2 parts :
– An exposed one : other developers will use
– Housekipping tasks : initialization, shutdown, memory allocation,
attachment to other plugins, steaming
• Extention vs Derivation
– Do we need to extend all the objects ? (add physic data to physical and not physical objects)
– A new object can be created only if necessary
Plugin Attach Plugin Attach
RpClumpPhysicsPluginAttach(void) {
RwInt32 offset;
/*
* Register global space...
*/
GlobalOffset = RwEngineRegisterPlugin(sizeof(PhysicsGlobals),
MAKECHUNKID(rwVENDORID_CRITERIONTK, rwID_EXAMPLE), PhysicsGlobalDataConstructor,
PhysicsGlobalDataDestructor);
if( GlobalOffset < 0 ) return FALSE;
/*
* Register clump extension space...
*/
LocalOffset = RpClumpRegisterPlugin(sizeof(PhysicsLocals),
MAKECHUNKID(rwVENDORID_CRITERIONTK, rwID_EXAMPLE), PhysicsDataConstructor,
PhysicsDataDestructor, PhysicsDataCopier);
if( LocalOffset < 0 ) return FALSE;
/*
* Register binary stream functionality for extension data...
*/
offset = -1;
offset = RpClumpRegisterPluginStream(
MAKECHUNKID(rwVENDORID_CRITERIONTK, rwID_EXAMPLE), PhysicsDataReadStream,
PhysicsDataWriteStream, PhysicsDataGetStreamSize);
if( offset != LocalOffset ) return FALSE return TRUE;
}
Constructor Exemple Constructor Exemple
#define PHYSICSLOCAL(clump, var) (RWPLUGINOFFSET(PhysicsLocals, clump, LocalOffset)->var) static void *
PhysicsDataConstructor(void *clump,
RwInt32 offset __RWUNUSED__, RwInt32 size __RWUNUSED__) {
if( LocalOffset > 0 ) {
PHYSICSLOCAL(clump, speed) = 0.0f;
PHYSICSLOCAL(clump, bounciness) = 0.0f;
PHYSICSLOCAL(clump, active) = TRUE;
}
return clump;
}
Exporter and Visualizer Exporter and Visualizer
• Template files modification by the UI
• Scripting
RenderWare_Exporter.AssetMgr.SetCustomizedAssets(true) select $MyCharectorRoot
-- Create asset of the current selection
myAsset = RenderWare_Exporter.AssetMgr.CreateAsset() -- Change the name of the asset so we know it's special.
myAsset.baseObject.name = "Script created Asset 01“
-- Change the template of the asset.
myAsset.template_name = "Animated Hierarchy.rwt“
-- Change the options of the asset to animated hierarchy options, setting a start and end animation time.
myAsset.options = #("INT:EXPORTENDTIME=40", "INT:EXPORTSTARTTIME=20")
• Exporter API
– Filter
– Scene graph modification, …
• How to extend the exported datas :
– Plugin with the api (exemples) – User data (by script)
-- export data for an object
custAttributes.add $Box01 myattrib
$Box01.mydata.TargetApp = "RenderWare"
$Box01.mydata.DataType = "Object"
$Box01.mydata.myint = 1
$Box01.mydata.myfloat = 2.5
$Box01.mydata.mystring = "Test"
Platforms Platforms
• Multiplatform hierarchy optimized for each platform :
– RW Plugin implementation using
• Sctatch pad, VU code, …. on PS2
• Vertex/Pixel Shader, SSE, MMX, …. on PC and Xbox
– Additionally supported features for specific target platform :
• HLSL and DX9
• Pixel/vertex shader
• VU and VCL framework and examples
Code exemple : HLSL Pipeline Code exemple : HLSL Pipeline
• This RW example is a modified clmpview app that supports fx file set to RpMaterial.
– The fx file can be applied to a material by dropping the fx file onto the window when a dff is loaded.
– Or by setting a fx file to the RpMaterials.The pipeline has support for standard RenderMonkey matrices and vectors such as the world
view projection matrix.
– For example a shader using the variable world_view_proj_matrix the pipeline will know to upload the world view projection matrix to this variable. The code for this can be found in
SetStdRenderMonkeyShaderConstant.
– When a fx file is load the menu is updated to include the shader constant variables so these can be adjust at runtime. Standard RenderMonkey variables are not added to the menu.
Fx file example Fx file example
// a white surface, lit by a white light
// the light color and direction can be changed in the viewer float4 mylightcolor = { 1.0, 1.0, 1.0, 1.0 };
float3 lightDirection = {0.0f, 0.0f, -1.0f };
technique T0 {
pass P0 {
pixelshader = NULL;
fvf = XYZ | Normal;
vertexshader = NULL;
// enable a single, colored light MaterialDiffuse = {1.0, 1.0, 1.0, 0.0};
MaterialAmbient = {0.1, 0.1, 0.1, 0.0};
LightType[0] = DIRECTIONAL;
LightDiffuse[0] = (mylightcolor);
LightSpecular[0] = {0.0f,0.0f,0.0f,0.0f};
LightAmbient[0] = {0.0f,0.0f,0.0f,0.0f};
LightDirection[0] = (lightDirection);
LightRange[0] = 100000.0f;
LightEnable[0] = TRUE;
Lighting = TRUE;
CullMode = None;
ColorOp[0] = SelectArg1;
ColorArg1[0] = Diffuse;
ColorOp[1] = Disable;
} }
How to attach the fx file to the How to attach the fx file to the
material material
• To set a fx file to a material userdata is used. This can be set in Max using Max Script as explain in the chapter "5.4 Adding Custom Data" of TechnicalArtistGuide.pdf.
• The userdata should be called "fxfile" and the data should be the path of the fx file. An example file ./models/gumbo.max is supplied and has two materials body and tusk and each
material has its onw fx file.
• MaterialAlways is the code for loading the fx file from the material userdata. If the file does not exist, the directory ./models/ will also be searched.
The rendering pipeline The rendering pipeline
• The pipline creation :
tatic void
PipelineOpen(void) {
RxPipeline *pipe = NULL;
RxPipelineNode *allinone = NULL;
RxLockedPipe *lpipe;
RxNodeDefinition *nodedef = NULL;
void *success;
assert(0 == Module.numInstances);
pipe = RxPipelineCreate();
nodedef = RxNodeDefinitionGetD3D9AtomicAllInOne();
assert(pipe);
lpipe = RxPipelineLock(pipe);
assert(lpipe);
success = RxLockedPipeAddFragment(lpipe, NULL, nodedef, NULL);
assert(success);
success = RxLockedPipeUnlock(lpipe);
assert(success);
allinone = RxPipelineFindNodeByName(pipe, nodedef->name, NULL, 0);
assert(allinone);
RxD3D9AllInOneSetInstanceCallBack(allinone, myInstanceCB);
RxD3D9AllInOneSetRenderCallBack(allinone, myRenderCB);
RxD3D9AllInOneSetLightingCallBack(allinone, NULL);
Pipeline = pipe;
return;
}
The instance callback The instance callback
• Create the vertex buffer
…
numTextureCoords = RpGeometryGetNumTexCoordSets(geometry);
if (numTextureCoords) {
RwInt32 n;
for (n=0; n<numTextureCoords; n++) {
declaration[declarationIndex].Stream = 0;
declaration[declarationIndex].Offset = offset;
declaration[declarationIndex].Type = D3DDECLTYPE_FLOAT2;
declaration[declarationIndex].Method = D3DDECLMETHOD_DEFAULT;
declaration[declarationIndex].Usage = D3DDECLUSAGE_TEXCOORD;
declaration[declarationIndex].UsageIndex = n;
declarationIndex++;
offset += sizeof(RwTexCoords);
vertexStream->stride += sizeof(RwTexCoords);
vertexStream->geometryFlags |= (rpGEOMETRYLOCKTEXCOORDS1 << n);
} }
…
Render callback Render callback
static void
myRenderCB(RwResEntry *repEntry, void *object, RwUInt8 type, RwUInt32 flags) {
…
while (numMeshes--) {…
material = (const RpMaterial *)instancedData->material;
effectData = DX_EFFECT_MATERIAL_GET_DATA(material);
d3dxEffect = effectData->d3dxEffect;
hr = d3dxEffect->lpVtbl->Begin(d3dxEffect, &numPasses, 0);
if (SUCCEEDED(hr)) {
for (i=0; i<numPasses; i++) { …
if (noTextures) {
const D3DCAPS9 *d3dCaps;
d3dCaps = (const D3DCAPS9 *)RwD3D9GetCaps();
for (j=0; j<d3dCaps->MaxTextureBlendStages; j++) {
IDirect3DDevice9_SetTexture(D3DDevice, j, NULL);
} }
for (j=0; j<effectData->numHandles; j++) {
switch (effectData->handles[j].type) {…
case MAT_EFFECT_HANDLE_FLOAT:
d3dxEffect->lpVtbl->SetFloat(d3dxEffect, effectData->handles[j].handle, effectData->handles[j].d3dVector.x);
break;
…}
}
d3dxEffect->lpVtbl->Pass(d3dxEffect, i);
if (resEntryHeader->indexBuffer != NULL) {
RwD3D9DrawIndexedPrimitive((D3DPRIMITIVETYPE)resEntryHeader->primType, instancedData->baseIndex,0, instancedData->numVertices,
instancedData->startIndex, instancedData->numPrimitives);
} …}
instancedData++;
}