diff --git a/source/Irrlicht/CBlit.h b/source/Irrlicht/CBlit.h index 5950660c..b7788289 100644 --- a/source/Irrlicht/CBlit.h +++ b/source/Irrlicht/CBlit.h @@ -48,7 +48,7 @@ namespace irr u32 srcPixelMul; //pixel byte size u32 dstPixelMul; - u32 srcPitch; //scanline byte size + int srcPitch; //scanline byte size. allow negative for mirror u32 dstPitch; bool stretch; diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index cb8f1a18..d8ea8b8a 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -1857,12 +1857,17 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest if ( !light.LightIsOn ) continue; + // lightcolor with standard model + // but shader is different. treating light and vertex in same space +#if 1 + vp.x = light.pos.x - base->Pos.X; + vp.y = light.pos.y - base->Pos.Y; + vp.z = light.pos.z - base->Pos.Z; +#else vp.x = light.pos4.x - EyeSpace.vertex.x; vp.y = light.pos4.y - EyeSpace.vertex.y; vp.z = light.pos4.z - EyeSpace.vertex.z; - - // lightcolor with standard model - // but shader is brighter and using different normalmatrix +#endif // transform by tangent matrix light_accu.x += (vp.x * tangent->Tangent.X + vp.y * tangent->Tangent.Y + vp.z * tangent->Tangent.Z ); diff --git a/source/Irrlicht/CSoftwareTexture2.cpp b/source/Irrlicht/CSoftwareTexture2.cpp index 319c450b..b17e462d 100644 --- a/source/Irrlicht/CSoftwareTexture2.cpp +++ b/source/Irrlicht/CSoftwareTexture2.cpp @@ -18,11 +18,16 @@ namespace video { //! stretches srcRect src to dstRect dst, applying a sliding window box filter in linear color space (sRGB->linear->sRGB) -void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect* dstRect, const video::IImage* src, const core::rect* srcRect); +void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect* dstRect, const video::IImage* src, const core::rect* srcRect, size_t flags); //! constructor CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 flags, CBurningVideoDriver* driver) - : ITexture(name, ETT_2D),MipMapLOD(0), Flags ( flags ), Driver(driver) + : ITexture(name +#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) + , ETT_2D +#endif + ) + ,MipMapLOD(0), Flags(flags), Driver(driver) { #ifdef _DEBUG setDebugName("CSoftwareTexture2"); @@ -31,7 +36,6 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl #ifndef SOFTWARE_DRIVER_2_MIPMAPPING Flags &= ~(GEN_MIPMAP| GEN_MIPMAP_AUTO); #endif - //set baseclass properties DriverType = EDT_BURNINGSVIDEO; ColorFormat = BURNINGSHADER_COLOR_FORMAT; @@ -39,15 +43,25 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl HasMipMaps = (Flags & GEN_MIPMAP) != 0; MipMap0_Area[0] = 1; MipMap0_Area[1] = 1; - LodBIAS = 1.f; + LodBIAS = 0.75f; for ( size_t i = 0; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) MipMap[i] = 0; if (!image) return; OriginalSize = image->getDimension(); OriginalColorFormat = image->getColorFormat(); + #if defined(IRRLICHT_sRGB) if ( Flags & IMAGE_IS_LINEAR ) image->set_sRGB(0); +#else + //guessing linear image + if (name.find("light") >= 0 || + name.find("bump") >= 0 || + name.find("height") >= 0 + ) + { + Flags |= TEXTURE_IS_LINEAR | IMAGE_IS_LINEAR; + } #endif bool isCompressed = IImage::isCompressedFormat(OriginalColorFormat); @@ -93,7 +107,7 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl if (!isCompressed) { //image->copyToScalingBoxFilter ( MipMap[0],0, false ); - Resample_subSampling(BLITTER_TEXTURE,MipMap[0],0,image,0); + Resample_subSampling(BLITTER_TEXTURE,MipMap[0],0,image,0, Flags); } // if Original Size is used for calculation ( 2D position, font) it will be wrong //OriginalSize = optSize; @@ -121,7 +135,11 @@ CSoftwareTexture2::~CSoftwareTexture2() //! Regenerates the mip map levels of the texture. Useful after locking and //! modifying the texture +#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) void CSoftwareTexture2::regenerateMipMapLevels(void* data, u32 layer) +#else +void CSoftwareTexture2::regenerateMipMapLevels(void* data) +#endif { int i; @@ -155,7 +173,7 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data, u32 layer) #endif //MipMap[i]->fill ( 0xFFFF4040 ); //MipMap[i-1]->copyToScalingBoxFilter( MipMap[i], 0, false ); - Resample_subSampling(BLITTER_TEXTURE, MipMap[i], 0, MipMap[0], 0); + Resample_subSampling(BLITTER_TEXTURE, MipMap[i], 0, MipMap[0], 0, Flags); } } else if (HasMipMaps && data) @@ -316,6 +334,9 @@ void CSoftwareTexture2::calcDerivative() /* Software Render Target 2 */ CSoftwareRenderTarget2::CSoftwareRenderTarget2(CBurningVideoDriver* driver) : Driver(driver) +#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0) +, IRenderTarget(0) +#endif { DriverType = EDT_BURNINGSVIDEO; @@ -501,7 +522,7 @@ static inline int clipTest(absrect2 &o, const core::rect* a, const absrect2 //! stretches srcRect src to dstRect dst, applying a sliding window box filter in linear color space (sRGB->linear->sRGB) // todo: texture jumps (mip selection problem) void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect* dstRect, - const video::IImage* src, const core::rect* srcRect) + const video::IImage* src, const core::rect* srcRect,size_t flags) { const absrect2 dst_clip = { 0,0,(s32)dst->getDimension().Width,(s32)dst->getDimension().Height }; absrect2 dc; @@ -519,8 +540,8 @@ void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect const int dst_sRGB = dst->get_sRGB(); const int src_sRGB = src->get_sRGB(); #else - const int dst_sRGB = 1; - const int src_sRGB = 1; + const int dst_sRGB = (flags & CSoftwareTexture2::TEXTURE_IS_LINEAR) ? 0 : 1; + const int src_sRGB = (flags & CSoftwareTexture2::IMAGE_IS_LINEAR) ? 0 : 1; #endif