OpenClonk
StdMeshMaterialPass Class Reference

#include <StdMeshMaterial.h>

Collaboration diagram for StdMeshMaterialPass:
[legend]

Classes

class  ProgramInstance
 
struct  ShaderInstance
 

Public Types

enum  CullHardwareType { CH_Clockwise , CH_CounterClockwise , CH_None }
 
enum  SceneBlendType {
  SB_One , SB_Zero , SB_DestColor , SB_SrcColor ,
  SB_OneMinusDestColor , SB_OneMinusSrcColor , SB_DestAlpha , SB_SrcAlpha ,
  SB_OneMinusDestAlpha , SB_OneMinusSrcAlpha
}
 
enum  DepthFunctionType {
  DF_AlwaysFail , DF_AlwaysPass , DF_Less , DF_LessEqual ,
  DF_Equal , DF_NotEqual , DF_GreaterEqual , DF_Greater
}
 

Public Member Functions

 StdMeshMaterialPass ()
 
void Load (StdMeshMaterialParserCtx &ctx)
 
bool IsOpaque () const
 

Public Attributes

StdCopyStrBuf Name
 
std::vector< StdMeshMaterialTextureUnitTextureUnits
 
float Ambient [4]
 
float Diffuse [4]
 
float Specular [4]
 
float Emissive [4]
 
float Shininess
 
bool DepthCheck {true}
 
bool DepthWrite {true}
 
CullHardwareType CullHardware {CH_Clockwise}
 
SceneBlendType SceneBlendFactors [2]
 
DepthFunctionType AlphaRejectionFunction
 
float AlphaRejectionValue
 
bool AlphaToCoverage
 
ShaderInstance FragmentShader
 
ShaderInstance VertexShader
 
ShaderInstance GeometryShader
 
std::shared_ptr< ProgramInstanceProgram
 

Detailed Description

Definition at line 370 of file StdMeshMaterial.h.


Class Documentation

◆ StdMeshMaterialPass::ShaderInstance

struct StdMeshMaterialPass::ShaderInstance

Definition at line 429 of file StdMeshMaterial.h.

Collaboration diagram for StdMeshMaterialPass::ShaderInstance:
[legend]
Class Members
StdMeshMaterialShaderParameters Parameters
const StdMeshMaterialShader * Shader

Member Enumeration Documentation

◆ CullHardwareType

Enumerator
CH_Clockwise 
CH_CounterClockwise 
CH_None 

Definition at line 373 of file StdMeshMaterial.h.

◆ DepthFunctionType

Enumerator
DF_AlwaysFail 
DF_AlwaysPass 
DF_Less 
DF_LessEqual 
DF_Equal 
DF_NotEqual 
DF_GreaterEqual 
DF_Greater 

Definition at line 394 of file StdMeshMaterial.h.

◆ SceneBlendType

Enumerator
SB_One 
SB_Zero 
SB_DestColor 
SB_SrcColor 
SB_OneMinusDestColor 
SB_OneMinusSrcColor 
SB_DestAlpha 
SB_SrcAlpha 
SB_OneMinusDestAlpha 
SB_OneMinusSrcAlpha 

Definition at line 380 of file StdMeshMaterial.h.

Constructor & Destructor Documentation

◆ StdMeshMaterialPass()

StdMeshMaterialPass::StdMeshMaterialPass ( )

Definition at line 1225 of file StdMeshMaterial.cpp.

1226 {
1227  Ambient[0] = Ambient[1] = Ambient[2] = 1.0f; Ambient[3] = 1.0f;
1228  Diffuse[0] = Diffuse[1] = Diffuse[2] = 1.0f; Diffuse[3] = 1.0f;
1229  Specular[0] = Specular[1] = Specular[2] = 0.0f; Specular[3] = 0.0f;
1230  Emissive[0] = Emissive[1] = Emissive[2] = 0.0f; Emissive[3] = 0.0f;
1231  Shininess = 0.0f;
1234  AlphaToCoverage = false;
1236 }
const StdMeshMaterialShader * Shader
DepthFunctionType AlphaRejectionFunction
SceneBlendType SceneBlendFactors[2]
ShaderInstance GeometryShader
ShaderInstance FragmentShader
ShaderInstance VertexShader

References AlphaRejectionFunction, AlphaRejectionValue, AlphaToCoverage, Ambient, DF_AlwaysPass, Diffuse, Emissive, FragmentShader, GeometryShader, SB_One, SB_Zero, SceneBlendFactors, StdMeshMaterialPass::ShaderInstance::Shader, Shininess, Specular, and VertexShader.

Member Function Documentation

◆ IsOpaque()

bool StdMeshMaterialPass::IsOpaque ( ) const
inline

Definition at line 409 of file StdMeshMaterial.h.

409 { return SceneBlendFactors[1] == SB_Zero; }

References SB_Zero, and SceneBlendFactors.

◆ Load()

void StdMeshMaterialPass::Load ( StdMeshMaterialParserCtx ctx)

Definition at line 1278 of file StdMeshMaterial.cpp.

1279 {
1280  Token token;
1281  StdCopyStrBuf token_name;
1282  StdMeshMaterialSubLoader texture_unit_loader;
1283  while ((token = ctx.AdvanceNonEOF(token_name)) == TOKEN_IDTF)
1284  {
1285  if (token_name == "texture_unit")
1286  {
1287  texture_unit_loader.Load(ctx, TextureUnits);
1288  }
1289  else if (token_name == "ambient")
1290  {
1291  ctx.AdvanceColor(true, Ambient);
1292  }
1293  else if (token_name == "diffuse")
1294  {
1295  ctx.AdvanceColor(true, Diffuse);
1296  }
1297  else if (token_name == "specular")
1298  {
1299  Specular[0] = ctx.AdvanceFloat();
1300  Specular[1] = ctx.AdvanceFloat();
1301  Specular[2] = ctx.AdvanceFloat();
1302 
1303  // The fourth argument is optional, not the fifth:
1304  float specular3 = ctx.AdvanceFloat();
1305 
1306  float shininess;
1307  if (ctx.AdvanceFloatOptional(shininess))
1308  {
1309  Specular[3] = specular3;
1310  Shininess = shininess;
1311  }
1312  else
1313  {
1314  Shininess = specular3;
1315  }
1316  }
1317  else if (token_name == "emissive")
1318  {
1319  ctx.AdvanceColor(true, Emissive);
1320  }
1321  else if (token_name == "depth_check")
1322  {
1323  DepthCheck = ctx.AdvanceBoolean();
1324  }
1325  else if (token_name == "depth_write")
1326  {
1327  DepthWrite = ctx.AdvanceBoolean();
1328  }
1329  else if (token_name == "cull_hardware")
1330  {
1331  CullHardware = ctx.AdvanceEnum(CullHardwareEnumerators);
1332  }
1333  else if (token_name == "scene_blend")
1334  {
1335  ctx.AdvanceEnums<2, StdMeshMaterialPass::SceneBlendType>(SceneBlendEnumerators, SceneBlendShortcuts, SceneBlendFactors);
1336  }
1337  else if (token_name == "scene_blend_op")
1338  {
1339  StdStrBuf op;
1340  ctx.AdvanceRequired(op, TOKEN_IDTF);
1341  ctx.WarningNotSupported(token_name.getData());
1342  }
1343  else if (token_name == "alpha_rejection")
1344  {
1345  AlphaRejectionFunction = ctx.AdvanceEnum(DepthFunctionEnumerators);
1347  AlphaRejectionValue = ctx.AdvanceFloat() / 255.0f;
1348  }
1349  else if (token_name == "alpha_to_coverage")
1350  {
1352  }
1353  else if (token_name == "colour_write")
1354  {
1355  ctx.AdvanceBoolean();
1356  ctx.WarningNotSupported("colour_write");
1357  }
1358  else if (token_name == "depth_func")
1359  {
1360  StdStrBuf func;
1361  ctx.AdvanceRequired(func, TOKEN_IDTF);
1362  ctx.WarningNotSupported(token_name.getData());
1363  }
1364  else if (token_name == "illumination_stage")
1365  {
1366  ctx.WarningNotSupported(token_name.getData());
1367  }
1368  else if (token_name == "light_clip_planes")
1369  {
1370  ctx.AdvanceBoolean();
1371  ctx.WarningNotSupported(token_name.getData());
1372  }
1373  else if (token_name == "light_scissor")
1374  {
1375  ctx.AdvanceBoolean();
1376  ctx.WarningNotSupported(token_name.getData());
1377  }
1378  else if (token_name == "lighting")
1379  {
1380  ctx.AdvanceBoolean();
1381  ctx.WarningNotSupported(token_name.getData());
1382  }
1383  else if (token_name == "normalise_normals" || token_name == "normalize_normals")
1384  {
1385  ctx.AdvanceBoolean();
1386  ctx.WarningNotSupported(token_name.getData());
1387  }
1388  else if (token_name == "polygon_mode")
1389  {
1390  StdStrBuf mode;
1391  ctx.AdvanceRequired(mode, TOKEN_IDTF);
1392  ctx.WarningNotSupported(token_name.getData());
1393  }
1394  else if (token_name == "shading")
1395  {
1396  StdStrBuf shading;
1397  ctx.AdvanceRequired(shading, TOKEN_IDTF);
1398  ctx.WarningNotSupported(token_name.getData());
1399  }
1400  else if (token_name == "transparent_sorting")
1401  {
1402  ctx.AdvanceBoolean();
1403  ctx.WarningNotSupported(token_name.getData());
1404  }
1405  else if (token_name == "vertex_program_ref")
1406  {
1407  LoadShaderRef(ctx, SMMS_VERTEX);
1408  }
1409  else if (token_name == "fragment_program_ref")
1410  {
1411  LoadShaderRef(ctx, SMMS_FRAGMENT);
1412  }
1413  else if (token_name == "geometry_program_ref")
1414  {
1415  LoadShaderRef(ctx, SMMS_GEOMETRY);
1416  }
1417  else
1418  ctx.ErrorUnexpectedIdentifier(token_name);
1419  }
1420 
1421  if (token != TOKEN_BRACE_CLOSE)
1422  ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
1423 }
@ TOKEN_IDTF
@ TOKEN_BRACE_CLOSE
@ SMMS_VERTEX
@ SMMS_FRAGMENT
@ SMMS_GEOMETRY
Token AdvanceRequired(StdStrBuf &name, Token expect)
void Error(const StdStrBuf &message)
void ErrorUnexpectedIdentifier(const StdStrBuf &identifier)
bool AdvanceFloatOptional(float &value)
void AdvanceColor(bool with_alpha, float Color[4])
Token AdvanceNonEOF(StdStrBuf &name)
void AdvanceEnums(const Enumerator< EnumType > *enumerators, EnumType enums[Num])
void WarningNotSupported(const char *identifier)
EnumType AdvanceEnum(const Enumerator< EnumType > *enumerators)
CullHardwareType CullHardware
std::vector< StdMeshMaterialTextureUnit > TextureUnits
void Load(StdMeshMaterialParserCtx &ctx, std::vector< SubT > &vec)
const char * getData() const
Definition: StdBuf.h:442

References StdMeshMaterialParserCtx::AdvanceBoolean(), StdMeshMaterialParserCtx::AdvanceColor(), StdMeshMaterialParserCtx::AdvanceEnum(), StdMeshMaterialParserCtx::AdvanceEnums(), StdMeshMaterialParserCtx::AdvanceFloat(), StdMeshMaterialParserCtx::AdvanceFloatOptional(), StdMeshMaterialParserCtx::AdvanceNonEOF(), StdMeshMaterialParserCtx::AdvanceRequired(), AlphaRejectionFunction, AlphaRejectionValue, AlphaToCoverage, Ambient, CullHardware, DepthCheck, DepthWrite, DF_AlwaysFail, DF_AlwaysPass, Diffuse, Emissive, StdMeshMaterialParserCtx::Error(), StdMeshMaterialParserCtx::ErrorUnexpectedIdentifier(), StdStrBuf::getData(), StdMeshMaterialSubLoader::Load(), SceneBlendFactors, Shininess, SMMS_FRAGMENT, SMMS_GEOMETRY, SMMS_VERTEX, Specular, TextureUnits, TOKEN_BRACE_CLOSE, TOKEN_IDTF, and StdMeshMaterialParserCtx::WarningNotSupported().

Here is the call graph for this function:

Member Data Documentation

◆ AlphaRejectionFunction

DepthFunctionType StdMeshMaterialPass::AlphaRejectionFunction

Definition at line 425 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

◆ AlphaRejectionValue

float StdMeshMaterialPass::AlphaRejectionValue

Definition at line 426 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

◆ AlphaToCoverage

bool StdMeshMaterialPass::AlphaToCoverage

Definition at line 427 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

◆ Ambient

float StdMeshMaterialPass::Ambient[4]

Definition at line 414 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

◆ CullHardware

CullHardwareType StdMeshMaterialPass::CullHardware {CH_Clockwise}

Definition at line 423 of file StdMeshMaterial.h.

Referenced by Load().

◆ DepthCheck

bool StdMeshMaterialPass::DepthCheck {true}

Definition at line 420 of file StdMeshMaterial.h.

Referenced by Load().

◆ DepthWrite

bool StdMeshMaterialPass::DepthWrite {true}

Definition at line 421 of file StdMeshMaterial.h.

Referenced by Load().

◆ Diffuse

float StdMeshMaterialPass::Diffuse[4]

Definition at line 415 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

◆ Emissive

float StdMeshMaterialPass::Emissive[4]

Definition at line 417 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

◆ FragmentShader

ShaderInstance StdMeshMaterialPass::FragmentShader

Definition at line 457 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial(), and StdMeshMaterialPass().

◆ GeometryShader

ShaderInstance StdMeshMaterialPass::GeometryShader

Definition at line 459 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial(), and StdMeshMaterialPass().

◆ Name

StdCopyStrBuf StdMeshMaterialPass::Name

Definition at line 411 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial().

◆ Program

std::shared_ptr<ProgramInstance> StdMeshMaterialPass::Program

Definition at line 468 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial().

◆ SceneBlendFactors

SceneBlendType StdMeshMaterialPass::SceneBlendFactors[2]

Definition at line 424 of file StdMeshMaterial.h.

Referenced by IsOpaque(), Load(), and StdMeshMaterialPass().

◆ Shininess

float StdMeshMaterialPass::Shininess

Definition at line 418 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

◆ Specular

float StdMeshMaterialPass::Specular[4]

Definition at line 416 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

◆ TextureUnits

std::vector<StdMeshMaterialTextureUnit> StdMeshMaterialPass::TextureUnits

◆ VertexShader

ShaderInstance StdMeshMaterialPass::VertexShader

Definition at line 458 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial(), and StdMeshMaterialPass().


The documentation for this class was generated from the following files: