Browse Source

Viewer:
- added hacky support for pre-shader graphics cards. Seems to work, but I'll not know for sure until I acutally test it on such a crippled hardware.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@174 67173fc5-114c-0410-ac8e-9d2fd5bffc1f

ulfjorensen 17 years ago
parent
commit
366562e5d1

+ 4 - 0
tools/assimp_view/Display.cpp

@@ -1905,6 +1905,10 @@ int CDisplay::RenderNode (aiNode* piNode,const aiMatrix4x4& piMatrix,
 		piEnd->SetVector( "vCameraPos",&apcVec[0]);
 
 		// setup the best technique 
+    if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
+    {
+      g_piDefaultEffect->SetTechnique( "DefaultFXSpecular_FF");
+    } else
 		if (g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0) || g_sOptions.bLowQuality)
 		{
 			if (g_sOptions.b3Lights)

+ 11 - 1
tools/assimp_view/Material.cpp

@@ -1054,7 +1054,13 @@ int CMaterialManager::CreateMaterial(
 			CLogDisplay::Instance().AddEntry("Unable to load material: UNNAMED");
 		}
 		return 0;
-	}
+	} else
+  {
+    // use Fixed Function effect when working with shaderless cards
+    if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
+      pcMesh->piEffect->SetTechnique( "MaterialFX_FF");
+  }
+
 	if( piBuffer) piBuffer->Release();
 
 
@@ -1205,6 +1211,10 @@ int CMaterialManager::SetupMaterial (
 	}
 
 	// setup the correct shader technique to be used for drawing
+  if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
+  {
+    g_piDefaultEffect->SetTechnique( "MaterialFXSpecular_FF");
+  } else
 	if (g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0) || g_sOptions.bLowQuality)
 	{
 		if (g_sOptions.b3Lights)

+ 2 - 0
tools/assimp_view/Shaders.cpp

@@ -714,6 +714,7 @@ std::string g_szMaterialShader = std::string(
 
     // and specular including emissive part
     "float4 specularColor = float4( 0.0f, 0.0f, 0.0f, 1.0f); \n"
+  	"#ifdef AV_SPECULAR_COMPONENT\n"
     "float3 viewDir = normalize( worldPos - vCameraPos); \n"
     "for( int a = 0; a < 5; a++) \n"
     "{ \n"
@@ -721,6 +722,7 @@ std::string g_szMaterialShader = std::string(
     "  float specIntensity = pow( dot( -reflDir, viewDir), SPECULAR_STRENGTH) * SPECULARITY; \n"
     "  specularColor.rgb += afLightColor[a] * specIntensity; \n"
     "} \n"
+    "#endif // AV_SPECULAR_COMPONENT\n"
     // factor in material properties and the emissive part
     "Out.SpecularColor = specularColor * SPECULAR_COLOR + EMISSIVE_COLOR; \n"
 

+ 18 - 6
tools/assimp_view/assimp_view.cpp

@@ -924,6 +924,13 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
 	}
 	g_piDevice->SetFVF(AssetHelper::Vertex::GetFVF());
 
+	// get the capabilities of the device object
+	g_piDevice->GetDeviceCaps(&g_sCaps);
+	if(g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0))
+	{
+		EnableWindow(GetDlgItem(g_hDlg,IDC_LOWQUALITY),FALSE);
+	}
+
 	// compile the default material shader (gray gouraud/phong)
 	ID3DXBuffer* piBuffer = NULL;
 	if(FAILED( D3DXCreateEffect(g_piDevice,
@@ -948,6 +955,10 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
 		piBuffer = NULL;
 	}
 
+  // use Fixed Function effect when working with shaderless cards
+  if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
+    g_piDefaultEffect->SetTechnique( "DefaultFXSpecular_FF");
+
 	// create the shader used to draw the HUD
 	if(FAILED( D3DXCreateEffect(g_piDevice,
 		g_szPassThroughShader.c_str(),(UINT)g_szPassThroughShader.length(),
@@ -966,6 +977,10 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
 		piBuffer = NULL;
 	}
 
+  // use Fixed Function effect when working with shaderless cards
+  if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
+    g_piPassThroughEffect->SetTechnique( "PassThrough_FF");
+
 	// create the shader used to visualize normal vectors
 	if(FAILED( D3DXCreateEffect(g_piDevice,
 		g_szNormalsShader.c_str(),(UINT)g_szNormalsShader.length(),
@@ -984,12 +999,9 @@ int CreateDevice (bool p_bMultiSample,bool p_bSuperSample,bool bHW /*= true*/)
 		piBuffer = NULL;
 	}
 
-	// get the capabilities of the device object
-	g_piDevice->GetDeviceCaps(&g_sCaps);
-	if(g_sCaps.PixelShaderVersion < D3DPS_VERSION(3,0))
-	{
-		EnableWindow(GetDlgItem(g_hDlg,IDC_LOWQUALITY),FALSE);
-	}
+  // use Fixed Function effect when working with shaderless cards
+  if( g_sCaps.PixelShaderVersion < D3DPS_VERSION(2,0))
+    g_piNormalsEffect->SetTechnique( "RenderNormals_FF");
 
 	// create the texture for the HUD
 	CreateHUDTexture();