diff --git a/src/d3d/d3ddevice.cpp b/src/d3d/d3ddevice.cpp index 7849d37..bfd72f8 100644 --- a/src/d3d/d3ddevice.cpp +++ b/src/d3d/d3ddevice.cpp @@ -325,6 +325,16 @@ restoreD3d9Device(void) d3ddevice->SetIndices(deviceCache.indices); for(i = 0; i < MAXNUMSTREAMS; i++) d3ddevice->SetStreamSource(i, deviceCache.vertexStreams[i].buffer, deviceCache.vertexStreams[i].offset, deviceCache.vertexStreams[i].stride); + + // shader constants are zero now + d3dShaderState.fogDirty = true; + d3dShaderState.matColor.red = 0; + d3dShaderState.matColor.green = 0; + d3dShaderState.matColor.blue = 0; + d3dShaderState.matColor.alpha = 0; + d3dShaderState.surfProps.ambient = 0.0f; + d3dShaderState.surfProps.specular = 0.0f; + d3dShaderState.surfProps.diffuse = 0.0f; } void @@ -517,7 +527,7 @@ setMaterial_fix(const RGBA &color, const SurfaceProperties &surfProps) void -setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops) +setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp) { if(!equal(d3dShaderState.matColor, color)){ rw::RGBAf col; @@ -528,14 +538,16 @@ setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops) if(d3dShaderState.surfProps.ambient != surfaceprops.ambient || d3dShaderState.surfProps.specular != surfaceprops.specular || - d3dShaderState.surfProps.diffuse != surfaceprops.diffuse){ + d3dShaderState.surfProps.diffuse != surfaceprops.diffuse || + d3dShaderState.extraSurfProp != extraSurfProp){ float surfProps[4]; surfProps[0] = surfaceprops.ambient; surfProps[1] = surfaceprops.specular; surfProps[2] = surfaceprops.diffuse; - surfProps[3] = 0.0f; + surfProps[3] = extraSurfProp; d3ddevice->SetVertexShaderConstantF(VSLOC_surfProps, surfProps, 1); d3dShaderState.surfProps = surfaceprops; + d3dShaderState.extraSurfProp = extraSurfProp; } } diff --git a/src/d3d/rwd3d.h b/src/d3d/rwd3d.h index 8a55467..6ff8484 100644 --- a/src/d3d/rwd3d.h +++ b/src/d3d/rwd3d.h @@ -187,7 +187,7 @@ void getSamplerState(uint32 stage, uint32 type, uint32 *value); void flushCache(void); void setTexture(uint32 stage, Texture *tex); -void setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops); +void setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp = 0.0f); void setVertexShader(void *vs); void setPixelShader(void *ps); @@ -226,6 +226,7 @@ struct D3dShaderState } fogData, fogDisable; RGBA matColor; SurfaceProperties surfProps; + float extraSurfProp; float lightOffset[3]; int32 numDir, numPoint, numSpot; RGBAf ambient;