DirectX照明 [英] DirectX Lighting

查看:94
本文介绍了DirectX照明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。我有一个使用DirectX10和C ++的小游戏。但是,我开始使用来自OBJ10直接X示例的meshloader来制作它,而我只是在上面构建它。但是,尽管它们有颜色,但我的对象看上去都只是纯黑色。

Hi. I've got a small game using directX10 and C++. However, I started making it using the meshloaderfromOBJ10 direct X sample and I have just been building on it. However, my objects are all looking just plain black althought they have colour.

我知道这是由于光线的原因,但似乎更改了任何与代码有关的代码

I know this is because of the light, but seemingly changing any of the code to do with the light does nothing from this sample.

我想知道是否有人知道一种简单的(ish)方法来照亮所有物体,就像在各处照亮一样。我不在乎阴影或反射之类的东西,因为我在做的事情不是必需的,但是很高兴看到我的物体而不仅仅是轮廓。

I was wondering if anyone knows a simple(ish) method to just light everything, as in make it bright everywhere. I don't care about shadows or reflection or anything like that as for what I'm doing it is not necessary but it would be nice to see my objects instead of just silhouettes.

干杯。

推荐答案


但是,尽管我的对象看起来像纯黑色

However, my objects are all looking just plain black althought they have colour.

如果着色器希望设置纹理并从该纹理中读取材质信息,并且将空纹理设置为相应的纹理阶段(采样器或在DX10中调用的任何东西),着色器将从该空纹理读取黑色。而且,无论您使用多少光,没有镜面反射/发射或反射贴图的黑色材质始终看起来是黑色的。

If shader expects texture to be set and reads material information from that texture, and you set null texture to corresponding texture stage(sampler or whatever it is called in DX10), shader will read black color from that null texture. And black material without specular/emissive or reflection mapping will always look black, no matter how many lights you use.

在没有纹理的材质/物体上使用白色纹理(假设您的着色器了解材质颜色并将其与纹理颜色相乘)。或切换至DX9并使用固定功能的管线,将丢失的纹理视为白色。或修改着色器以支持没有纹理的材质。

Use white texture on materials/objects without texture (assuming your shader understands material color and multiplies it with texture color). Or switch to DX9 and use fixed-function pipeline which treats missing textures as white. Or modify the shader to support materials without texture.


方法只是照亮所有内容,如使其在任何地方都变得明亮

method to just light everything, as in make it bright everywhere

您可以使用全局环境(必须在着色器中添加它,因为D3D10没有固定的功能管线)。但是,您并不是真的想要它,因为

You can use "global" ambient (which you'll have to add in your shader, because D3D10 doesn't have fixed function pipeline). However, you don't really want it, because


我不在乎阴影

I don't care about shadows

您实际上并不关心阴影。全球环境值将使所有材料均匀着色,没有任何渐变。这意味着,如果您的纹理没有复杂的网格,您将无法弄清楚所要查看的内容,并且所有带纹理的内容都很难看。同样,黑色材料仍将保持黑色。因此,要使它到处都是明亮,您将需要太阳-定向光源或很大的点光源。

you actually care about shadows just don't know it yet. global ambient value will make all materials evenly colored without any gradients. It means that if you have an untextured complicated mesh, you won't be able to figure out what you're looking at and everything that is textured will look ugly. Also, black materials will still remain black. So to "make it bright everywhere", you'll need "sun" - directional light source or a very big point light.

这篇关于DirectX照明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆