DirectX Lighting

不羁岁月 提交于 2019-12-24 00:59:39

问题


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.

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.

Cheers.


回答1:


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

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.

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

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.



来源:https://stackoverflow.com/questions/9955762/directx-lighting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!