我在C#中使用託管DirectX9。我做了一臺cnc機器的可視化。DirectX 9陰影不是線性的嗎?
在計算機1上它完美地工作。左側的圓形管呈明亮的灰色,陰影與深灰色呈線形。
在計算機2上,我得到了一些不同的東西(代碼相同!): 它只是白色在左邊,深灰色在右邊,但它不是線性的。它仍然是白色的約45%的管和黑暗的55%。一個陰影只在這兩個點之間可見....
任何想法???
看起來像我使用光線太亮,但代碼是完全一樣的...
/編輯 確定這裏是截圖: 有問題的電腦是酷睿i3 +英特爾集成圖形+ Win7的64位 用正確的可視化能力的計算機是一個較老的英特爾與onboardgraphic和XP 32位
下面是對DirectX的設置:
PresentParameters aPresentParams = new PresentParameters();
aPresentParams.Windowed = true;
aPresentParams.DeviceWindow = theControl;
aPresentParams.DeviceWindowHandle = theControl.Handle;
aPresentParams.SwapEffect = SwapEffect.Copy;
aPresentParams.EnableAutoDepthStencil = true;
aPresentParams.AutoDepthStencilFormat = DepthFormat.D16;
CreateFlags aCreateFlags = CreateFlags.HardwareVertexProcessing;
itsDevice = new Device(0, DeviceType.Hardware, theControl, aCreateFlags, aPresentParams);
itsDevice.RenderState.AntiAliasedLineEnable = true;
itsDevice.RenderState.CullMode = Cull.None;
//some materials...
itsMaterialBasic.Diffuse = Color.LightGray;
itsMaterialBasic.Ambient = Color.FromArgb(0, 80, 80, 80);
itsMaterialBasic.Specular = Color.Red;
itsMaterialBasic.SpecularSharpness = 1000.0f;
//...
itsDevice.RenderState.Lighting = true;
itsDevice.Lights[0].Type = LightType.Point;
itsDevice.Lights[0].Diffuse = Color.LightGray;
itsDevice.Lights[0].Range = 10000f;
itsDevice.Lights[0].Falloff = 10f;
itsDevice.Lights[0].Direction = new Vector3(-5, -28, 10);
itsDevice.Lights[0].Position = new Vector3(1000, 2000, 3350);
itsDevice.Lights[0].Attenuation0 = 0f;
itsDevice.Lights[0].Update();
itsDevice.Lights[0].Enabled = true;
itsDevice.RenderState.ShadeMode = ShadeMode.Phong;
itsDevice.RenderState.SpecularEnable = true;
itsDevice.RenderState.SpecularMaterialSource = ColorSource.Color1;
itsDevice.RenderState.Ambient = Color.FromArgb(110, 110, 110);
itsDevice.RenderState.AmbientMaterialSource = ColorSource.Color1;
屏幕截圖,或許是兩臺機器上的渲染和硬件規格的一個小列表將有所幫助。 – Ani
您是否嘗試過在有問題的機器上初始化參考光柵器(DeviceType.Reference)?如果解決了這個問題 - 我會直接責怪那臺機器上的驅動程序/ GPU組合。 – Ani
如果你使用自己的着色器:也許你忘了用着色器代碼複製一些文件? – miloszmaki