问题
I am trying to build an obj file viewer using Helix Toolkit (https://github.com/helix-toolkit/helix-toolkit) with SharpDX. So far I am able to load an object file and render it's contents to Helix Viewport3DX. Model looks good with some obj files but for others there are some lightning problem and back surfaces are always black. I am not sure what am I doing wrong. Is this light problem due to the fact that SharpDX does not support back materials?? Please help.
Problem using Helix Sharp DX:
Original Model in Adobe DC Reader looks like this:
Viewport3DX settings are:
<Window.Resources>
<DataTemplate x:Key="Template1">
<hx:MyMeshGeometryModel3D Geometry="{Binding Geometry}" Transform="{Binding Transform}" Material="{Binding Material}"/>
</DataTemplate>
<hx:RenderTechniqueConverter x:Key="RenderTechniqueConverter"/>
</Window.Resources>
<hx:Viewport3DX x:Name="helixViewport" Camera="{Binding Camera}" CameraRotationMode="Trackball" RenderTechnique="{Binding RenderTechnique}" RenderTechniquesManager="{Binding RenderTechniquesManager}" EffectsManager="{Binding EffectsManager}" BackgroundColor="{Binding BackgroundColor}" UseDefaultGestures="False">
<hx:Viewport3DX.InputBindings>
<MouseBinding Gesture="LeftClick" Command="hx:ViewportCommands.Rotate"/>
<MouseBinding Gesture="MiddleClick" Command="hx:ViewportCommands.Zoom"/>
<MouseBinding Gesture="RightClick" Command="hx:ViewportCommands.Pan"/>
</hx:Viewport3DX.InputBindings>
<hx:AmbientLight3D Color="{Binding AmbientLightColor}"/>
<hx:DirectionalLight3D Color="{Binding DirectionalLightColor1}" Direction="-1,-1,-1"/>
<hx:DirectionalLight3D Color="{Binding DirectionalLightColor2}" Direction="1,-1,-0.1"/>
<hx:DirectionalLight3D Color="{Binding DirectionalLightColor3}" Direction="0.1,1,-1"/>
<hx:DirectionalLight3D Color="{Binding DirectionalLightColor4}" Direction="0.1,0.1,1"/>
<hx:ItemsModel3D x:Name="itemsModel3d" ItemTemplate="{StaticResource Template1}" ItemsSource="{Binding Items}"/>
</hx:Viewport3DX>
回答1:
I'm not sure what u mean with "back materials".
SharpDX supports what ever u want it to as its just a wrapper around DirectX, the issue could have something to do with helix but again I don't really know because helix is a framework that is based on sharpDX and I'm just using sharpDX to build my own framework.
You never draw the back side of a mesh because u cant see it anyway so why bother sending drawing it?
It almost looks like there is some sort of falloff on the light but because its a directional light that would be of no use.
Sometimes in max I have to flip the normal so things draw right in game or I change the winding order when I import the mesh with assimp.
来源:https://stackoverflow.com/questions/34837263/lights-not-working-properly-in-helix-sharp-dx