C# Class idTech4.Renderer.idMaterial

Material.
Any errors during parsing just set MF_DEFAULTED and return, rather than throwing a hard error. This will cause the material to fall back to default material, but otherwise let things continue.

Each material may have a set of calculations that must be evaluated before drawing with it.

Every expression that a material uses can be evaluated at one time, which will allow for perfect common subexpression removal when I get around to writing it.

Without this, scrolling an entire surface could result in evaluating the same texture matrix calculations a half dozen times.

Open question: should I allow arbitrary per-vertex color, texCoord, and vertex calculations to be specified in the material code?

Every stage will definately have a valid image pointer.

We might want the ability to change the sort value based on conditionals, but it could be a hassle to implement,

Inheritance: idTech4.Text.idDecl
显示文件 Open project: iainmckay/idtech4.net Class Usage Examples

Public Methods

Method Description
AddReference ( ) : void
EvaluateRegisters ( float &registers, float shaderParms, View view ) : void
EvaluateRegisters ( float &registers, float shaderParms, View view, idSoundEmitter soundEmitter ) : void
GetStage ( int index ) : MaterialStage
Parse ( string text ) : bool

Parses the current material definition and finds all necessary images.

TestMaterialFlag ( MaterialFlags flag ) : bool

Test for existance of specific material flag(s).

idMaterial ( ) : System

Protected Methods

Method Description
ClearData ( ) : void
GenerateDefaultText ( ) : bool

Private Methods

Method Description
AddImplicitStages ( TextureRepeat textureRepeatDefault = TextureRepeat.Repeat ) : void

Adds implicit stages to the material.

If a material has diffuse or specular stages without any bump stage, add an implicit _flat bumpmap stage.

It is valid to have either a diffuse or specular without the other.

It is valid to have a reflection map and a bump map for bumpy reflection.

AppendToken ( StringBuilder b, idToken token ) : void
CheckForConstantRegisters ( ) : void

As of 5/2/03, about half of the unique materials loaded on typical maps are constant, but 2/3 of the surface references are. This is probably an optimization of dubious value.

CheckSurfaceParameter ( idToken token ) : bool

See if the current token matches one of the surface parameter bit flags.

Clear ( ) : void
EmitOp ( int a, int b, ExpressionOperationType opType ) : int
GetDestinationBlendMode ( string name ) : MaterialStates
GetExpressionConstant ( float f ) : int
GetExpressionOperation ( ) : ExpressionOperation
GetExpressionTemporary ( ) : int
GetSourceBlendMode ( string name ) : MaterialStates
MatchAndAppendToken ( StringBuilder b, idLexer lexer, string match ) : void
MatchToken ( idLexer lexer, string match ) : bool

Sets defaultShader and returns false if the next token doesn't match.

MultiplyTextureMatrix ( TextureStage &textureStage, int registers ) : void
ParseBlend ( idLexer lexer, MaterialStage &stage ) : void
ParseDecalInfo ( idLexer lexer ) : void
ParseDeform ( idLexer lexer ) : void
ParseEmitOp ( idLexer lexer, int a, ExpressionOperationType opType, int priority ) : int
ParseExpression ( idLexer lexer ) : int

ParseExpressionPriority ( idLexer lexer, int priority ) : int
ParseFragmentMap ( idLexer lexer, NewMaterialStage &newStage ) : void
ParseMaterial ( idLexer lexer ) : void

Parses the material, if there are any errors during parsing the defaultShader will be set.

ParsePastImageProgram ( idLexer lexer ) : string
ParseSort ( idLexer lexer ) : void
ParseStage ( idLexer lexer, TextureRepeat textureRepeatDefault ) : void
ParseTerm ( idLexer lexer ) : int

ParseVertexParameter ( idLexer lexer, NewMaterialStage &newStage ) : void

Parses a vertex parameter.

If there is a single value, it will be repeated across all elements. If there are two values, 3 = 0.0, 4 = 1.0. if there are three values, 4 = 1.0.

SortInteractionStages ( ) : void

Sorts the shader stages.

The renderer expects bump, then diffuse, then specular There can be multiple bump maps, followed by additional diffuse and specular stages, which allows cross-faded bump mapping. Ambient stages can be interspersed anywhere, but they are ignored during interactions, and all the interaction stages are ignored during ambient drawing.

Method Details

AddReference() public method

public AddReference ( ) : void
return void

ClearData() protected method

protected ClearData ( ) : void
return void

EvaluateRegisters() public method

public EvaluateRegisters ( float &registers, float shaderParms, View view ) : void
registers float
shaderParms float
view View
return void

EvaluateRegisters() public method

public EvaluateRegisters ( float &registers, float shaderParms, View view, idSoundEmitter soundEmitter ) : void
registers float
shaderParms float
view View
soundEmitter idSoundEmitter
return void

GenerateDefaultText() protected method

protected GenerateDefaultText ( ) : bool
return bool

GetStage() public method

public GetStage ( int index ) : MaterialStage
index int
return MaterialStage

Parse() public method

Parses the current material definition and finds all necessary images.
public Parse ( string text ) : bool
text string
return bool

TestMaterialFlag() public method

Test for existance of specific material flag(s).
public TestMaterialFlag ( MaterialFlags flag ) : bool
flag MaterialFlags
return bool

idMaterial() public method

public idMaterial ( ) : System
return System