here are a couple of helper shaders (scripts), for viewing your meshes in wireframe or point render mode. might be useful in some cases while editing.
you can set the color of your choice.
wireframe:
you can set the color of your choice.
wireframe:
Code: [Select]
//******************************************************************
//SHADERS
//******************************************************************
/*HLSLSTART WireFrame_Fx_1_1
//---------------------------------------------------------------------
// fillmode - Wireframe
//---------------------------------------------------------------------
float Script : STANDARDSGLOBAL <
string UIWidget = "none";
string ScriptClass = "object";
string ScriptOrder = "standard";
string ScriptOutput = "color";
string Script = "Technique=NoSkinning;";
> = 0.8;
//---------------------------------------------------------------------
//*****************************************************************************
//MATRIX
//*****************************************************************************
#define MATRIX_PALETTE_SIZE_DEFAULT 26
const int MATRIX_PALETTE_SIZE = MATRIX_PALETTE_SIZE_DEFAULT;
float4x3 amPalette[MATRIX_PALETTE_SIZE_DEFAULT];
float4x4 mxWorld : WORLD;
float4x4 mxWorldIT : amPalette; //to transform normals (note: we can re-use bone matrices registers as this will only be set for non-skinned meshes)
float4x4 mxViewProj : VIEWPROJECTION;
//*****************************************************************************
//LIGHT PROPERTIES
//*****************************************************************************
float4 lightDir : DIRECTION = {0.0f,0.0f,-1.0f,1.0f};
float4 lightColor : DIFFUSE = {1.0f,1.0f,1.0f,1.0f};
float4 lightAmbient : AMBIENT = {0.1f,0.1f,0.1f,1.0f};
//*****************************************************************************
//MATERIAL PROPERTIES
//*****************************************************************************
float4 MaterialDiffuse : DIFFUSE = {1.0f,1.0f,1.0f,1.0f};
float4 OverlayColor = {1.0f,1.0f,1.0f,1.0f};
//*****************************************************************************
//USED IN VERTEX SHADER
//*****************************************************************************
float3 worldEyePos;
//*****************************************************************************
//TEXTURE
//*****************************************************************************
texture diffuseMap : DIFFUSE <
string ResourceName = "default_color.dds";
string UIName = "Color Texture";
string ResourceType = "2D";
>;
//*****************************************************************************
//SKINNING STUFF
//*****************************************************************************
int boneCount = 2;
struct VS_SKIN_INPUT
{
float4 vPos;
float3 vBlendWeights;
float4 vBlendIndices;
float3 vNor;
};
struct VS_SKIN_OUTPUT
{
float4 vPos;
float3 vNor;
};
VS_SKIN_OUTPUT VS_Skin( const VS_SKIN_INPUT vInput, int iNumBones )
{
//This function is called by VertSkinning(), the main
//vertex shader function for skinned meshes
//It applies bone matrices to vertex coordinates and normal,
//which also transforms from model-space to world space
VS_SKIN_OUTPUT vOutput = (VS_SKIN_OUTPUT) 0;
float fLastWeight = 1.0;
float fWeight;
float afBlendWeights[3] = (float[3])vInput.vBlendWeights;
int aiIndices[4] = (int[4])D3DCOLORtoUBYTE4(vInput.vBlendIndices);
for (int iBone=0;(iBone<3) && (iBone<(iNumBones-1));iBone++)
{
fWeight = afBlendWeights[iBone];
fLastWeight -= fWeight;
vOutput.vPos.xyz += mul(vInput.vPos,amPalette[aiIndices[iBone]])*fWeight;
vOutput.vNor += mul(vInput.vNor,amPalette[aiIndices[iBone]])*fWeight;
}
vOutput.vPos.xyz += mul(vInput.vPos,amPalette[aiIndices[iNumBones-1]])*fLastWeight;
vOutput.vNor += mul(vInput.vNor,amPalette[aiIndices[iNumBones-1]])*fLastWeight;
return vOutput;
}
//*****************************************************************************
//TEXTURE SAMPLER
//*****************************************************************************
sampler DiffuseMapSampler = sampler_state
{
Texture = <diffuseMap>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
//*****************************************************************************
//INPUT - OUTPUT
//*****************************************************************************
struct VS_INPUT
{
float4 Pos : POSITION;
float3 BlendWeights : BLENDWEIGHT;
float4 BlendIndices : BLENDINDICES;
float3 Normal : NORMAL;
float2 Tex0 : TEXCOORD0;
};
struct VS_INPUT_NOSKIN
{
float4 Pos : POSITION;
float3 Normal : NORMAL;
float2 Tex0 : TEXCOORD0;
};
struct VS_OUTPUT
{
float4 Pos : POSITION;
float2 Tex0 : TEXCOORD0;
};
//*****************************************************************************
//VERTEX SHADER - SKINNED
//*****************************************************************************
VS_OUTPUT VertSkinning(VS_INPUT IN, uniform int iNumBones)
{
//-------------------------------------------------------------------------
//Vertex shader used for skinned meshes
VS_OUTPUT OUT;
VS_SKIN_INPUT vsi = { IN.Pos, IN.BlendWeights, IN.BlendIndices, IN.Normal };
VS_SKIN_OUTPUT vso = VS_Skin( vsi, iNumBones );
//-------------------------------------------------------------------------
//vpos
OUT.Pos = mul(float4(vso.vPos.xyz,1.0f),mxViewProj);
//-------------------------------------------------------------------------
//uv coords
OUT.Tex0 = IN.Tex0;
return OUT;
}
//*****************************************************************************
//VERTEX SHADER - NON SKINNED
//*****************************************************************************
VS_OUTPUT VertNoSkinning(VS_INPUT_NOSKIN IN)
{
//-------------------------------------------------------------------------
//Vertex shader used for static meshes
VS_OUTPUT OUT;
//-------------------------------------------------------------------------
//vpos
OUT.Pos = mul(float4(IN.Pos.xyz,1.0f),mxViewProj);
//-------------------------------------------------------------------------
//uv coords
OUT.Tex0 = IN.Tex0;
return OUT;
}
//*****************************************************************************
//PIXEL SHADER
//*****************************************************************************
float4 PixScene(VS_OUTPUT IN): COLOR
{
//Pixel shader
return OverlayColor;
}
//*****************************************************************************
//TECHNIQUES
//*****************************************************************************
VertexShader vsArray[4] = { compile vs_1_1 VertSkinning(1),
compile vs_1_1 VertSkinning(2),
compile vs_1_1 VertSkinning(3),
compile vs_1_1 VertSkinning(4) };
technique Skinning
{
pass p0
{
VertexShader = (vsArray[boneCount]);
PixelShader = compile ps_1_1 PixScene();
FillMode = wireframe;
}
}
technique NoSkinning
{
pass p0
{
VertexShader = compile vs_1_1 VertNoSkinning();
PixelShader = compile ps_1_1 PixScene();
FillMode = wireframe;
}
}
HLSLEND*/
//******************************************************************
//VALUES
//******************************************************************
//------------------------------------------------------------------
float[] cOverlayColor(4);
int cObjectCount = 0;
int[] cObjectIdList(100);
//******************************************************************
//MAIN
//******************************************************************
void Main()
{
//***************************************************************
//INITIALIZATION SECTION
//***************************************************************
if (iInitializing())
{
//------------------------------------------------------------
//wireframe shader
cOverlayColor[0] = 1.0f;//red
cOverlayColor[1] = 0.0f;//green
cOverlayColor[2] = 0.0f;//blue
cOverlayColor[3] = 1.0f;//alpha
cObjectCount = 0;
while (iObjectHandle(cObjectCount) != -1)
{
cObjectIdList[cObjectCount] = iObjectHandle(cObjectCount);
iShaderSet(cObjectIdList[cObjectCount],"WireFrame_Fx_1_1");
cObjectCount++;
}
//------------------------------------------------------------
}
//***************************************************************
//UPDATE SECTION
//***************************************************************
//---------------------------------------------------------------
//shaders - wireframe - set color
for(int i=0;i<cObjectCount;i++)
{
iShaderFloat4Set(cObjectIdList[i],"OverlayColor",cOverlayColor[0],cOverlayColor[1],cOverlayColor[2],cOverlayColor[3]);
}
//---------------------------------------------------------------
//***************************************************************
//DEINITIALIZATION SECTION
//***************************************************************
//if(iDeinitializing())
//{
//------------------------------------------------------------
//------------------------------------------------------------
//}
//---------------------------------------------------------------
}
//******************************************************************END OF MAIN