3D 对象的材质

发布于 2024-10-25 12:15:46 字数 1538 浏览 1 评论 0原文

当我尝试使用 WPF 的 3D 支持时,我想尝试 3d 对象材质类型的不同选项,因此首先我创建了一个简单的场景,只有一个三角形(渲染正常)

<Viewport3D>
            <Viewport3D.Camera>
                <PerspectiveCamera Position="-2,2,2" LookDirection="2,-2,-2" UpDirection="0,1,0" />
            </Viewport3D.Camera>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <DirectionalLight Color="White" Direction="-1,-1,-1" />
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <GeometryModel3D>
                        <GeometryModel3D.Geometry>
                            <MeshGeometry3D Positions="-1,0,0 0,1,0 1,0,0" TriangleIndices="0,2,1" />
                        </GeometryModel3D.Geometry>
                        <GeometryModel3D.Material>
                            <DiffuseMaterial Brush="Yellow" />
                        </GeometryModel3D.Material>
                    </GeometryModel3D>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>

: 时,不再渲染

<SpecularMaterial Brush="Yellow" Color="Yellow" SpecularPower="24" />

当我将 GeometryModel3D.Material 更改为另一种材质(例如或)

<EmissiveMaterial Brush="Yellow" ></EmissiveMaterial>

,这是为什么?我应该使用不同的灯光来使镜面或发射材质发挥作用吗?

As I was playing around with the WPF's 3D support, I wanted to try different options for the 3d objects material types, so at first I created a simple scene, with just a triangle (which is rendered ok):

<Viewport3D>
            <Viewport3D.Camera>
                <PerspectiveCamera Position="-2,2,2" LookDirection="2,-2,-2" UpDirection="0,1,0" />
            </Viewport3D.Camera>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <DirectionalLight Color="White" Direction="-1,-1,-1" />
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <GeometryModel3D>
                        <GeometryModel3D.Geometry>
                            <MeshGeometry3D Positions="-1,0,0 0,1,0 1,0,0" TriangleIndices="0,2,1" />
                        </GeometryModel3D.Geometry>
                        <GeometryModel3D.Material>
                            <DiffuseMaterial Brush="Yellow" />
                        </GeometryModel3D.Material>
                    </GeometryModel3D>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>

But it seems that the triangle is no longer rendered when I changed the GeometryModel3D.Material to another material like

<SpecularMaterial Brush="Yellow" Color="Yellow" SpecularPower="24" />

or

<EmissiveMaterial Brush="Yellow" ></EmissiveMaterial>

Why is that? should I be using different lights for the specular or emissive materials to work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬花如无物 2024-11-01 12:15:46

发射材料不能单独工作,需要与其他材料结合使用。举例来说:

<GeometryModel3D.Material>
  <MaterialGroup>
    <DiffuseMaterial Brush="Black"></DiffuseMaterial>
    <EmissiveMaterial Brush="Yellow" ></EmissiveMaterial>
  </MaterialGroup>
</GeometryModel3D.Material>

Emissive material does not work by its own, use it in combination with other materials. As for example:

<GeometryModel3D.Material>
  <MaterialGroup>
    <DiffuseMaterial Brush="Black"></DiffuseMaterial>
    <EmissiveMaterial Brush="Yellow" ></EmissiveMaterial>
  </MaterialGroup>
</GeometryModel3D.Material>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文