- adding fallback effects for non-shader graphics hardware. Work In Progress.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@172 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
286d33d30a
commit
23c99f2176
|
@ -43,8 +43,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "assimp_view.h"
|
#include "assimp_view.h"
|
||||||
|
|
||||||
|
|
||||||
namespace AssimpView {
|
namespace AssimpView
|
||||||
|
{
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
std::string g_szNormalsShader = std::string(
|
std::string g_szNormalsShader = std::string(
|
||||||
|
|
||||||
// World * View * Projection matrix\n"
|
// World * View * Projection matrix\n"
|
||||||
|
@ -52,29 +54,27 @@ std::string g_szNormalsShader = std::string(
|
||||||
"float4x4 WorldViewProjection : WORLDVIEWPROJECTION;\n"
|
"float4x4 WorldViewProjection : WORLDVIEWPROJECTION;\n"
|
||||||
"float4 OUTPUT_COLOR;\n"
|
"float4 OUTPUT_COLOR;\n"
|
||||||
|
|
||||||
|
// Vertex shader input structure
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Vertex shader input structure\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_INPUT\n"
|
"struct VS_INPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"// Position\n"
|
"// Position\n"
|
||||||
"float3 Position : POSITION;\n"
|
"float3 Position : POSITION;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Vertex shader output structure for pixel shader usage
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Vertex shader output structure\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_OUTPUT\n"
|
"struct VS_OUTPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"// Position\n"
|
|
||||||
"float4 Position : POSITION;\n"
|
"float4 Position : POSITION;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Vertex shader output structure for FixedFunction usage
|
||||||
// Vertex shader\n"
|
"struct VS_OUTPUT_FF\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
"{\n"
|
||||||
|
"float4 Position : POSITION;\n"
|
||||||
|
"float4 Color : COLOR;\n"
|
||||||
|
"};\n"
|
||||||
|
|
||||||
|
// Vertex shader for rendering normals using pixel shader
|
||||||
"VS_OUTPUT RenderNormalsVS(VS_INPUT IN)\n"
|
"VS_OUTPUT RenderNormalsVS(VS_INPUT IN)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"// Initialize the output structure with zero\n"
|
"// Initialize the output structure with zero\n"
|
||||||
|
@ -86,19 +86,22 @@ std::string g_szNormalsShader = std::string(
|
||||||
"return Out;\n"
|
"return Out;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
// Vertex shader for rendering normals using fixed function pipeline
|
||||||
|
"VS_OUTPUT RenderNormalsVS_FF(VS_INPUT IN)\n"
|
||||||
|
"{\n"
|
||||||
|
"VS_OUTPUT_FF Out;\n"
|
||||||
|
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
||||||
|
"Out.Color = OUTPUT_COLOR;\n"
|
||||||
|
"return Out;\n"
|
||||||
|
"}\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Pixel shader
|
||||||
// Pixel shader\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"float4 RenderNormalsPS() : COLOR\n"
|
"float4 RenderNormalsPS() : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"return OUTPUT_COLOR;\n"
|
"return OUTPUT_COLOR;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
// Technique for the normal rendering effect (ps_2_0)
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Technique for the normal rendering effect (ps_2_0)\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique RenderNormals\n"
|
"technique RenderNormals\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -108,13 +111,26 @@ std::string g_szNormalsShader = std::string(
|
||||||
"VertexShader = compile vs_2_0 RenderNormalsVS();\n"
|
"VertexShader = compile vs_2_0 RenderNormalsVS();\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Technique for the normal rendering effect (fixed function)
|
||||||
|
"technique RenderNormals_FF\n"
|
||||||
|
"{\n"
|
||||||
|
"pass p0\n"
|
||||||
|
"{\n"
|
||||||
|
"CullMode=none;\n"
|
||||||
|
"VertexShader = compile vs_2_0 RenderNormalsVS_FF();\n"
|
||||||
|
"ColorOp[0] = SelectArg0;\n"
|
||||||
|
"ColorArg0[0] = Diffuse;\n"
|
||||||
|
"AlphaOp[0] = SelectArg0;\n"
|
||||||
|
"AlphaArg0[0] = Diffuse;\n"
|
||||||
|
"}\n"
|
||||||
|
"};\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
std::string g_szSkyboxShader = std::string(
|
std::string g_szSkyboxShader = std::string(
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Sampler and texture for the skybox
|
||||||
// Sampler and texture for the skybox\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"textureCUBE lw_tex_envmap;\n"
|
"textureCUBE lw_tex_envmap;\n"
|
||||||
"samplerCUBE EnvironmentMapSampler = sampler_state\n"
|
"samplerCUBE EnvironmentMapSampler = sampler_state\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
@ -131,67 +147,45 @@ std::string g_szSkyboxShader = std::string(
|
||||||
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
||||||
"float4x4 WorldViewProjection : WORLDVIEWPROJECTION;\n"
|
"float4x4 WorldViewProjection : WORLDVIEWPROJECTION;\n"
|
||||||
|
|
||||||
|
// Vertex shader input structure
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Vertex shader input structure\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_INPUT\n"
|
"struct VS_INPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Position\n"
|
|
||||||
"float3 Position : POSITION;\n"
|
"float3 Position : POSITION;\n"
|
||||||
|
|
||||||
// 3D-Texture coordinate\n"
|
|
||||||
"float3 Texture0 : TEXCOORD0;\n"
|
"float3 Texture0 : TEXCOORD0;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Vertex shader output structure
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Vertex shader output structure\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_OUTPUT\n"
|
"struct VS_OUTPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Position\n"
|
|
||||||
"float4 Position : POSITION;\n"
|
"float4 Position : POSITION;\n"
|
||||||
|
|
||||||
// 3D-Texture coordinate\n"
|
|
||||||
"float3 Texture0 : TEXCOORD0;\n"
|
"float3 Texture0 : TEXCOORD0;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Vertex shader
|
||||||
// Vertex shader\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"VS_OUTPUT RenderSkyBoxVS(VS_INPUT IN)\n"
|
"VS_OUTPUT RenderSkyBoxVS(VS_INPUT IN)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Initialize the output structure with zero\n"
|
"VS_OUTPUT Out;\n"
|
||||||
"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
|
|
||||||
|
|
||||||
// Multiply with the WorldViewProjection matrix\n"
|
// Multiply with the WorldViewProjection matrix
|
||||||
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
||||||
|
|
||||||
// Set z to w to ensure z becomes 1.0 after the division through\n"
|
// Set z to w to ensure z becomes 1.0 after the division through w occurs
|
||||||
// w occurs\n"
|
|
||||||
"Out.Position.z = Out.Position.w;\n"
|
"Out.Position.z = Out.Position.w;\n"
|
||||||
|
|
||||||
// Simply pass through texture coordinates\n"
|
// Simply pass through texture coordinates
|
||||||
"Out.Texture0 = IN.Texture0;\n"
|
"Out.Texture0 = IN.Texture0;\n"
|
||||||
|
|
||||||
"return Out;\n"
|
"return Out;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
// Pixel shader
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Pixel shader\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"float4 RenderSkyBoxPS(float3 Texture0 : TEXCOORD0) : COLOR\n"
|
"float4 RenderSkyBoxPS(float3 Texture0 : TEXCOORD0) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Lookup the skybox texture\n"
|
// Lookup the skybox texture
|
||||||
"return texCUBE(EnvironmentMapSampler,Texture0) ;\n"
|
"return texCUBE(EnvironmentMapSampler,Texture0) ;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
// Technique for the skybox shader (ps_2_0)
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Technique for the skybox shader (ps_2_0)\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique RenderSkyBox\n"
|
"technique RenderSkyBox\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -205,49 +199,36 @@ std::string g_szSkyboxShader = std::string(
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// -------------- same for static background image -----------------
|
||||||
"texture TEXTURE_2D;\n"
|
"texture TEXTURE_2D;\n"
|
||||||
"sampler TEXTURE_SAMPLER = sampler_state\n"
|
"sampler TEXTURE_SAMPLER = sampler_state\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"Texture = (TEXTURE_2D);\n"
|
"Texture = (TEXTURE_2D);\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_OUTPUT2\n"
|
"struct VS_OUTPUT2\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"// Position\n"
|
"float4 Position : POSITION;\n"
|
||||||
"float4 _Position : POSITION;\n"
|
"float2 TexCoord0 : TEXCOORD0;\n"
|
||||||
|
|
||||||
"// Texture coordinate\n"
|
|
||||||
"float2 _TexCoord0 : TEXCOORD0;\n"
|
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
"VS_OUTPUT2 RenderImageVS(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"VS_OUTPUT2 RenderImageVS(float4 INPosition : POSITION,\n"
|
|
||||||
"float2 INTexCoord0 : TEXCOORD0 )\n"
|
|
||||||
"{\n"
|
"{\n"
|
||||||
// Initialize the output structure with zero\n"
|
"VS_OUTPUT2 Out;\n"
|
||||||
"VS_OUTPUT2 Out = (VS_OUTPUT2)0;\n"
|
|
||||||
|
|
||||||
"Out._Position.xy = INPosition.xy;\n"
|
"Out.Position.xy = INPosition.xy;\n"
|
||||||
"Out._Position.z = Out._Position.w = 1.0f;\n"
|
"Out.Position.z = Out._Position.w = 1.0f;\n"
|
||||||
|
"Out.TexCoord0 = INTexCoord0;\n"
|
||||||
"Out._TexCoord0 = INTexCoord0;\n"
|
|
||||||
|
|
||||||
"return Out;\n"
|
"return Out;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"float4 RenderImagePS(float2 IN : TEXCOORD0) : COLOR\n"
|
"float4 RenderImagePS(float2 IN : TEXCOORD0) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"return tex2D(TEXTURE_SAMPLER,IN);\n"
|
"return tex2D(TEXTURE_SAMPLER,IN);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
// Technique for the background image shader (ps_2_0)
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Technique for the background image shader (ps_2_0)\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique RenderImage2D\n"
|
"technique RenderImage2D\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -264,55 +245,48 @@ std::string g_szSkyboxShader = std::string(
|
||||||
|
|
||||||
std::string g_szDefaultShader = std::string(
|
std::string g_szDefaultShader = std::string(
|
||||||
|
|
||||||
// World * View * Projection matrix\n"
|
// World * View * Projection matrix
|
||||||
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
// NOTE: Assume that the material uses a WorldViewProjection matrix
|
||||||
"float4x4 WorldViewProjection : WORLDVIEWPROJECTION;\n"
|
"float4x4 WorldViewProjection : WORLDVIEWPROJECTION;\n"
|
||||||
"float4x4 World : WORLD;\n"
|
"float4x4 World : WORLD;\n"
|
||||||
"float4x3 WorldInverseTranspose : WORLDINVERSETRANSPOSE;\n"
|
"float4x3 WorldInverseTranspose : WORLDINVERSETRANSPOSE;\n"
|
||||||
|
|
||||||
|
// light colors
|
||||||
// light colors\n"
|
|
||||||
"float3 afLightColor[5];\n"
|
"float3 afLightColor[5];\n"
|
||||||
|
// light direction
|
||||||
// light direction \n"
|
|
||||||
"float3 afLightDir[5];\n"
|
"float3 afLightDir[5];\n"
|
||||||
|
|
||||||
// position of the camera in worldspace\n"
|
// position of the camera in worldspace\n"
|
||||||
"float3 vCameraPos : CAMERAPOSITION;\n"
|
"float3 vCameraPos : CAMERAPOSITION;\n"
|
||||||
|
|
||||||
|
// Vertex shader input structure
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Vertex shader input structure\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_INPUT\n"
|
"struct VS_INPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"// Position\n"
|
|
||||||
"float3 Position : POSITION;\n"
|
"float3 Position : POSITION;\n"
|
||||||
"float3 Normal : NORMAL;\n"
|
"float3 Normal : NORMAL;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Vertex shader output structure for pixel shader usage
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Vertex shader output structure\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_OUTPUT\n"
|
"struct VS_OUTPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Position\n"
|
|
||||||
"float4 Position : POSITION;\n"
|
"float4 Position : POSITION;\n"
|
||||||
|
|
||||||
"float3 ViewDir : TEXCOORD0;\n"
|
"float3 ViewDir : TEXCOORD0;\n"
|
||||||
"float3 Normal : TEXCOORD1;\n"
|
"float3 Normal : TEXCOORD1;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Vertex shader output structure for fixed function
|
||||||
// Vertex shader\n"
|
"struct VS_OUTPUT_FF\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
"{\n"
|
||||||
|
"float4 Position : POSITION;\n"
|
||||||
|
"float4 Color : COLOR;\n"
|
||||||
|
"};\n"
|
||||||
|
|
||||||
|
// Vertex shader for pixel shader usage
|
||||||
"VS_OUTPUT DefaultVShader(VS_INPUT IN)\n"
|
"VS_OUTPUT DefaultVShader(VS_INPUT IN)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Initialize the output structure with zero\n"
|
"VS_OUTPUT Out;\n"
|
||||||
"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
|
|
||||||
|
|
||||||
// Multiply with the WorldViewProjection matrix\n"
|
// Multiply with the WorldViewProjection matrix
|
||||||
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
||||||
"float3 WorldPos = mul(float4(IN.Position,1.0f),World);\n"
|
"float3 WorldPos = mul(float4(IN.Position,1.0f),World);\n"
|
||||||
"Out.ViewDir = vCameraPos - WorldPos;\n"
|
"Out.ViewDir = vCameraPos - WorldPos;\n"
|
||||||
|
@ -321,10 +295,23 @@ std::string g_szDefaultShader = std::string(
|
||||||
"return Out;\n"
|
"return Out;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
// Vertex shader for fixed function pipeline
|
||||||
|
"VS_OUTPUT DefaultVShader_FF(VS_INPUT IN)\n"
|
||||||
|
"{\n"
|
||||||
|
"VS_OUTPUT Out;\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Multiply with the WorldViewProjection matrix
|
||||||
// Pixel shader\n"
|
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
"float3 worldNormal = mul( IN.Normal, float3x3( WorldInverseTranspose)); \n"
|
||||||
|
|
||||||
|
// per-vertex lighting. We simply assume light colors of unused lights to be black
|
||||||
|
"Out.Color = float4( 0.2f, 0.2f, 0.2f, 1.0f); \n"
|
||||||
|
"for( int a = 0; a < 5; a++)\n"
|
||||||
|
" Out.Color.rgb += saturate( dot( afLightDir[a], worldNormal)) * afLightColor[a].rgb; \n"
|
||||||
|
"return Out;\n"
|
||||||
|
"}\n"
|
||||||
|
|
||||||
|
// Pixel shader for one light
|
||||||
"float4 DefaultPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
|
"float4 DefaultPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
||||||
|
@ -341,7 +328,8 @@ std::string g_szDefaultShader = std::string(
|
||||||
"}\n"
|
"}\n"
|
||||||
"return OUT;\n"
|
"return OUT;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
|
// Pixel shader for two lights
|
||||||
"float4 DefaultPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
|
"float4 DefaultPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
||||||
|
@ -365,7 +353,7 @@ std::string g_szDefaultShader = std::string(
|
||||||
"}\n"
|
"}\n"
|
||||||
"return OUT;\n"
|
"return OUT;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
// ----------------------------------------------------------------------------
|
||||||
"float4 DefaultPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
|
"float4 DefaultPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
||||||
|
@ -382,7 +370,7 @@ std::string g_szDefaultShader = std::string(
|
||||||
|
|
||||||
"return OUT;\n"
|
"return OUT;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
// ----------------------------------------------------------------------------
|
||||||
"float4 DefaultPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
|
"float4 DefaultPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
||||||
|
@ -406,9 +394,7 @@ std::string g_szDefaultShader = std::string(
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Technique for the default effect
|
||||||
// Technique for the default effect\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique DefaultFXSpecular_D1\n"
|
"technique DefaultFXSpecular_D1\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -428,10 +414,7 @@ std::string g_szDefaultShader = std::string(
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Technique for the default effect (ps_2_0)
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Technique for the default effect (ps_2_0)\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique DefaultFXSpecular_PS20_D1\n"
|
"technique DefaultFXSpecular_PS20_D1\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -450,13 +433,27 @@ std::string g_szDefaultShader = std::string(
|
||||||
"VertexShader = compile vs_2_0 DefaultVShader();\n"
|
"VertexShader = compile vs_2_0 DefaultVShader();\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Technique for the default effect using the fixed function pixel pipeline
|
||||||
|
"technique DefaultFXSpecular_FF\n"
|
||||||
|
"{\n"
|
||||||
|
"pass p0\n"
|
||||||
|
"{\n"
|
||||||
|
"CullMode=none;\n"
|
||||||
|
"VertexShader = compile vs_2_0 DefaultVShader_FF();\n"
|
||||||
|
"ColorOp[0] = SelectArg0;\n"
|
||||||
|
"ColorArg0[0] = Diffuse;\n"
|
||||||
|
"AlphaOp[0] = SelectArg0;\n"
|
||||||
|
"AlphaArg0[0] = Diffuse;\n"
|
||||||
|
"}\n"
|
||||||
|
"};\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
std::string g_szMaterialShader = std::string(
|
std::string g_szMaterialShader = std::string(
|
||||||
|
|
||||||
// World * View * Projection matrix\n"
|
// World * View * Projection matrix
|
||||||
// NOTE: Assume that the material uses a WorldViewProjection matrix\n"
|
// NOTE: Assume that the material uses a WorldViewProjection matrix
|
||||||
"float4x4 WorldViewProjection : WORLDVIEWPROJECTION;\n"
|
"float4x4 WorldViewProjection : WORLDVIEWPROJECTION;\n"
|
||||||
"float4x4 World : WORLD;\n"
|
"float4x4 World : WORLD;\n"
|
||||||
"float4x3 WorldInverseTranspose : WORLDINVERSETRANSPOSE;\n"
|
"float4x3 WorldInverseTranspose : WORLDINVERSETRANSPOSE;\n"
|
||||||
|
@ -479,14 +476,14 @@ std::string g_szMaterialShader = std::string(
|
||||||
"float TRANSPARENCY;\n"
|
"float TRANSPARENCY;\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
|
|
||||||
// light colors (diffuse and specular)\n"
|
// light colors (diffuse and specular)
|
||||||
"float4 afLightColor[5];\n"
|
"float4 afLightColor[5];\n"
|
||||||
"float4 afLightColorAmbient[5];\n"
|
"float4 afLightColorAmbient[5];\n"
|
||||||
|
|
||||||
// light direction \n"
|
// light direction
|
||||||
"float3 afLightDir[5];\n"
|
"float3 afLightDir[5];\n"
|
||||||
|
|
||||||
// position of the camera in worldspace\n"
|
// position of the camera in worldspace
|
||||||
"float3 vCameraPos : CAMERAPOSITION;\n"
|
"float3 vCameraPos : CAMERAPOSITION;\n"
|
||||||
|
|
||||||
"#ifdef AV_DIFFUSE_TEXTURE\n"
|
"#ifdef AV_DIFFUSE_TEXTURE\n"
|
||||||
|
@ -569,33 +566,20 @@ std::string g_szMaterialShader = std::string(
|
||||||
"};\n"
|
"};\n"
|
||||||
"#endif // AV_SKYBOX_LOOKUP\n"
|
"#endif // AV_SKYBOX_LOOKUP\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Vertex shader input structure
|
||||||
// Vertex shader input structure\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_INPUT\n"
|
"struct VS_INPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Position\n"
|
|
||||||
"float3 Position : POSITION;\n"
|
"float3 Position : POSITION;\n"
|
||||||
"float3 Normal : NORMAL;\n"
|
"float3 Normal : NORMAL;\n"
|
||||||
|
|
||||||
// NOTE: Tangents and bitangents are passed to the shader
|
|
||||||
// in every case, even if not required. This saves a few lines
|
|
||||||
// of code ...
|
|
||||||
|
|
||||||
"float3 Tangent : TEXCOORD0;\n"
|
"float3 Tangent : TEXCOORD0;\n"
|
||||||
"float3 Bitangent : TEXCOORD1;\n"
|
"float3 Bitangent : TEXCOORD1;\n"
|
||||||
"float2 TexCoord0 : TEXCOORD2;\n"
|
"float2 TexCoord0 : TEXCOORD2;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Vertex shader output structure for pixel shader usage
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Vertex shader output structure\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_OUTPUT\n"
|
"struct VS_OUTPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Position\n"
|
|
||||||
"float4 Position : POSITION;\n"
|
"float4 Position : POSITION;\n"
|
||||||
|
|
||||||
"float3 ViewDir : TEXCOORD0;\n"
|
"float3 ViewDir : TEXCOORD0;\n"
|
||||||
|
|
||||||
"#ifndef AV_NORMAL_TEXTURE\n"
|
"#ifndef AV_NORMAL_TEXTURE\n"
|
||||||
|
@ -605,17 +589,22 @@ std::string g_szMaterialShader = std::string(
|
||||||
"float2 TexCoord0 : TEXCOORD2;\n"
|
"float2 TexCoord0 : TEXCOORD2;\n"
|
||||||
|
|
||||||
"#ifdef AV_NORMAL_TEXTURE\n"
|
"#ifdef AV_NORMAL_TEXTURE\n"
|
||||||
|
|
||||||
"float3 Light0 : TEXCOORD3;\n"
|
"float3 Light0 : TEXCOORD3;\n"
|
||||||
"float3 Light1 : TEXCOORD4;\n"
|
"float3 Light1 : TEXCOORD4;\n"
|
||||||
|
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Vertex shader output structure for fixed function pixel pipeline
|
||||||
|
"struct VS_OUTPUT_FF\n"
|
||||||
|
"{\n"
|
||||||
|
"float4 Position : POSITION;\n"
|
||||||
|
"float4 DiffuseColor : COLOR0;\n"
|
||||||
|
"float4 SpecularColor : COLOR1;\n"
|
||||||
|
"float2 TexCoord0 : TEXCOORD0;\n"
|
||||||
|
"};\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Selective SuperSampling in screenspace for reflection lookups\n"
|
// Selective SuperSampling in screenspace for reflection lookups
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"#ifndef AV_SKYBOX_LOOKUP\n"
|
"#ifndef AV_SKYBOX_LOOKUP\n"
|
||||||
"#define AV_DISABLESSS\n"
|
"#define AV_DISABLESSS\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
|
@ -656,13 +645,10 @@ std::string g_szMaterialShader = std::string(
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Vertex shader for pixel shader usage and one light
|
||||||
// Vertex shader\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"VS_OUTPUT MaterialVShader_D1(VS_INPUT IN)\n"
|
"VS_OUTPUT MaterialVShader_D1(VS_INPUT IN)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Initialize the output structure with zero\n"
|
"VS_OUTPUT Out;\n"
|
||||||
"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
|
|
||||||
|
|
||||||
// Multiply with the WorldViewProjection matrix\n"
|
// Multiply with the WorldViewProjection matrix\n"
|
||||||
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
||||||
|
@ -682,11 +668,11 @@ std::string g_szMaterialShader = std::string(
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"return Out;\n"
|
"return Out;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"// ----------------------------------------------------------------------------\n"
|
|
||||||
|
// Vertex shader for pixel shader usage and two lights
|
||||||
"VS_OUTPUT MaterialVShader_D2(VS_INPUT IN)\n"
|
"VS_OUTPUT MaterialVShader_D2(VS_INPUT IN)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
// Initialize the output structure with zero\n"
|
"VS_OUTPUT Out;\n"
|
||||||
"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
|
|
||||||
|
|
||||||
// Multiply with the WorldViewProjection matrix\n"
|
// Multiply with the WorldViewProjection matrix\n"
|
||||||
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
"Out.Position = mul(float4(IN.Position,1.0f),WorldViewProjection);\n"
|
||||||
|
@ -708,10 +694,41 @@ std::string g_szMaterialShader = std::string(
|
||||||
"return Out;\n"
|
"return Out;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
// Vertex shader for zero to five lights using the fixed function pixel pipeline
|
||||||
|
"VS_OUTPUT MaterialVShader_FF(VS_INPUT IN)\n"
|
||||||
|
"{\n"
|
||||||
|
"VS_OUTPUT_FF Out;\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Multiply with the WorldViewProjection matrix
|
||||||
// Pixel shader\n"
|
"Out.Position = mul( float4( IN.Position, 1.0f), WorldViewProjection);\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
"float3 worldPos = mul( float4( IN.Position, 1.0f), World);\n"
|
||||||
|
"float3 worldNormal = mul( IN.Normal, float3x3( WorldInverseTranspose)); \n"
|
||||||
|
"Out.TexCoord0 = IN.TexCoord0;\n"
|
||||||
|
|
||||||
|
// calculate per-vertex diffuse lighting including ambient part
|
||||||
|
"float4 diffuseColor = float4( 0.0f, 0.0f, 0.0f, 1.0f); \n"
|
||||||
|
"for( int a = 0; a < 5; a++) \n"
|
||||||
|
" diffuseColor.rgb += saturate( dot( afLightDir[a], worldNormal)) * afLightColor[a].rgb; \n"
|
||||||
|
// factor in material properties and a bit of ambient lighting
|
||||||
|
"Out.DiffuseColor = diffuseColor * DIFFUSE_COLOR + float4( 0.2f, 0.2f, 0.2f, 1.0f) * AMBIENT_COLOR; ; \n"
|
||||||
|
|
||||||
|
// and specular including emissive part
|
||||||
|
"float4 specularColor = float4( 0.0f, 0.0f, 0.0f, 1.0f); \n"
|
||||||
|
"float3 viewDir = normalize( worldPos - vCameraPos); \n"
|
||||||
|
"for( int a = 0; a < 5; a++) \n"
|
||||||
|
"{ \n"
|
||||||
|
" float3 reflDir = reflect( afLightDir[a], worldNormal); \n"
|
||||||
|
" float specIntensity = pow( dot( -reflDir, viewDir), SPECULAR_STRENGTH) * SPECULARITY; \n"
|
||||||
|
" specularColor.rgb += afLightColor[a] * specIntensity; \n"
|
||||||
|
"} \n"
|
||||||
|
// factor in material properties and the emissive part
|
||||||
|
"Out.SpecularColor = specularColor * SPECULAR_COLOR + EMISSIVE_COLOR; \n"
|
||||||
|
|
||||||
|
"return Out;\n"
|
||||||
|
"}\n"
|
||||||
|
|
||||||
|
|
||||||
|
// Pixel shader - one light
|
||||||
"float4 MaterialPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
|
"float4 MaterialPShaderSpecular_D1(VS_OUTPUT IN) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
||||||
|
@ -781,7 +798,8 @@ std::string g_szMaterialShader = std::string(
|
||||||
|
|
||||||
"#undef AV_LIGHT_0\n"
|
"#undef AV_LIGHT_0\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
|
// Pixel shader - two lights
|
||||||
"float4 MaterialPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
|
"float4 MaterialPShaderSpecular_D2(VS_OUTPUT IN) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
||||||
|
@ -893,7 +911,8 @@ std::string g_szMaterialShader = std::string(
|
||||||
"#undef AV_LIGHT_0\n"
|
"#undef AV_LIGHT_0\n"
|
||||||
"#undef AV_LIGHT_1\n"
|
"#undef AV_LIGHT_1\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
|
// Same pixel shader again, one light
|
||||||
"float4 MaterialPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
|
"float4 MaterialPShaderSpecular_PS20_D1(VS_OUTPUT IN) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
||||||
|
@ -947,7 +966,8 @@ std::string g_szMaterialShader = std::string(
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"return OUT;\n"
|
"return OUT;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
|
// Same pixel shader again, two lights
|
||||||
"float4 MaterialPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
|
"float4 MaterialPShaderSpecular_PS20_D2(VS_OUTPUT IN) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
"float4 OUT = float4(0.0f,0.0f,0.0f,1.0f);\n"
|
||||||
|
@ -1036,9 +1056,7 @@ std::string g_szMaterialShader = std::string(
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Technique for the material effect
|
||||||
// Technique for the material effect\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique MaterialFXSpecular_D1\n"
|
"technique MaterialFXSpecular_D1\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -1084,10 +1102,7 @@ std::string g_szMaterialShader = std::string(
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Technique for the material effect (ps_2_0)
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Technique for the material effect (ps_2_0)\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique MaterialFXSpecular_PS20_D1\n"
|
"technique MaterialFXSpecular_PS20_D1\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -1110,6 +1125,7 @@ std::string g_szMaterialShader = std::string(
|
||||||
"VertexShader = compile vs_2_0 MaterialVShader_D1();\n"
|
"VertexShader = compile vs_2_0 MaterialVShader_D1();\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
"technique MaterialFXSpecular_PS20_D2\n"
|
"technique MaterialFXSpecular_PS20_D2\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -1132,6 +1148,23 @@ std::string g_szMaterialShader = std::string(
|
||||||
"VertexShader = compile vs_2_0 MaterialVShader_D2();\n"
|
"VertexShader = compile vs_2_0 MaterialVShader_D2();\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Technique for the material effect using fixed function pixel pipeline
|
||||||
|
"technique MaterialFX_FF\n"
|
||||||
|
"{\n"
|
||||||
|
"pass p0\n"
|
||||||
|
"{\n"
|
||||||
|
"CullMode=none;\n"
|
||||||
|
"SpecularEnable = true; \n"
|
||||||
|
"VertexShader = compile vs_2_0 MaterialVShader_FF();\n"
|
||||||
|
"ColorOp[0] = Modulate;\n"
|
||||||
|
"ColorArg0[0] = Texture;\n"
|
||||||
|
"ColorArg1[0] = Diffuse;\n"
|
||||||
|
"AlphaOp[0] = Modulate;\n"
|
||||||
|
"AlphaArg0[0] = Textur;\n"
|
||||||
|
"AlphaArg1[0] = Diffuse;\n"
|
||||||
|
"}\n"
|
||||||
|
"};\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string g_szPassThroughShader = std::string(
|
std::string g_szPassThroughShader = std::string(
|
||||||
|
@ -1141,55 +1174,43 @@ std::string g_szPassThroughShader = std::string(
|
||||||
"Texture = (TEXTURE_2D);\n"
|
"Texture = (TEXTURE_2D);\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// Vertex Shader output for pixel shader usage
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"struct VS_OUTPUT\n"
|
"struct VS_OUTPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"// Position\n"
|
"float4 Position : POSITION;\n"
|
||||||
"float4 _Position : POSITION;\n"
|
"float2 TexCoord0 : TEXCOORD0;\n"
|
||||||
|
|
||||||
"// Texture coordinate\n"
|
|
||||||
"float2 _TexCoord0 : TEXCOORD0;\n"
|
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// vertex shader for pixel shader usage
|
||||||
// ----------------------------------------------------------------------------\n"
|
"VS_OUTPUT DefaultVShader(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
|
||||||
"VS_OUTPUT DefaultVShader(float4 INPosition : POSITION,\n"
|
|
||||||
"float2 INTexCoord0 : TEXCOORD0 )\n"
|
|
||||||
"{\n"
|
"{\n"
|
||||||
"// Initialize the output structure with zero\n"
|
"VS_OUTPUT Out;\n"
|
||||||
"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
|
|
||||||
|
|
||||||
"Out._Position = INPosition;\n"
|
"Out.Position = INPosition;\n"
|
||||||
"Out._TexCoord0 = INTexCoord0;\n"
|
"Out.TexCoord0 = INTexCoord0;\n"
|
||||||
|
|
||||||
"return Out;\n"
|
"return Out;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
// simply lookup a texture
|
// simply lookup a texture
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"float4 PassThrough_PS(float2 IN : TEXCOORD0) : COLOR\n"
|
"float4 PassThrough_PS(float2 IN : TEXCOORD0) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"return tex2D(TEXTURE_SAMPLER,IN);\n"
|
" return tex2D(TEXTURE_SAMPLER,IN);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
// visualize the alpha channel (in black) -> use a
|
// visualize the alpha channel (in black) -> use a
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"float4 PassThroughAlphaA_PS(float2 IN : TEXCOORD0) : COLOR\n"
|
"float4 PassThroughAlphaA_PS(float2 IN : TEXCOORD0) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).a);\n"
|
" return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).a);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
// visualize the alpha channel (in black) -> use r
|
// visualize the alpha channel (in black) -> use r
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"float4 PassThroughAlphaR_PS(float2 IN : TEXCOORD0) : COLOR\n"
|
"float4 PassThroughAlphaR_PS(float2 IN : TEXCOORD0) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).r);\n"
|
" return float4(0.0f,0.0f,0.0f,tex2D(TEXTURE_SAMPLER,IN).r);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// Simple pass-through technique
|
||||||
// Simple pass-through technique\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique PassThrough\n"
|
"technique PassThrough\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -1205,9 +1226,7 @@ std::string g_szPassThroughShader = std::string(
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Pass-through technique which visualizes the texture's alpha channel
|
// Pass-through technique which visualizes the texture's alpha channel
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique PassThroughAlphaFromA\n"
|
"technique PassThroughAlphaFromA\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -1223,9 +1242,7 @@ std::string g_szPassThroughShader = std::string(
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Pass-through technique which visualizes the texture's red channel
|
// Pass-through technique which visualizes the texture's red channel
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique PassThroughAlphaFromR\n"
|
"technique PassThroughAlphaFromR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
@ -1240,6 +1257,24 @@ std::string g_szPassThroughShader = std::string(
|
||||||
"VertexShader = compile vs_2_0 DefaultVShader();\n"
|
"VertexShader = compile vs_2_0 DefaultVShader();\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// technique for fixed function pixel pipeline
|
||||||
|
"technique PassThrough_FF\n"
|
||||||
|
"{\n"
|
||||||
|
"pass p0\n"
|
||||||
|
"{\n"
|
||||||
|
"ZEnable = FALSE;\n"
|
||||||
|
"CullMode = none;\n"
|
||||||
|
"AlphaBlendEnable = TRUE;\n"
|
||||||
|
"SrcBlend =srcalpha;\n"
|
||||||
|
"DestBlend =invsrcalpha;\n"
|
||||||
|
"VertexShader = compile vs_2_0 DefaultVShader();\n"
|
||||||
|
"ColorOp[0] = SelectArg0;\n"
|
||||||
|
"ColorArg0[0] = Texture;\n"
|
||||||
|
"AlphaOp[0] = SelectArg0;\n"
|
||||||
|
"AlphaArg0[0] = Textur;\n"
|
||||||
|
"}\n"
|
||||||
|
"};\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string g_szCheckerBackgroundShader = std::string(
|
std::string g_szCheckerBackgroundShader = std::string(
|
||||||
|
@ -1251,44 +1286,35 @@ std::string g_szCheckerBackgroundShader = std::string(
|
||||||
// size of a square in both x and y direction
|
// size of a square in both x and y direction
|
||||||
"float SQUARE_SIZE = 10.0f;\n"
|
"float SQUARE_SIZE = 10.0f;\n"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
// vertex shader output structure
|
||||||
"struct VS_OUTPUT\n"
|
"struct VS_OUTPUT\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"// Position\n"
|
"float4 Position : POSITION;\n"
|
||||||
"float4 _Position : POSITION;\n"
|
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
|
// vertex shader
|
||||||
// ----------------------------------------------------------------------------\n"
|
"VS_OUTPUT DefaultVShader(float4 INPosition : POSITION, float2 INTexCoord0 : TEXCOORD0 )\n"
|
||||||
"VS_OUTPUT DefaultVShader(float4 INPosition : POSITION,\n"
|
|
||||||
"float2 INTexCoord0 : TEXCOORD0 )\n"
|
|
||||||
"{\n"
|
"{\n"
|
||||||
"// Initialize the output structure with zero\n"
|
"VS_OUTPUT Out;\n"
|
||||||
"VS_OUTPUT Out = (VS_OUTPUT)0;\n"
|
|
||||||
|
|
||||||
"Out._Position = INPosition;\n"
|
|
||||||
|
|
||||||
|
"Out.Position = INPosition;\n"
|
||||||
"return Out;\n"
|
"return Out;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
// pixel shader
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"float4 MakePattern_PS(float2 IN : VPOS) : COLOR\n"
|
"float4 MakePattern_PS(float2 IN : VPOS) : COLOR\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"float2 fDiv = IN / SQUARE_SIZE;\n"
|
"float2 fDiv = IN / SQUARE_SIZE;\n"
|
||||||
"float3 fColor = COLOR_ONE;\n"
|
"float3 fColor = COLOR_ONE;\n"
|
||||||
"if (0 == round(fmod(round(fDiv.x),2)))\n"
|
"if (0 == round(fmod(round(fDiv.x),2)))\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"if (0 == round(fmod(round(fDiv.y),2))) fColor = COLOR_TWO;\n"
|
" if (0 == round(fmod(round(fDiv.y),2))) fColor = COLOR_TWO;\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"else if (0 != round(fmod(round(fDiv.y),2)))fColor = COLOR_TWO;\n"
|
"else if (0 != round(fmod(round(fDiv.y),2)))fColor = COLOR_TWO;\n"
|
||||||
"return float4(fColor,1.0f);"
|
"return float4(fColor,1.0f);"
|
||||||
"}\n"
|
"}\n"
|
||||||
|
|
||||||
|
// technique to generate a pattern
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
// Shader to generate a pattern\n"
|
|
||||||
// ----------------------------------------------------------------------------\n"
|
|
||||||
"technique MakePattern\n"
|
"technique MakePattern\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"pass p0\n"
|
"pass p0\n"
|
||||||
|
|
Loading…
Reference in New Issue