1450 lines
42 KiB
C++
1450 lines
42 KiB
C++
// ShaderEditorDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "ShaderEditor.h"
|
|
#include "ShaderEditorDlg.h"
|
|
#include "ShaderEditorToolbarDlg.h"
|
|
|
|
using namespace CKControl;
|
|
|
|
#ifdef _MFCDEBUGNEW
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
#endif
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Convenient keywords registation stuff
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Colors
|
|
//-----------------------------------------------------------------------------
|
|
#define KC_COMMENT 0x00008000
|
|
#define KC_STRING 0x00000080
|
|
#define KC_CHAR 0x000000C0
|
|
#define KC_SYNTAX 0x00FF0000
|
|
#define KC_DATATYPE 0x00FF0000
|
|
#define KC_VARMODIFIER 0x00FF0000
|
|
#define KC_PREPROC 0x00FF0000
|
|
#define KC_FUNCTION 0x00505050
|
|
#define KC_DATATYPE_MEMBER 0x00500000
|
|
#define KC_SYNTAXShader 0x00F000F0
|
|
#define KC_LITERAL 0x00B03000
|
|
#define KC_INTRINSICS 0x000000A0
|
|
#define KC_SEMANTICS 0x000080A0
|
|
#define KC_SEMANTICS_VR 0x000033DD
|
|
#define KC_ANNOTATIONS_VR 0x00DD33DD
|
|
#define KC_RENDERSTATE 0x00900090
|
|
#define KC_RENDERSTATE_ENUM 0x000030B0
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_AddArray( char* name[], DWORD color )
|
|
{
|
|
_SetCurrentColor( color );
|
|
|
|
for( int a=0 ; name[a] ; ++a ){
|
|
_Add( name[a] );
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_AddArray( KeywordAndDesc* nameAndDesc, DWORD color )
|
|
{
|
|
_SetCurrentColor( color );
|
|
|
|
for( int a=0 ; nameAndDesc[a].name ; ++a ){
|
|
_Add( nameAndDesc[a].name, nameAndDesc[a].desc );
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_RemoveArray( KeywordAndDesc* nameAndDesc )
|
|
{
|
|
for( int a=0 ; nameAndDesc[a].name ; ++a ){
|
|
const char* name = nameAndDesc[a].name;
|
|
|
|
char str[256];
|
|
int lastIndex = strlen( name )-1;
|
|
memcpy( str, name, lastIndex+1 );
|
|
str[lastIndex+1] = (char)0;
|
|
|
|
//--- Special case for "[]"
|
|
if( str[lastIndex]==']' ){
|
|
|
|
//--- Completion with "[]"
|
|
m_Editor.RemoveKeyWord( NULL, str );
|
|
|
|
//--- Color without "[]"
|
|
str[lastIndex-1] = (char)0;
|
|
m_Editor.RemoveColorKeyWord( str );
|
|
continue;
|
|
}
|
|
//--- Special case for "?"
|
|
if( str[lastIndex] == '?' ){
|
|
for( char c='0' ; c<='9'; ++c ){
|
|
//--- Color for '0' to '9' derived name
|
|
str[lastIndex] = c;
|
|
m_Editor.RemoveColorKeyWord( str );
|
|
}
|
|
str[lastIndex] = (char)0;
|
|
|
|
}
|
|
//--- Completion and Color for original name
|
|
m_Editor.RemoveKeyWord( NULL, str );
|
|
m_Editor.RemoveColorKeyWord( str );
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_Add( const char* name, char* desc )
|
|
{
|
|
char str[256];
|
|
int lastIndex = strlen( name )-1;
|
|
memcpy( str, name, lastIndex+1 );
|
|
str[lastIndex+1] = (char)0;
|
|
|
|
//--- Special case for "[]"
|
|
if( str[lastIndex]==']' ){
|
|
|
|
//--- Completion with "[]"
|
|
m_Editor.AddKeyWord( NULL, str, desc );
|
|
|
|
//--- Color without "[]"
|
|
str[lastIndex-1] = (char)0;
|
|
m_Editor.AddColorKeyWord( str, m_currentKeyColor );
|
|
return;
|
|
}
|
|
//--- Special case for "?"
|
|
if( str[lastIndex] == '?' ){
|
|
for( char c='0' ; c<='9'; ++c ){
|
|
//--- Color for '0' to '9' derived name
|
|
str[lastIndex] = c;
|
|
m_Editor.AddColorKeyWord( str, m_currentKeyColor );
|
|
}
|
|
str[lastIndex] = (char)0;
|
|
|
|
}
|
|
//--- Completion and Color for original name
|
|
m_Editor.AddKeyWord( NULL, str, desc );
|
|
m_Editor.AddColorKeyWord( str, m_currentKeyColor );
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// All the keywords registration function
|
|
//
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_RegisterScopes()
|
|
{
|
|
// Scopes
|
|
m_Editor.AddColorScope("//", "\r", KC_COMMENT);
|
|
m_Editor.AddColorScope("/*", "*/", KC_COMMENT);
|
|
m_Editor.AddColorScope("\"", "\"", KC_STRING);
|
|
m_Editor.AddColorScope("\'", "\'", KC_CHAR);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_RegisterKeywords()
|
|
{
|
|
{ //--- Syntax
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
{"return", NULL},
|
|
{"if", NULL},
|
|
{"else", NULL},
|
|
{"for", NULL},
|
|
{"do", NULL},
|
|
{"while", NULL},
|
|
{"struct", NULL},
|
|
{"typedef", NULL},
|
|
|
|
{ NULL, NULL }
|
|
};
|
|
_AddArray( kw, KC_SYNTAX );
|
|
}
|
|
{ //--- Shader structure
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
{"technique", NULL},
|
|
{"pass", NULL},
|
|
{"compile", NULL},
|
|
{"asm", NULL},
|
|
|
|
{ NULL, NULL }
|
|
};
|
|
_AddArray( kw, KC_SYNTAXShader );
|
|
}
|
|
{ //--- Variable modifier
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
|
|
{"shared", NULL},
|
|
{"static", NULL},
|
|
{"uniform", NULL},
|
|
{"extern", NULL},
|
|
{"volatile", NULL},
|
|
{"const", NULL},
|
|
{"register", NULL},
|
|
|
|
{ NULL, NULL }
|
|
};
|
|
_AddArray( kw, KC_VARMODIFIER );
|
|
}
|
|
{ //--- Data types
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
|
|
{"void", NULL},
|
|
{"vector", NULL},
|
|
{"matrix", NULL},
|
|
{"string", NULL},
|
|
{"texture", NULL},
|
|
{"texture2D", NULL},
|
|
{"textureCUBE", NULL},
|
|
{"texture3D", NULL},
|
|
{"sampler", NULL},
|
|
{"sampler2D", NULL},
|
|
{"sampler3D", NULL},
|
|
{"samplerCUBE", NULL},
|
|
|
|
{ NULL, NULL }
|
|
};
|
|
_AddArray( kw, KC_DATATYPE );
|
|
}
|
|
{ //--- Preprocessor
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
{"#define", NULL},
|
|
{"#if", NULL},
|
|
{"#elif", NULL},
|
|
{"#else", NULL},
|
|
{"#endif", NULL},
|
|
{"#include", NULL},
|
|
{"#ifdef", NULL},
|
|
{"#ifndef", NULL},
|
|
{"#undef", NULL},
|
|
{"#error", NULL},
|
|
{"#pragma", NULL},
|
|
{"#line", NULL},
|
|
{"#row_major", NULL},
|
|
{"#column_major", NULL},
|
|
{"DIRECT3D_VERSION",NULL},
|
|
{"D3DX_VERSION",NULL},
|
|
{"XBOX",NULL},
|
|
{"screenspace",NULL},
|
|
{ NULL, NULL }
|
|
};
|
|
_AddArray( kw, KC_PREPROC );
|
|
}
|
|
{ //--- Literals
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
{"true", NULL},
|
|
{"false", NULL},
|
|
{"null", NULL},
|
|
|
|
{ NULL, NULL }
|
|
};
|
|
_AddArray( kw, KC_LITERAL );
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void ShaderEditorDlg::_RegisterASM()
|
|
{
|
|
{
|
|
// Vertex Shader
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
|
|
{"abs", "Absolute value"},
|
|
{"add","Add two vectors"},
|
|
{"break","Break out of a loop...endloop or rep...endrep block"},
|
|
{"break_comp","Conditionally break out of a loop...endloop or rep...endrep block, with a comparison"},
|
|
{"breakp","Break out of a loop...endloop or rep...endrep block, based on a predicate"},
|
|
{"call"," Call a subroutine"},
|
|
{"callnz","bool Call a subroutine if a Boolean register is not zero"},
|
|
{"callnz","pred Call a subroutine if a predicate register is not zero"},
|
|
{"crs","Cross product"},
|
|
{"def","Define constants"},
|
|
{"defb","Declare a Boolean constant"},
|
|
{"defi","Declare an integer constant"},
|
|
{"dp3","Three-component dot product"},
|
|
{"dp4","Four-component dot product"},
|
|
{"dst","Distance"},
|
|
{"else","Begin an else block"},
|
|
{"endif","End an if bool...else block"},
|
|
{"endloop","End of a loop block"},
|
|
{"endrep","End of a repeat block"},
|
|
{"exp","Full precision exponential"},
|
|
{"expp","Partial precision exponential"},
|
|
{"frc","Fractional component"},
|
|
{"if","bool Begin an if bool block (using a Boolean condition)"},
|
|
{"if_comp","Begin an if bool block, with a comparison"},
|
|
{"if","pred Begin an if bool block with a predicate condition"},
|
|
{"label","Label"},
|
|
{"lit","Calculate lighting"},
|
|
{"log","Full precision log2(x)"},
|
|
{"logp","Partial precision log2(x)"},
|
|
{"loop","Loop"},
|
|
{"lrp","Linear interpolation"},
|
|
{"m3x2","3x2 multiply"},
|
|
{"m3x3","3x3 multiply"},
|
|
{"m3x4","3x4 multiply"},
|
|
{"m4x3","4x3 multiply"},
|
|
{"m4x4","4x4 multiply"},
|
|
{"mad","Multiply and add"},
|
|
{"max","Maximum"},
|
|
{"min","Minimum"},
|
|
{"mov","Move"},
|
|
{"mova","Move data from a floating point register to an integer register"},
|
|
{"mul","Multiply"},
|
|
{"nop","No operation"},
|
|
{"nrm","Normalize"},
|
|
{"pow","2 pow x"},
|
|
{"rcp","Reciprocal"},
|
|
{"rep","Repeat"},
|
|
{"ret","End of a subroutine"},
|
|
{"rsq","Reciprocal square root"},
|
|
{"setp_comp","Set the predicate register"},
|
|
{"sge","Greater than or equal compare"},
|
|
{"sgn","Sign"},
|
|
{"sincos","Sine and cosine"},
|
|
{"slt","Less than compare"},
|
|
{"sub", "Subtract"},
|
|
{"texldl" , "Texture load with user-adjustable level of detail (LOD)"},
|
|
|
|
{"vs","version"},
|
|
{"phase", "Transition between phase 1 and phase 2"},
|
|
{"stream", "Vertex Shader Stream declaration"},
|
|
{"decl", "Vertex Shader Declaration"},
|
|
|
|
{"dcl_position",NULL},
|
|
{"dcl_blendweight",NULL},
|
|
{"dcl_position",NULL},
|
|
{"dcl_blendweight",NULL},
|
|
{"dcl_blendindices",NULL},
|
|
{"dcl_normal",NULL},
|
|
{"dcl_psize",NULL},
|
|
{"dcl_texcoord",NULL},
|
|
{"dcl_texcoord0",NULL},
|
|
{"dcl_texcoord1",NULL},
|
|
{"dcl_texcoord2",NULL},
|
|
{"dcl_texcoord3",NULL},
|
|
{"dcl_texcoord4",NULL},
|
|
{"dcl_texcoord5",NULL},
|
|
{"dcl_texcoord6",NULL},
|
|
{"dcl_texcoord7",NULL},
|
|
{"dcl_tangent",NULL},
|
|
{"dcl_binormal",NULL},
|
|
|
|
{"dcl_tangent0",NULL},
|
|
{"dcl_tangent1",NULL},
|
|
{"dcl_tangent2",NULL},
|
|
{"dcl_tangent3",NULL},
|
|
{"dcl_tangent4",NULL},
|
|
{"dcl_tangent5",NULL},
|
|
{"dcl_tangent6",NULL},
|
|
{"dcl_tangent7",NULL},
|
|
|
|
{"dcl_binormal0",NULL},
|
|
{"dcl_binormal1",NULL},
|
|
{"dcl_binormal2",NULL},
|
|
{"dcl_binormal3",NULL},
|
|
{"dcl_binormal4",NULL},
|
|
{"dcl_binormal5",NULL},
|
|
{"dcl_binormal6",NULL},
|
|
{"dcl_binormal7",NULL},
|
|
|
|
{"dcl_tessfactor",NULL},
|
|
{"dcl_positiont",NULL},
|
|
{"dcl_color",NULL},
|
|
{"dcl_fog",NULL},
|
|
{"dcl_depth",NULL},
|
|
{"dcl_sample",NULL},
|
|
|
|
{"tex","Sample a texture"},
|
|
{"texbem","Apply a fake bump environment-map transform"},
|
|
{"texbeml","Apply a fake bump environment-map transform with luminance correction"},
|
|
{"texcoord","Interpret texture coordinate data as color data"},
|
|
{"texcrd","Copy texture coordinate data as color data"},
|
|
{"texdepth","Calculate depth values"},
|
|
{"texdp3","Three-component dot product between texture data and the texture coordinates"},
|
|
{"texdp3tex","Three-component dot product and 1-D texture lookup"},
|
|
{"texkill","Cancels rendering of pixels based on a comparison"},
|
|
{"texld","Sample a texture"},
|
|
{"texm3x2depth","Calculate per-pixel depth values"},
|
|
{"texm3x2pad","First row matrix multiply of a two-row matrix multiply"},
|
|
{"texm3x2tex","Final row matrix multiply of a two-row matrix multiply"},
|
|
{"texm3x3","3x3 matrix multiply"},
|
|
{"texm3x3pad","First or second row multiply of a three-row matrix multiply"},
|
|
{"texm3x3spec","Final row multiply of a three-row matrix multiply"},
|
|
{"texm3x3tex","Texture look up using a 3x3 matrix multiply"},
|
|
{"texm3x3vspec","Texture look up using a 3x3 matrix multiply, with non-constant eye-ray vector"},
|
|
{"texreg2ar","Sample a texture using the alpha and red components"},
|
|
{"texreg2gb","Sample a texture using the green and blue components"},
|
|
{"texreg2rgb","Sample a texture using the red, green and blue components "},
|
|
|
|
{"vFace","Face Register"},
|
|
{"vPos","Position Register."},
|
|
{"aL","Loop Counter Register"},
|
|
|
|
{ NULL, NULL }
|
|
};
|
|
_AddArray( kw, KC_INTRINSICS );
|
|
}
|
|
|
|
|
|
{
|
|
// Pixel Shader
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
|
|
{"abs","Absolute value"},
|
|
{"add","Add two vectors"},
|
|
{"break","Break out of a loop...endloop or rep...endrep block"},
|
|
{"break_comp","Conditionally break out of a loop...endloop or rep...endrep block, with a comparison"},
|
|
{"breakp","Break out of a loop...endloop or rep...endrep block, based on a predicate"},
|
|
{"call","Call a subroutine"},
|
|
{"callnz","bool Call a subroutine if a boolean register is not zero"},
|
|
{"callnz","pred Call a subroutine if a predicate register is not zero"},
|
|
{"cmp","Compare source to 0"},
|
|
{"crs","Cross product"},
|
|
{"def","Define constants"},
|
|
{"defb","Define a Boolean constant"},
|
|
{"defi","Define an integer constant"},
|
|
{"dp2add","2-D dot product and add"},
|
|
{"dp3","3-D dot product"},
|
|
{"dp4","4-D dot product"},
|
|
{"dsx","Rate of change in the x-direction"},
|
|
{"dsy","Rate of change in the y direction"},
|
|
{"else","Begin an else block"},
|
|
{"endif","End an if...else block"},
|
|
{"endloop","endloop"},
|
|
{"endrep","End of a repeat block"},
|
|
{"exp","Full precision 2x"},
|
|
{"frc","Fractional component"},
|
|
{"if","bool Begin an if block"},
|
|
{"if_comp","Begin an if block with a comparison"},
|
|
{"if","pred Begin an if block with predication"},
|
|
{"label","Label"},
|
|
{"log","Full precision log2(x)"},
|
|
{"loop","Loop"},
|
|
{"lrp","Linear interpolate"},
|
|
{"m3x2","3x2 multiply"},
|
|
{"m3x3","3x3 multiply"},
|
|
{"m3x4","3x4 multiply"},
|
|
{"m4x3","4x3 multiply"},
|
|
{"m4x4","4x4 multiply"},
|
|
{"mad","Multiply and add"},
|
|
{"max","Maximum"},
|
|
{"min","Minimum"},
|
|
{"mov","Move"},
|
|
{"mul","Multiply"},
|
|
{"nop","No operation"},
|
|
{"nrm","Normalize"},
|
|
{"pow","2 pow x"},
|
|
{"ps","version"},
|
|
{"xps","version"},
|
|
{"rcp","Reciprocal"},
|
|
{"rep","Repeat"},
|
|
{"ret","End of a subroutine"},
|
|
{"rsq","Reciprocal square root"},
|
|
{"setp_comp","Set the predicate register"},
|
|
{"sincos","Sine and cosine"},
|
|
{"sub","Subtract"},
|
|
{"texkill","Kill pixel render"},
|
|
{"texld","Sample a texture"},
|
|
{"texldb","Texture sampling with level of detail (LOD) bias from w-component"},
|
|
{"texldl","Texture sampling with LOD from w-component See note"},
|
|
{"texldd","Texture sampling with user-provided gradients"},
|
|
{"texldp","Texture sampling with projective divide by w-component"},
|
|
|
|
{"oC0","The pixel shader color output registers (oC#) are write-only registers that output results to multiple render targets."},
|
|
{"oC1","The pixel shader color output registers (oC#) are write-only registers that output results to multiple render targets."},
|
|
{"oC2","The pixel shader color output registers (oC#) are write-only registers that output results to multiple render targets."},
|
|
{"oC3","The pixel shader color output registers (oC#) are write-only registers that output results to multiple render targets."},
|
|
{"oDepth","The pixel shader output depth register (oDepth) is a write-only scalar register that returns a new depth value for a depth test against the depth-stencil buffer."},
|
|
|
|
|
|
|
|
{ NULL, NULL }
|
|
};
|
|
_AddArray( kw, KC_INTRINSICS );
|
|
}
|
|
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_RegisterBasicDataTypes()
|
|
{
|
|
//--- Basic types structures.
|
|
m_Editor.AddOwnerSeparator(".");
|
|
|
|
char* basetypes[] = {
|
|
{"bool"},
|
|
{"int"},
|
|
{"half"},
|
|
{"byte"},
|
|
{"short"},
|
|
{"float"},
|
|
{"double"},
|
|
{NULL}
|
|
};
|
|
|
|
char* basetypesmembers_vector[] = {
|
|
{"x"},
|
|
{"y"},
|
|
{"z"},
|
|
{"w"},
|
|
{NULL}
|
|
};
|
|
|
|
char* basetypesmembers_color[] = {
|
|
{"r"},
|
|
{"g"},
|
|
{"b"},
|
|
{"a"},
|
|
{NULL}
|
|
};
|
|
|
|
//--- For each type
|
|
for (int ti = 0; basetypes[ti] != NULL; ++ti)
|
|
{
|
|
m_Editor.AddKeyWord( NULL, basetypes[ti] );
|
|
m_Editor.AddColorKeyWord( basetypes[ti], KC_DATATYPE );
|
|
m_Editor.AddOwnerType( basetypes[ti], NULL );
|
|
|
|
//--- For each component
|
|
for (int ci = 1; ci < 4; ++ci)
|
|
{
|
|
XString type;
|
|
type.Format("%s%d", basetypes[ti], ci + 1);
|
|
m_Editor.AddKeyWord( NULL, type.Str() );
|
|
m_Editor.AddColorKeyWord( type.Str(), KC_DATATYPE );
|
|
m_Editor.AddOwnerType( type.Str(), NULL );
|
|
|
|
//--- Creates rgba, xyzw components.
|
|
for (int xi = 0; xi <= ci; ++xi)
|
|
{
|
|
assert(basetypesmembers_vector[xi] != NULL);
|
|
assert(basetypesmembers_color[xi] != NULL);
|
|
m_Editor.AddKeyWord( type.Str(), basetypesmembers_vector[xi] );
|
|
m_Editor.AddColorKeyWord( type.Str(), KC_DATATYPE_MEMBER );
|
|
}
|
|
// Creates the matrix
|
|
for (int yi = 0; yi < 4; ++yi)
|
|
{
|
|
XString type;
|
|
type.Format("%s%dx%d", basetypes[ti], ci + 1, yi + 1 );
|
|
m_Editor.AddKeyWord( NULL, type.Str() );
|
|
m_Editor.AddColorKeyWord( type.Str(), KC_DATATYPE );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_RegisterIntrinsics()
|
|
{
|
|
//--- Intrinsics
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
{"abs", "abs(x): Absolute value (per component)."},
|
|
{"acos", "acos(x): Returns the arccosine of each component of x."},
|
|
{"all", "all(x): Test if all components of x are nonzero."},
|
|
{"any", "any(x): Test is any component of x is nonzero."},
|
|
{"asin", "asin(x): Returns the arcsine of each component of x."},
|
|
{"atan", "atan(x): Returns the arctangent of x."},
|
|
{"atan2", "atan2(y, x): Returns the arctangent of y/x."},
|
|
{"ceil", "ceil(x): Returns the smallest integer which is greater than or equal to x."},
|
|
{"clamp", "clamp(x, min, max): Clamps x to the range [min, max]."},
|
|
{"clip", "clip(x): Discards the current pixel, if any component of x is less than zero."},
|
|
{"cos", "cos(x): Returns the cosine of x."},
|
|
{"cosh", "cosh(x): Returns the hyperbolic cosine of x."},
|
|
{"cross", "cross(v1, v2): Returns the cross product of two 3-D vectors a and b."},
|
|
{"D3DCOLORtoUBYTE4", "D3DCOLORtoUBYTE4(x): Swizzles and scales components of the 4-D vector x to compensate for the lack of UBYTE4 support in some hardware."},
|
|
{"ddx", "ddx(x): Returns the partial derivative of x with respect to the screen-space x-coordinate."},
|
|
{"ddy", "ddy(x): Returns the partial derivative of x with respect to the screen-space y-coordinate."},
|
|
{"degrees", "degrees(x): Converts x from radians to degrees."},
|
|
{"determinant", "determinant(m): Returns the determinant of the square matrix m."},
|
|
{"distance", "distance(v1, v2): Returns the distance between two points a and b."},
|
|
{"dot", "dot(v1, v2): Returns the dot product of two vectors a and b."},
|
|
{"exp", "exp(x): Returns the base-e exponent ex."},
|
|
{"exp2", "value exp2(value a): Base 2 Exp (per component)."},
|
|
{"faceforward", "faceforward(n, i, ng): Returns -n * sign(dot(i, ng))."},
|
|
{"floor", "floor(x): Returns the greatest integer which is less than or equal to x."},
|
|
{"fmod", "fmod(a, b): Returns the floating point remainder f of a / b such that a = i * b + f, where i is an integer, f has the same sign as x, and the absolute value of f is less than the absolute value of b."},
|
|
{"frac", "frac(x): Returns the fractional part f of x, such that f is a value greater than or equal to 0, and less than 1."},
|
|
{"frc", "frc(x): Fractional part (per component)."},
|
|
{"frexp", "frexp(x, out exp): Returns the mantissa and exponent of x."},
|
|
{"fwidth", "fwidth(x): Returns abs(ddx(x))+abs(ddy(x))."},
|
|
{"isfinite", "isfinite(x): Returns true if x is finite, false otherwise."},
|
|
{"isinf", "isinf(x): Returns true if x is +INF or -INF, false otherwise."},
|
|
{"isnan", "isnan(x): Returns true if x is NAN or QNAN, false otherwise."},
|
|
{"ldexp", "ldexp(x, exp): Returns x * 2exp."},
|
|
{"len", "len(v): Vector length."},
|
|
{"length", "length(v): Returns the length of the vector v."},
|
|
{"lerp", "lerp(a, b, s): Returns a + s(b - a)."},
|
|
{"lit", "lit(ndotl, ndoth, m): Returns a lighting vector (ambient, diffuse, specular, 1): ambient = 1; diffuse = (ndotl < 0) ? 0: ndotl; specular = (ndotl < 0) || (ndoth < 0) ? 0: (ndoth * m); "},
|
|
{"log", "log(x): Returns the base-e logarithm of x."},
|
|
{"log10", "log10(x): Returns the base-10 logarithm of x."},
|
|
{"log2", "log2(x): Returns the base-2 logarithm of x."},
|
|
{"max", "max(a, b): Selects the greater of a and b."},
|
|
{"min", "min(a, b): Selects the lesser of a and b."},
|
|
{"modf", "modf(x, out ip): Splits the value x into fractional and integer parts, each of which has the same sign and x."},
|
|
{"mul", "mul(a, b): Performs matrix multiplication between a and b."},
|
|
{"noise", "noise(x): Not yet implemented."},
|
|
{"normalize", "normalize(v): Returns the normalized vector v / length(v)."},
|
|
{"pow", "pow(x, y): Returns xy."},
|
|
{"radians", "radians(x): Converts x from degrees to radians."},
|
|
{"reflect", "reflect(i, n): Returns the reflection vector v, given the entering ray direction i, and the surface normal n."},
|
|
{"refract", "refract(i, n, eta): Returns the refraction vector v, given the entering ray direction i, the surface normal n, and the relative index of refraction eta."},
|
|
{"round", "round(x): Rounds x to the nearest integer."},
|
|
{"rsqrt", "rsqrt(x): Returns 1 / sqrt(x)."},
|
|
{"saturate", "saturate(x): Clamps x to the range [0, 1]."},
|
|
{"sign", "sign(x): Computes the sign of x."},
|
|
{"sin", "sin(x): Returns the sine of x."},
|
|
{"sincos", "sincos(x, out s, out c): Returns the sine and cosine of x."},
|
|
{"sinh", "sinh(x): Returns the hyperbolic sine of x."},
|
|
{"smoothstep", "smoothstep(min, max, x): Returns 0 if x < min."},
|
|
{"sqrt", "value sqrt(value a): Square root (per component)."},
|
|
{"step", "step(a, x): Returns (x >= a) ? 1: 0."},
|
|
{"tan", "tan(x): Returns the tangent of x."},
|
|
{"tanh", "tanh(x): Returns the hyperbolic tangent of x."},
|
|
{"tex1D", "tex1D(s, t): 1-D texture lookup."},
|
|
{"tex1D", "tex1D(s, t, ddx, ddy): 1-D texture lookup, with derivatives."},
|
|
{"tex1Dproj", "tex1Dproj(s, t): 1-D projective texture lookup."},
|
|
{"tex1Dbias", "tex1Dbias(s, t): 1-D biased texture lookup."},
|
|
{"tex1Dlod", "tex1Dlod(s, t): 1D texture lookup with LOD. s is a sampler or sampler1D object. t is a 4D vector. The mipmap LOD is specified in t."},
|
|
{"tex2D", "tex2D(s, t): 2-D texture lookup."},
|
|
{"tex2D", "tex2D(s, t, ddx, ddy): 2-D texture lookup, with derivatives."},
|
|
{"tex2Dproj", "tex2Dproj(s, t): 2-D projective texture lookup."},
|
|
{"tex2Dbias", "tex2Dbias(s, t): 2-D biased texture lookup."},
|
|
{"tex2Dlod", "tex2Dlod(s, t): 2D texture lookup with LOD. s is a sampler or sampler2D object. t is a 4D vector. The mipmap LOD is specified in t."},
|
|
{"tex3D", "tex3D(s, t): 3-D volume texture lookup."},
|
|
{"tex3D", "tex3D(s, t, ddx, ddy): 3-D volume texture lookup, with derivatives."},
|
|
{"tex3Dproj", "tex3Dproj(s, t): 3-D projective volume texture lookup."},
|
|
{"tex3Dbias", "tex3Dbias(s, t): 3-D biased texture lookup."},
|
|
{"tex3Dlod", "tex3Dlod(s, t): 3D texture lookup with LOD. s is a sampler or sampler3D object. t is a 4D vector. The mipmap LOD is specified in t."},
|
|
{"texCUBE", "texCUBE(s, t): 3-D cube texture lookup."},
|
|
{"texCUBE", "texCUBE(s, t, ddx, ddy): 3-D cube texture lookup, with derivatives."},
|
|
{"texCUBEproj", "texCUBEproj(s, t): 3-D projective cube texture lookup."},
|
|
{"texCUBEbias", "texCUBEbias(s, t): 3-D biased cube texture lookup."},
|
|
{"transpose", "transpose(m): Returns the transpose of the matrix m."},
|
|
{NULL, NULL}
|
|
|
|
};
|
|
_AddArray( kw, KC_INTRINSICS );
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_RegisterRenderstates(BOOL iUnregister)
|
|
{
|
|
{ //--- Render States
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
{"MaterialAmbient", NULL },
|
|
{"MaterialDiffuse", NULL },
|
|
{"MaterialEmissive", NULL },
|
|
{"MaterialPower", NULL },
|
|
{"MaterialSpecular", NULL },
|
|
|
|
{"LightAmbient[]", NULL },
|
|
{"LightAttenuation0[]", NULL },
|
|
{"LightAttenuation1[]", NULL },
|
|
{"LightAttenuation2[]", NULL },
|
|
{"LightDiffuse[]", NULL },
|
|
{"LightDirection[]", NULL },
|
|
{"LightEnable[]", NULL },
|
|
{"LightFalloff[]", NULL },
|
|
{"LightPhi[]", NULL },
|
|
{"LightPosition[]", NULL },
|
|
{"LightRange[]", NULL },
|
|
{"LightSpecular[]", NULL },
|
|
{"LightTheta[]", NULL },
|
|
{"LightType[]", NULL },
|
|
|
|
{"Ambient", NULL },
|
|
{"AmbientMaterialSource", NULL },
|
|
{"Clipping", NULL },
|
|
{"ClipPlaneEnable", NULL },
|
|
{"ColorVertex", NULL },
|
|
{"CullMode", NULL },
|
|
{"DiffuseMaterialSource", NULL },
|
|
{"EmissiveMaterialSource", NULL },
|
|
{"FogColor", NULL },
|
|
{"FogDensity", NULL },
|
|
{"FogEnable", NULL },
|
|
{"FogEnd", NULL },
|
|
{"FogStart", NULL },
|
|
{"FogTableMode", NULL },
|
|
{"FogVertexMode", NULL },
|
|
{"IndexedVertexBlendEnable", NULL },
|
|
{"Lighting", NULL },
|
|
{"LocalViewer", NULL },
|
|
{"MultiSampleAntialias", NULL },
|
|
{"MultiSampleMask", NULL },
|
|
{"NormalizeNormals", NULL },
|
|
{"PatchSegments", NULL },
|
|
{"PointScale_A", NULL },
|
|
{"PointScale_B", NULL },
|
|
{"PointScale_C", NULL },
|
|
{"PointScaleEnable", NULL },
|
|
{"PointSize", NULL },
|
|
{"PointSize_Min", NULL },
|
|
{"PointSize_Max", NULL },
|
|
{"PointSpriteEnable", NULL },
|
|
{"RangeFogEnable", NULL },
|
|
{"SpecularEnable", NULL },
|
|
{"SpecularMaterialSource", NULL },
|
|
{"TweenFactor", NULL },
|
|
{"VertexBlend", NULL },
|
|
|
|
{"AlphaBlendEnable", NULL },
|
|
{"AlphaFunc", NULL },
|
|
{"AlphaRef", NULL },
|
|
{"AlphaTestEnable", NULL },
|
|
{"BlendOp", NULL },
|
|
{"ColorWriteEnable", NULL },
|
|
{"DepthBias", NULL },
|
|
{"DestBlend", NULL },
|
|
{"DitherEnable", NULL },
|
|
{"FillMode", NULL },
|
|
{"LastPixel", NULL },
|
|
{"ShadeMode", NULL },
|
|
{"SrcBlend", NULL },
|
|
{"StencilEnable", NULL },
|
|
{"StencilFail", NULL },
|
|
{"StencilFunc", NULL },
|
|
{"StencilMask", NULL },
|
|
{"StencilPass", NULL },
|
|
{"StencilRef", NULL },
|
|
{"StencilWriteMask", NULL },
|
|
{"StencilZFail", NULL },
|
|
{"TextureFactor", NULL },
|
|
{"Wrap0", NULL },
|
|
{"Wrap1", NULL },
|
|
{"Wrap2", NULL },
|
|
{"Wrap3", NULL },
|
|
{"Wrap4", NULL },
|
|
{"Wrap5", NULL },
|
|
{"Wrap6", NULL },
|
|
{"Wrap7", NULL },
|
|
{"Wrap8", NULL },
|
|
{"Wrap9", NULL },
|
|
{"Wrap10", NULL },
|
|
{"Wrap11", NULL },
|
|
{"Wrap12", NULL },
|
|
{"Wrap13", NULL },
|
|
{"Wrap14", NULL },
|
|
{"Wrap15", NULL },
|
|
{"ZEnable", NULL },
|
|
{"ZFunc", NULL },
|
|
{"ZWriteEnable", NULL },
|
|
|
|
{"Sampler", NULL },
|
|
|
|
{"AddressU[]", NULL },
|
|
{"AddressV[]", NULL },
|
|
{"AddressW[]", NULL },
|
|
{"BorderColor[]", NULL },
|
|
{"MagFilter[]", NULL },
|
|
{"Magfilter[]", NULL },
|
|
{"MaxAnisotropy[]", NULL },
|
|
{"MaxMipLevel[]", NULL },
|
|
{"MinFilter[]", NULL },
|
|
{"Minfilter[]", NULL },
|
|
{"MipFilter[]", NULL },
|
|
{"MipMapLodBias[]", NULL },
|
|
{"SRGBTexture", NULL },
|
|
|
|
{"PixelShader", NULL },
|
|
{"VertexShader", NULL },
|
|
|
|
{"PixelShaderConstant", NULL },
|
|
{"PixelShaderConstant1", NULL },
|
|
{"PixelShaderConstant2", NULL },
|
|
{"PixelShaderConstant3", NULL },
|
|
{"PixelShaderConstant4", NULL },
|
|
{"PixelShaderConstantB", NULL },
|
|
{"PixelShaderConstantI", NULL },
|
|
{"PixelShaderConstantF", NULL },
|
|
|
|
{"VertexShaderConstant", NULL },
|
|
{"VertexShaderConstant1", NULL },
|
|
{"VertexShaderConstant2", NULL },
|
|
{"VertexShaderConstant3", NULL },
|
|
{"VertexShaderConstant4", NULL },
|
|
{"VertexShaderConstantB", NULL },
|
|
{"VertexShaderConstantI", NULL },
|
|
{"VertexShaderConstantF", NULL },
|
|
|
|
{"Texture", NULL },
|
|
|
|
{"AlphaOp[]", NULL },
|
|
{"AlphaArg0[]", NULL },
|
|
{"AlphaArg1[]", NULL },
|
|
{"AlphaArg2[]", NULL },
|
|
{"ColorArg0[]", NULL },
|
|
{"ColorArg1[]", NULL },
|
|
{"ColorArg2[]", NULL },
|
|
{"ColorOp[]", NULL },
|
|
{"BumpEnvLScale[]", NULL },
|
|
{"BumpEnvLOffset[]", NULL },
|
|
{"BumpEnvMat00[]", NULL },
|
|
{"BumpEnvMat01[]", NULL },
|
|
{"BumpEnvMat10[]", NULL },
|
|
{"BumpEnvMat11[]", NULL },
|
|
{"ResultArg[]", NULL },
|
|
{"TexCoordIndex[]", NULL },
|
|
{"TextureTransformFlags[]", NULL },
|
|
|
|
{"ProjectionTransform", NULL },
|
|
{"TextureTransform[]", NULL },
|
|
{"ViewTransform", NULL },
|
|
{"WorldTransform", NULL },
|
|
{"sampler_state", NULL },
|
|
|
|
{NULL, NULL}
|
|
};
|
|
if (iUnregister)
|
|
_RemoveArray( kw );
|
|
else
|
|
_AddArray( kw, KC_RENDERSTATE );
|
|
}
|
|
|
|
{ //--- SYNTAXShader
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
|
|
{"vs_1_1", NULL },
|
|
{"vs_2_0", NULL },
|
|
{"vs_3_0", NULL },
|
|
{"ps_1_1", NULL },
|
|
{"ps_1_2", NULL },
|
|
{"ps_1_3", NULL },
|
|
{"ps_1_4", NULL },
|
|
{"ps_2_0", NULL },
|
|
{"ps_3_0", NULL },
|
|
|
|
{NULL, NULL}
|
|
};
|
|
if (iUnregister)
|
|
_RemoveArray( kw );
|
|
else
|
|
_AddArray( kw, KC_SYNTAXShader );
|
|
}
|
|
|
|
{ //--- RENDERSTATE ENUMS
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
{"POINT", NULL },
|
|
{"SPOT", NULL },
|
|
{"DIRECTIONAL", NULL },
|
|
|
|
{"MATERIAL", NULL },
|
|
{"COLOR1", NULL },
|
|
{"COLOR2", NULL },
|
|
|
|
{"CLIPPLANE0", NULL },
|
|
{"CLIPPLANE1", NULL },
|
|
{"CLIPPLANE2", NULL },
|
|
{"CLIPPLANE3", NULL },
|
|
{"CLIPPLANE4", NULL },
|
|
{"CLIPPLANE5", NULL },
|
|
|
|
{"NONE", NULL },
|
|
|
|
{"CW", NULL },
|
|
{"CCW", NULL },
|
|
|
|
{"EXP", NULL },
|
|
{"EXP2", NULL },
|
|
{"LINEAR", NULL },
|
|
|
|
{"1WEIGHTS", NULL },
|
|
{"2WEIGHTS", NULL },
|
|
{"3WEIGHTS", NULL },
|
|
{"TWEENING", NULL },
|
|
{"0WEIGHTS", NULL },
|
|
|
|
{"NEVER", NULL },
|
|
{"LESS", NULL },
|
|
{"EQUAL", NULL },
|
|
{"LESSEQUAL", NULL },
|
|
{"GREATER", NULL },
|
|
{"NOTEQUAL", NULL },
|
|
{"GREATEREQUAL", NULL },
|
|
{"ALWAYS", NULL },
|
|
|
|
{"ADD", NULL },
|
|
{"SUBTRACT", NULL },
|
|
{"REVSUBTRACT", NULL },
|
|
{"MIN", NULL },
|
|
{"MAX", NULL },
|
|
|
|
{"RED", NULL },
|
|
{"GREEN", NULL },
|
|
{"BLUE", NULL },
|
|
{"ALPHA", NULL },
|
|
|
|
{"ZERO", NULL },
|
|
{"ONE", NULL },
|
|
{"SRCCOLOR", NULL },
|
|
{"INVSRCCOLOR", NULL },
|
|
{"SRCALPHA", NULL },
|
|
{"INVSRCALPHA", NULL },
|
|
{"DESTALPHA", NULL },
|
|
{"INVDESTALPHA", NULL },
|
|
{"DESTCOLOR", NULL },
|
|
{"INVDESTCOLOR", NULL },
|
|
{"SRCALPHASAT", NULL },
|
|
{"BOTHSRCALPHA", NULL },
|
|
{"BOTHINVSRCALPHA", NULL },
|
|
{"BLENDFACTOR", NULL },
|
|
{"INVBLENDFACTOR", NULL },
|
|
|
|
//{"POINT", NULL }, // Already defined for LightType
|
|
{"WIREFRAME", NULL },
|
|
{"SOLID", NULL },
|
|
|
|
{"FLAT", NULL },
|
|
{"SHADE_GOURAUD", NULL },
|
|
{"SHADE_PHONG", NULL },
|
|
|
|
{"KEEP", NULL },
|
|
//{"ZERO", NULL }, // Already defined for SrcBlend
|
|
{"REPLACE", NULL },
|
|
{"INCRSAT", NULL },
|
|
{"DECRSAT", NULL },
|
|
{"INVERT", NULL },
|
|
{"INCR", NULL },
|
|
{"DECR", NULL },
|
|
//{"TWOSIDED", NULL },
|
|
|
|
{"COORD0", NULL },
|
|
{"COORD1", NULL },
|
|
{"COORD2", NULL },
|
|
{"COORD3", NULL },
|
|
|
|
{"U", NULL },
|
|
{"V", NULL },
|
|
{"W", NULL },
|
|
|
|
{"FALSE", NULL },
|
|
{"TRUE", NULL },
|
|
{"USEW", NULL },
|
|
|
|
//{"NONE", NULL }, // Already defined
|
|
//{"POINT", NULL }, // Already defined
|
|
//{"LINEAR", NULL } // Already defined
|
|
{"ANISOTROPIC", NULL },
|
|
{"PYRAMIDALQUAD", NULL },
|
|
{"GAUSSIANQUAD", NULL },
|
|
|
|
{"DISABLE", NULL },
|
|
{"SELECTARG1", NULL },
|
|
{"SELECTARG2", NULL },
|
|
{"MODULATE", NULL },
|
|
{"MODULATE2X", NULL },
|
|
{"MODULATE4X", NULL },
|
|
//{"ADD", NULL }, // Already defined
|
|
{"ADDSIGNED", NULL },
|
|
{"ADDSIGNED2X", NULL },
|
|
//{"SUBTRACT", NULL },// Already defined
|
|
{"ADDSMOOTH", NULL },
|
|
{"BLENDDIFFUSEALPHA", NULL },
|
|
{"BLENDTEXTUREALPHA", NULL },
|
|
{"BLENDFACTORALPHA", NULL },
|
|
{"BLENDTEXTUREALPHAPM", NULL },
|
|
{"BLENDCURRENTALPHA", NULL },
|
|
{"PREMODULATE", NULL },
|
|
{"MODULATEALPHA_ADDCOLOR", NULL },
|
|
{"MODULATECOLOR_ADDALPHA", NULL },
|
|
{"MODULATEINVALPHA_ADDCOLOR", NULL },
|
|
{"MODULATEINVCOLOR_ADDALPHA", NULL },
|
|
{"BUMPENVMAP", NULL },
|
|
{"BUMPENVMAPLUMINANCE", NULL },
|
|
{"DOTPRODUCT3", NULL },
|
|
{"MULTIPLYADD", NULL },
|
|
{"LERP", NULL },
|
|
|
|
{"CURRENT", NULL },
|
|
{"DIFFUSE",
|
|
"- as a Virtools semantic: Virtools material's diffuse color\n"
|
|
"- as render state: renderstate enum standing for diffuse stage\n"
|
|
"- as a Vertex Shader Input semantic: the input vertex diffuse color"
|
|
},
|
|
{"SELECTMASK", NULL },
|
|
{"SPECULAR",
|
|
"- as a Virtools semantic: Virtools material's specular color\n"
|
|
"- as a VS input semantic: the input vertex specular color"
|
|
},
|
|
{"TEMP", NULL },
|
|
{"TEXTURE",
|
|
"- as a Virtools semantic: Virtools material's texture\n"
|
|
"- as render state: renderstate enum standing for texture stage"
|
|
},
|
|
{"TFACTOR", NULL },
|
|
|
|
{"ALPHAREPLICATE", NULL },
|
|
{"COMPLEMENT", NULL },
|
|
|
|
{"PASSTHRU", NULL },
|
|
{"CAMERASPACENORMAL", NULL },
|
|
{"CAMERASPACEPOSITION", NULL },
|
|
{"CAMERASPACEREFLECTIONVECTOR", NULL },
|
|
{"SPHEREMAP", NULL },
|
|
|
|
//{"DISABLE", NULL }, // Already defined
|
|
{"COUNT1", NULL },
|
|
{"COUNT2", NULL },
|
|
{"COUNT3", NULL },
|
|
{"COUNT4", NULL },
|
|
{"PROJECTED", NULL },
|
|
|
|
{"WRAP", NULL },
|
|
{"MIRROR", NULL },
|
|
{"CLAMP", NULL },
|
|
{"BORDER", NULL },
|
|
{"MIRRORONCE", NULL },
|
|
|
|
{NULL, NULL}
|
|
};
|
|
if (iUnregister)
|
|
_RemoveArray( kw );
|
|
else
|
|
_AddArray( kw, KC_RENDERSTATE_ENUM );
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_RegisterCgGLRenderstates(BOOL iUnregister)
|
|
{
|
|
{ //--- Render States
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
{"AlphaFunc", NULL },
|
|
{"BlendFunc", NULL },
|
|
{"BlendFuncSeparate", NULL },
|
|
{"BlendEquation", NULL },
|
|
{"BlendEquationSeparate ", NULL },
|
|
{"BlendColor", NULL },
|
|
{"ClearColor", NULL },
|
|
{"ClearStencil", NULL },
|
|
{"ClearDepth", NULL },
|
|
{"ClipPlane", NULL },
|
|
{"ColorMask", NULL },
|
|
{"ColorMatrix", NULL },
|
|
{"ColorMaterial", NULL },
|
|
{"CullFace", NULL },
|
|
{"DepthBounds", NULL },
|
|
{"DepthFunc", NULL },
|
|
{"DepthMask", NULL },
|
|
{"DepthRange", NULL },
|
|
{"FogMode", NULL },
|
|
{"FogDensity", NULL },
|
|
{"FogStart", NULL },
|
|
{"FogEnd", NULL },
|
|
{"FogColor", NULL },
|
|
{"FragmentEnvParameter", NULL },
|
|
{"FragmentLocalParameter", NULL },
|
|
{"FogCoordSrc", NULL },
|
|
{"FogDistanceMode", NULL },
|
|
{"FrontFace", NULL },
|
|
{"LightModelAmbient", NULL },
|
|
{"LightAmbient[]", NULL },
|
|
{"LightConstantAttenuation[]", NULL },
|
|
{"LightDiffuse[]", NULL },
|
|
{"LightLinearAttenuation[]", NULL },
|
|
{"LightPosition[]", NULL },
|
|
{"LightQuadraticAttenuation[]", NULL },
|
|
{"LightSpecular[]", NULL },
|
|
{"LightSpotCutoff[]", NULL },
|
|
{"LightSpotDirection[]", NULL },
|
|
{"LightSpotExponent[]", NULL },
|
|
{"LightModelColorControl[]", NULL },
|
|
{"LineStipple[]", NULL },
|
|
{"LineWidth", NULL },
|
|
{"LogicOp", NULL },
|
|
|
|
{"MaterialAmbient", NULL },
|
|
{"MaterialDiffuse", NULL },
|
|
{"MaterialEmission", NULL },
|
|
{"MaterialEmissive", NULL },
|
|
{"MaterialShininess", NULL },
|
|
{"MaterialSpecular", NULL },
|
|
{"ModelViewMatrix", NULL },
|
|
{"PointDistanceAttenuation", NULL },
|
|
{"PointFadeThresholdSize", NULL },
|
|
{"PointSize", NULL },
|
|
{"PointSizeMin", NULL },
|
|
{"PointSizeMax", NULL },
|
|
{"PointSpriteCoordOrigin", NULL },
|
|
{"PointSpriteCoordReplace[]", NULL },
|
|
{"PointSpriteRMode", NULL },
|
|
{"PolygonMode", NULL },
|
|
{"PolygonOffset", NULL },
|
|
{"ProjectionMatrix", NULL },
|
|
{"Scissor", NULL },
|
|
{"ShadeModel", NULL },
|
|
{"StencilFunc", NULL },
|
|
{"StencilMask", NULL },
|
|
{"StencilOp", NULL },
|
|
{"StencilFuncSeparate", NULL },
|
|
{"StencilMaskSeparate", NULL },
|
|
{"StencilOpSeparate", NULL },
|
|
{"TexGenSMode[]", NULL },
|
|
{"TexGenTMode[]", NULL },
|
|
{"TexGenRMode[]", NULL },
|
|
{"TexGenQMode[]", NULL },
|
|
{"TexGenSEyePlane[]", NULL },
|
|
{"TexGenTEyePlane[]", NULL },
|
|
{"TexGenREyePlane[]", NULL },
|
|
{"TexGenQEyePlane[]", NULL },
|
|
{"TexGenSObjectPlane[]", NULL },
|
|
{"TexGenTObjectPlane[]", NULL },
|
|
{"TexGenRObjectPlane[]", NULL },
|
|
{"TexGenQObjectPlane[]", NULL },
|
|
{"TextureEnvColor[]", NULL },
|
|
{"TextureEnvMode[]", NULL },
|
|
{"VertexEnvParameter[]", NULL },
|
|
{"VertexLocalParameter[]", NULL },
|
|
|
|
{"AlphaTestEnable", NULL },
|
|
{"AutoNormalEnable", NULL },
|
|
{"BlendEnable", NULL },
|
|
{"ClipPlaneEnable[]", NULL },
|
|
{"ColorLogicOpEnable", NULL },
|
|
{"CullFaceEnable", NULL },
|
|
{"DepthBoundsEnable", NULL },
|
|
{"DepthClampEnable", NULL },
|
|
{"DepthTestEnable", NULL },
|
|
{"DitherEnable", NULL },
|
|
{"FogEnable", NULL },
|
|
{"LightEnable[]", NULL },
|
|
{"LightingEnable", NULL },
|
|
{"LightModelLocalViewerEnable", NULL },
|
|
{"LightModelTwoSideEnable", NULL },
|
|
{"LineSmoothEnable", NULL },
|
|
{"LineStippleEnable", NULL },
|
|
{"LogicOpEnable", NULL },
|
|
{"MultisampleEnable", NULL },
|
|
{"NormalizeEnable", NULL },
|
|
{"PointSmoothEnable", NULL },
|
|
{"PointSpriteEnable", NULL },
|
|
{"PolygonOffsetFillEnable", NULL },
|
|
{"PolygonOffsetLineEnable", NULL },
|
|
{"PolygonOffsetPointEnable", NULL },
|
|
{"PolygonSmoothEnable", NULL },
|
|
{"PolygonStippleEnable", NULL },
|
|
{"RescaleNormalEnable", NULL },
|
|
{"SampleAlphaToCoverageEnable", NULL },
|
|
{"SampleAlphaToOneEnable", NULL },
|
|
{"SampleCoverageEnable", NULL },
|
|
{"ScissorTestEnable", NULL },
|
|
{"StencilTestEnable", NULL },
|
|
{"TexGenSEnable[]", NULL },
|
|
{"TexGenTEnable[]", NULL },
|
|
{"TexGenREnable[]", NULL },
|
|
{"TexGenQEnable[]", NULL },
|
|
{"Texture1DEnable[]", NULL },
|
|
{"Texture2DEnable[]", NULL },
|
|
{"Texture3DEnable[]", NULL },
|
|
{"TextureRectangleEnable[]", NULL },
|
|
{"TextureCubeMapEnable[]", NULL },
|
|
|
|
|
|
{"Sampler", NULL },
|
|
|
|
{"WrapS[]", NULL },
|
|
{"WrapT[]", NULL },
|
|
{"WrapR[]", NULL },
|
|
{"BorderColor[]", NULL },
|
|
{"CompareMode[]", NULL },
|
|
{"CompareFunc[]", NULL },
|
|
{"DepthMode[]", NULL },
|
|
{"GenerateMipMap[]", NULL },
|
|
{"MagFilter[]", NULL },
|
|
{"Magfilter[]", NULL },
|
|
{"MaxAnisotropy[]", NULL },
|
|
{"MaxMipLevel[]", NULL },
|
|
{"MinMipLevel[]", NULL },
|
|
{"MinFilter[]", NULL },
|
|
{"Minfilter[]", NULL },
|
|
{"LODBias[]", NULL },
|
|
|
|
{"FragmentProgram", NULL },
|
|
{"VertexProgram", NULL },
|
|
|
|
{"Texture", NULL },
|
|
|
|
|
|
{"ProjectionTransform", NULL },
|
|
{"TextureTransform[]", NULL },
|
|
{"ViewTransform", NULL },
|
|
{"WorldTransform", NULL },
|
|
{"sampler_state", NULL },
|
|
|
|
{NULL, NULL}
|
|
};
|
|
if (iUnregister)
|
|
_RemoveArray( kw );
|
|
else
|
|
_AddArray( kw, KC_RENDERSTATE );
|
|
}
|
|
|
|
{ //--- SYNTAXShader
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
|
|
{"arbvp1", NULL },
|
|
{"vp20", NULL },
|
|
{"vp30", NULL },
|
|
{"vp40", NULL },
|
|
{"arbfp1", NULL },
|
|
{"fp20", NULL },
|
|
{"fp30", NULL },
|
|
{"fp40", NULL },
|
|
|
|
{NULL, NULL}
|
|
};
|
|
if (iUnregister)
|
|
_RemoveArray( kw );
|
|
else
|
|
_AddArray( kw, KC_SYNTAXShader );
|
|
}
|
|
|
|
{ //--- RENDERSTATE ENUMS
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
{"NONE", NULL },
|
|
|
|
{"CW", NULL },
|
|
{"CCW", NULL },
|
|
|
|
{"EXP", NULL },
|
|
{"EXP2", NULL },
|
|
{"LINEAR", NULL },
|
|
|
|
{"NEVER", NULL },
|
|
{"LESS", NULL },
|
|
{"LEQUAL", NULL },
|
|
{"EQUAL", NULL },
|
|
{"GREATER", NULL },
|
|
{"NOTEQUAL", NULL },
|
|
{"GEQUAL", NULL },
|
|
{"ALWAYS", NULL },
|
|
|
|
{"ZERO", NULL },
|
|
{"ONE", NULL },
|
|
{"DESTCOLOR", NULL },
|
|
{"ONEMINUSDESTCOLOR", NULL },
|
|
{"SRCALPHA", NULL },
|
|
{"ONEMINUSSRCALPHA", NULL },
|
|
{"DSTALPHA", NULL },
|
|
{"ONEMINUSDSTALPHA", NULL },
|
|
{"SRCALPHASATURATE", NULL },
|
|
{"SRCCOLOR", NULL },
|
|
{"ONEMINUSSRCCOLOR", NULL },
|
|
{"CONSTANTCOLOR", NULL },
|
|
{"ONEMINUSCONSTANTCOLOR", NULL },
|
|
{"CONSTANTALPHA", NULL },
|
|
{"ONEMINUSCONSTANTALPHA", NULL },
|
|
|
|
{"FUNCADD", NULL },
|
|
{"FUNCSUBTRACT", NULL },
|
|
{"MIN", NULL },
|
|
{"MAX", NULL },
|
|
{"LOGICOP", NULL },
|
|
|
|
{"FRONT", NULL },
|
|
{"BACK", NULL },
|
|
{"FRONTANDBACK", NULL },
|
|
|
|
{"FRAGMENTDEPTH", NULL },
|
|
{"FOGCOORD", NULL },
|
|
{"EYERADIAL", NULL },
|
|
{"EYEPLANE", NULL },
|
|
{"EYEPLANEABSOLUTE", NULL },
|
|
|
|
{"SINGLECOLOR", NULL },
|
|
{"SEPARATESPECULAR", NULL },
|
|
|
|
{"CLEAR", NULL },
|
|
{"AND", NULL },
|
|
{"ANDREVERSE", NULL },
|
|
{"COPY", NULL },
|
|
{"ANDINVERTED", NULL },
|
|
{"NOOP", NULL },
|
|
{"XOR", NULL },
|
|
{"OR", NULL },
|
|
{"NOR", NULL },
|
|
{"EQUIV", NULL },
|
|
{"INVERT", NULL },
|
|
{"ORREVERSE", NULL },
|
|
{"COPYINVERTED", NULL },
|
|
{"NAND", NULL },
|
|
{"SET", NULL },
|
|
|
|
{"LOWERLEFT", NULL },
|
|
{"UPPERLEFT", NULL },
|
|
|
|
{"R", NULL },
|
|
{"S", NULL },
|
|
|
|
{"POINT", NULL },
|
|
{"LINE", NULL },
|
|
{"FILL", NULL },
|
|
{"FLAT", NULL },
|
|
{"SMOOTH", NULL },
|
|
|
|
{"KEEP", NULL },
|
|
{"REPLACE", NULL },
|
|
{"INCR", NULL },
|
|
{"DECR", NULL },
|
|
{"INCRWRAP", NULL },
|
|
{"DECRWRAP", NULL },
|
|
|
|
{"OBJECTLINEAR", NULL },
|
|
{"EYELINEAR", NULL },
|
|
{"SPHEREMAP", NULL },
|
|
{"REFLECTIONMAP", NULL },
|
|
{"NORMALMAP", NULL },
|
|
|
|
{"MODULATE", NULL },
|
|
{"DECAL", NULL },
|
|
{"BLEND", NULL },
|
|
{"ADD", NULL },
|
|
|
|
{"FALSE", NULL },
|
|
{"TRUE", NULL },
|
|
|
|
{"EMISSION", NULL },
|
|
{"AMBIENT", NULL },
|
|
{"AMBIENTANDDIFFUSE", NULL },
|
|
{"DIFFUSE",
|
|
"- as a Virtools semantic: Virtools material's diffuse color\n"
|
|
"- as render state: renderstate enum standing for diffuse stage\n"
|
|
"- as a Vertex Shader Input semantic: the input vertex diffuse color"
|
|
},
|
|
{"SPECULAR",
|
|
"- as a Virtools semantic: Virtools material's specular color\n"
|
|
"- as a VS input semantic: the input vertex specular color"
|
|
},
|
|
|
|
{"TEXTURE",
|
|
"- as a Virtools semantic: Virtools material's texture\n"
|
|
"- as render state: renderstate enum standing for texture stage"
|
|
},
|
|
|
|
{"REPEAT", NULL },
|
|
{"CLAMP", NULL },
|
|
{"CLAMPTOEDGE", NULL },
|
|
{"CLAMPTOBORDER", NULL },
|
|
{"MIRROREDREPEAT", NULL },
|
|
{"MIRROREDCLAMP", NULL },
|
|
{"MIRROREDCLAMPTOEDGE", NULL },
|
|
{"MIRROREDCLAMPTOBORDER", NULL },
|
|
|
|
{"COMPARERTOTEXTURE", NULL },
|
|
|
|
{"ALPHA", NULL },
|
|
{"INTENSITY", NULL },
|
|
{"LUMINANCE", NULL },
|
|
|
|
{"NEAREST", NULL },
|
|
{"LINEARMIPMAPNEAREST", NULL },
|
|
{"NEARESTMIPMAPNEAREST", NULL },
|
|
{"NEARESTMIPMAPLINEAR", NULL },
|
|
{"LINEARMIPMAPLINEAR", NULL },
|
|
|
|
{NULL, NULL}
|
|
};
|
|
if (iUnregister)
|
|
_RemoveArray( kw );
|
|
else
|
|
_AddArray( kw, KC_RENDERSTATE_ENUM );
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void ShaderEditorDlg::_RegisterSemantics()
|
|
{
|
|
//--- Virtools Semantics
|
|
_SetCurrentColor( KC_SEMANTICS_VR );
|
|
|
|
XString* semDesc = NULL;
|
|
int a;
|
|
|
|
const XClassArray<XString>& semOriginalNames = m_ShaderManager->GetSemanticOriginalNames();
|
|
const int semOriginalCount = semOriginalNames.Size();
|
|
|
|
for( a=0 ; a<semOriginalCount ; ++a ){
|
|
|
|
XString semName = semOriginalNames[a];
|
|
int semIndex = m_ShaderManager->GetSemanticIndexFromString( semName );
|
|
m_ShaderManager->GetSemanticDesc( semIndex, semDesc );
|
|
|
|
_Add( semName.Str(), semDesc->Str() );
|
|
_Add( semName.ToUpper().Str(), semDesc->Str() );
|
|
}
|
|
|
|
//--- Virtools Annotations
|
|
_SetCurrentColor( KC_ANNOTATIONS_VR );
|
|
|
|
const XClassArray<XString>& annotOriginalNames = m_ShaderManager->GetAnnotationOriginalNames();
|
|
const int annotOriginalCount = annotOriginalNames.Size();
|
|
|
|
for( a=0 ; a<annotOriginalCount ; ++a ){
|
|
|
|
XString annotName = annotOriginalNames[a];
|
|
_Add( annotName.Str() );
|
|
_Add( annotName.ToLower().Str() );
|
|
}
|
|
|
|
//--- HLSL Semantics
|
|
// Color only
|
|
KeywordAndDesc kw[] =
|
|
{
|
|
//--- HLSL semantics
|
|
{ "POSITION?", NULL },
|
|
{ "BLENDWEIGHT?", NULL },
|
|
{ "BLENDINDICES?", NULL },
|
|
{ "NORMAL?", NULL },
|
|
{ "PSIZE?", NULL },
|
|
{ "DIFFUSE?", NULL },
|
|
{ "SPECULAR?", NULL },
|
|
{ "TEXCOORD?", NULL },
|
|
{ "TANGENT?", NULL },
|
|
{ "BINORMAL?", NULL },
|
|
{ "TESSFACTOR?", NULL },
|
|
{ "COLOR?", NULL },
|
|
{ "FOG", NULL },
|
|
{ "DEPTH?",NULL},
|
|
{ "VFACE",NULL},
|
|
{ "VPOS",NULL},
|
|
|
|
{ NULL, NULL }
|
|
};
|
|
_AddArray( kw, KC_SEMANTICS );
|
|
}
|