Shademode=flat does not work on Intel graphicchips

Posted By: Puppeteer

Shademode=flat does not work on Intel graphicchips - 01/09/14 17:44

I realized that flat shading does not seem to work on Intel graphicchips like the Intel HD 4000.

How it looks on regular GPUs:
Click me

How it looks on Intel Chips:
Click me

Is it supported? Am I doing something wrong?

Here a little bit of code to try out for yourself:
Code:
#include <acknex.h>

MATERIAL* mat1={
	effect="
	const float4x4 matWorldViewProj; // World*view*projection matrix. 
	texture entSkin1;
	
	sampler ColorMapSampler = sampler_state 
	{ 
	   Texture = <entSkin1>; 
	}; 
	
struct VS_OUTPUT
{
	float4 position : POSITION0;
	float4 color : COLOR0;
};

VS_OUTPUT DiffuseVS( 
   in float4 InPos: POSITION, 
   in float2 InTex: TEXCOORD0)
{ 
	VS_OUTPUT output;
	output.position=InPos;
   output.position = mul(output.position, matWorldViewProj); 
   output.color=tex2Dlod(ColorMapSampler,float4(InTex.xy,0.0f,0.0f));
   return output;
} 
 
float4 DiffusePS(in float4 col : COLOR0) : COLOR0
{
	return col;
}

// Technique: 
technique DiffuseTechnique 
{ 
   pass P0 
   {
   	shademode=flat;
      VertexShader = compile vs_3_0 DiffuseVS(); 
      PixelShader = compile ps_3_0 DiffusePS();
   } 
} 	
	";
	
	
	
}

void main()
{
	level_load(NULL);
	camera.x=150;
	camera.pan=180;
        //Choose a model you like here =)
	you=ent_create("player.mdl",NULLVECTOR,NULL);
	you.material=mat1;
}

Posted By: Kartoffel

Re: Shademode=flat does not work on Intel graphicchips - 01/09/14 21:28

I don't think you're doing anything wrong.

afaik there are a couple of things which (some ?) intel graphics cards do not support.
Posted By: sivan

Re: Shademode=flat does not work on Intel graphicchips - 01/09/14 22:30

I don't know how intel can make such a bad cards in general. but they need low power. I can test it for you tomorrow.
Posted By: Kartoffel

Re: Shademode=flat does not work on Intel graphicchips - 01/10/14 08:42

My brother's got an Intel in his laptop aswell.
I'll let him try it and post the result.
Posted By: sivan

Re: Shademode=flat does not work on Intel graphicchips - 01/10/14 10:58

yes it looks like that exactly. tested with ATI radeon hd 7670m and intel hd4000.
Posted By: Puppeteer

Re: Shademode=flat does not work on Intel graphicchips - 01/10/14 20:47

I think it can be done.
If you comment this line out:
PixelShader = compile ps_3_0 DiffusePS();

You will see that without a PixelShader it is proper flat shading.
But I need a pixelshader so that is not an option for me.
Posted By: Slin

Re: Shademode=flat does not work on Intel graphicchips - 01/19/14 19:27

I do believe that it is a driver problem and especially not a gamestudio bug, because as far as I know it just uses the directx api to load and compile .fx files and there isnīt much to mess up.

The best solution which you should use anyways is to not use a flat shademode, but use the default setting instead and then split your meshes polygons. As a result it will look the same on all hardware and better than it currently does, because it then uses real face normals instead of the currently used per vertex normals which donīt exactly fit the shaded faces.
Posted By: Puppeteer

Re: Shademode=flat does not work on Intel graphicchips - 01/21/14 14:11

I fixed all those issues you described with flat shading by rebuilding edge splitted meshes to meshes optimized for flat shading with correct normals etc. using some digital awesome.

Because the problem is if I keep the edge splitted models that work in all shade modes my vertex count is way to high.
Using the method above I loose about 66% of all vertexes, which is quite a lot.
Posted By: Slin

Re: Shademode=flat does not work on Intel graphicchips - 01/21/14 14:36

How high is your vertex count for a complete scene? Because usually the vertex count is not a bottleneck...
Posted By: Puppeteer

Re: Shademode=flat does not work on Intel graphicchips - 01/22/14 19:40

The scence I am currently working with has 1235000 vertices.
© 2024 lite-C Forums