fixed d3d9 rendering
This commit is contained in:
parent
5fe9ca91e8
commit
dbb131d92b
@ -26,7 +26,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
{
|
||||
RawMatrix world;
|
||||
|
||||
d3d::lightingCB();
|
||||
d3d::lightingCB(!!(atomic->geometry->flags & Geometry::NORMALS));
|
||||
|
||||
Geometry *geo = atomic->geometry;
|
||||
d3d::setRenderState(D3DRS_LIGHTING, !!(geo->flags & rw::Geometry::LIGHT));
|
||||
|
@ -65,7 +65,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
|
||||
int lighting = !!(geo->flags & rw::Geometry::LIGHT);
|
||||
if(lighting)
|
||||
d3d::lightingCB();
|
||||
d3d::lightingCB(!!(atomic->geometry->flags & Geometry::NORMALS));
|
||||
|
||||
d3d::setRenderState(D3DRS_LIGHTING, lighting);
|
||||
|
||||
@ -80,16 +80,32 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
|
||||
InstanceData *inst = header->inst;
|
||||
for(uint32 i = 0; i < header->numMeshes; i++){
|
||||
// Texture
|
||||
d3d::setTexture(0, inst->material->texture);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
|
||||
SetRenderState(VERTEXALPHA, inst->vertexAlpha || inst->material->color.alpha != 255);
|
||||
const static rw::RGBA white = { 255, 255, 255, 255 };
|
||||
d3d::setMaterial(inst->material->surfaceProps, white);
|
||||
|
||||
d3d::setRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
if(geo->flags & Geometry::PRELIT)
|
||||
d3d::setRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||
else
|
||||
d3d::setRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
d3d::setRenderState(D3DRS_DIFFUSEMATERIALSOURCE, inst->vertexAlpha ? D3DMCS_COLOR1 : D3DMCS_MATERIAL);
|
||||
|
||||
if(inst->material->texture){
|
||||
// Texture
|
||||
d3d::setTexture(0, inst->material->texture);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
}else{
|
||||
d3d::setTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
d3d::setTextureStageState(0, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
d3d::setTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
}
|
||||
|
||||
// Material colour
|
||||
const rw::RGBA *col = &inst->material->color;
|
||||
@ -101,16 +117,6 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||
d3d::setTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
d3d::setTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CONSTANT);
|
||||
|
||||
const static rw::RGBA white = { 255, 255, 255, 255 };
|
||||
d3d::setMaterial(inst->material->surfaceProps, white);
|
||||
|
||||
d3d::setRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
if(geo->flags & Geometry::PRELIT)
|
||||
d3d::setRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||
else
|
||||
d3d::setRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
|
||||
d3d::setRenderState(D3DRS_DIFFUSEMATERIALSOURCE, inst->vertexAlpha ? D3DMCS_COLOR1 : D3DMCS_MATERIAL);
|
||||
|
||||
drawInst(header, inst);
|
||||
inst++;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ IDirect3DDevice9 *d3ddevice = nil;
|
||||
#define MAX_LIGHTS 8
|
||||
|
||||
void
|
||||
lightingCB(void)
|
||||
lightingCB(bool32 normals)
|
||||
{
|
||||
World *world;
|
||||
RGBAf ambLight = { 0.0, 0.0, 0.0, 1.0 };
|
||||
@ -46,7 +46,9 @@ lightingCB(void)
|
||||
Light *l = Light::fromWorld(lnk);
|
||||
if((l->getFlags() & Light::LIGHTATOMICS) == 0)
|
||||
continue;
|
||||
if(l->getType() == Light::DIRECTIONAL){
|
||||
if(normals &&
|
||||
l->getType() == Light::DIRECTIONAL &&
|
||||
l->getFlags() & Light::LIGHTATOMICS){
|
||||
if(n >= MAX_LIGHTS)
|
||||
continue;
|
||||
light.Diffuse = *(D3DCOLORVALUE*)&l->color;
|
||||
|
@ -20,7 +20,7 @@ extern bool32 isP8supported;
|
||||
extern IDirect3DDevice9 *d3ddevice;
|
||||
extern Device renderdevice;
|
||||
|
||||
void lightingCB(void);
|
||||
void lightingCB(bool32 normals);
|
||||
|
||||
struct Im3DVertex
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user