mirror of https://github.com/aap/librw.git
fixed d3d9 rendering
This commit is contained in:
parent
5fe9ca91e8
commit
dbb131d92b
|
@ -26,7 +26,7 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||||
{
|
{
|
||||||
RawMatrix world;
|
RawMatrix world;
|
||||||
|
|
||||||
d3d::lightingCB();
|
d3d::lightingCB(!!(atomic->geometry->flags & Geometry::NORMALS));
|
||||||
|
|
||||||
Geometry *geo = atomic->geometry;
|
Geometry *geo = atomic->geometry;
|
||||||
d3d::setRenderState(D3DRS_LIGHTING, !!(geo->flags & rw::Geometry::LIGHT));
|
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);
|
int lighting = !!(geo->flags & rw::Geometry::LIGHT);
|
||||||
if(lighting)
|
if(lighting)
|
||||||
d3d::lightingCB();
|
d3d::lightingCB(!!(atomic->geometry->flags & Geometry::NORMALS));
|
||||||
|
|
||||||
d3d::setRenderState(D3DRS_LIGHTING, lighting);
|
d3d::setRenderState(D3DRS_LIGHTING, lighting);
|
||||||
|
|
||||||
|
@ -80,16 +80,32 @@ defaultRenderCB(Atomic *atomic, InstanceDataHeader *header)
|
||||||
|
|
||||||
InstanceData *inst = header->inst;
|
InstanceData *inst = header->inst;
|
||||||
for(uint32 i = 0; i < header->numMeshes; i++){
|
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);
|
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
|
// Material colour
|
||||||
const rw::RGBA *col = &inst->material->color;
|
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_ALPHAARG1, D3DTA_CURRENT);
|
||||||
d3d::setTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CONSTANT);
|
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);
|
drawInst(header, inst);
|
||||||
inst++;
|
inst++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ IDirect3DDevice9 *d3ddevice = nil;
|
||||||
#define MAX_LIGHTS 8
|
#define MAX_LIGHTS 8
|
||||||
|
|
||||||
void
|
void
|
||||||
lightingCB(void)
|
lightingCB(bool32 normals)
|
||||||
{
|
{
|
||||||
World *world;
|
World *world;
|
||||||
RGBAf ambLight = { 0.0, 0.0, 0.0, 1.0 };
|
RGBAf ambLight = { 0.0, 0.0, 0.0, 1.0 };
|
||||||
|
@ -46,7 +46,9 @@ lightingCB(void)
|
||||||
Light *l = Light::fromWorld(lnk);
|
Light *l = Light::fromWorld(lnk);
|
||||||
if((l->getFlags() & Light::LIGHTATOMICS) == 0)
|
if((l->getFlags() & Light::LIGHTATOMICS) == 0)
|
||||||
continue;
|
continue;
|
||||||
if(l->getType() == Light::DIRECTIONAL){
|
if(normals &&
|
||||||
|
l->getType() == Light::DIRECTIONAL &&
|
||||||
|
l->getFlags() & Light::LIGHTATOMICS){
|
||||||
if(n >= MAX_LIGHTS)
|
if(n >= MAX_LIGHTS)
|
||||||
continue;
|
continue;
|
||||||
light.Diffuse = *(D3DCOLORVALUE*)&l->color;
|
light.Diffuse = *(D3DCOLORVALUE*)&l->color;
|
||||||
|
|
|
@ -20,7 +20,7 @@ extern bool32 isP8supported;
|
||||||
extern IDirect3DDevice9 *d3ddevice;
|
extern IDirect3DDevice9 *d3ddevice;
|
||||||
extern Device renderdevice;
|
extern Device renderdevice;
|
||||||
|
|
||||||
void lightingCB(void);
|
void lightingCB(bool32 normals);
|
||||||
|
|
||||||
struct Im3DVertex
|
struct Im3DVertex
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue