CSoftwareDriver2: Normalmap like Irrlicht. Lightpos in vertex space

CSoftwareTexture2: Tweaking (guessing linear Image)
CBlit.h: allow mirror image (SuperTuxKart)

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6105 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
engineer_apple 2020-03-01 22:33:55 +00:00
parent f74abf1d2b
commit bca8023261
3 changed files with 39 additions and 13 deletions

@ -48,7 +48,7 @@ namespace irr
u32 srcPixelMul; //pixel byte size u32 srcPixelMul; //pixel byte size
u32 dstPixelMul; u32 dstPixelMul;
u32 srcPitch; //scanline byte size int srcPitch; //scanline byte size. allow negative for mirror
u32 dstPitch; u32 dstPitch;
bool stretch; bool stretch;

@ -1857,12 +1857,17 @@ void CBurningVideoDriver::VertexCache_fill(const u32 sourceIndex, const u32 dest
if ( !light.LightIsOn ) if ( !light.LightIsOn )
continue; 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.x = light.pos4.x - EyeSpace.vertex.x;
vp.y = light.pos4.y - EyeSpace.vertex.y; vp.y = light.pos4.y - EyeSpace.vertex.y;
vp.z = light.pos4.z - EyeSpace.vertex.z; vp.z = light.pos4.z - EyeSpace.vertex.z;
#endif
// lightcolor with standard model
// but shader is brighter and using different normalmatrix
// transform by tangent matrix // transform by tangent matrix
light_accu.x += (vp.x * tangent->Tangent.X + vp.y * tangent->Tangent.Y + vp.z * tangent->Tangent.Z ); light_accu.x += (vp.x * tangent->Tangent.X + vp.y * tangent->Tangent.Y + vp.z * tangent->Tangent.Z );

@ -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) //! 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<s32>* dstRect, const video::IImage* src, const core::rect<s32>* srcRect); void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect<s32>* dstRect, const video::IImage* src, const core::rect<s32>* srcRect, size_t flags);
//! constructor //! constructor
CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 flags, CBurningVideoDriver* driver) 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 #ifdef _DEBUG
setDebugName("CSoftwareTexture2"); setDebugName("CSoftwareTexture2");
@ -31,7 +36,6 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl
#ifndef SOFTWARE_DRIVER_2_MIPMAPPING #ifndef SOFTWARE_DRIVER_2_MIPMAPPING
Flags &= ~(GEN_MIPMAP| GEN_MIPMAP_AUTO); Flags &= ~(GEN_MIPMAP| GEN_MIPMAP_AUTO);
#endif #endif
//set baseclass properties //set baseclass properties
DriverType = EDT_BURNINGSVIDEO; DriverType = EDT_BURNINGSVIDEO;
ColorFormat = BURNINGSHADER_COLOR_FORMAT; ColorFormat = BURNINGSHADER_COLOR_FORMAT;
@ -39,15 +43,25 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl
HasMipMaps = (Flags & GEN_MIPMAP) != 0; HasMipMaps = (Flags & GEN_MIPMAP) != 0;
MipMap0_Area[0] = 1; MipMap0_Area[0] = 1;
MipMap0_Area[1] = 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; for ( size_t i = 0; i < SOFTWARE_DRIVER_2_MIPMAPPING_MAX; ++i ) MipMap[i] = 0;
if (!image) return; if (!image) return;
OriginalSize = image->getDimension(); OriginalSize = image->getDimension();
OriginalColorFormat = image->getColorFormat(); OriginalColorFormat = image->getColorFormat();
#if defined(IRRLICHT_sRGB) #if defined(IRRLICHT_sRGB)
if ( Flags & IMAGE_IS_LINEAR ) image->set_sRGB(0); 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 #endif
bool isCompressed = IImage::isCompressedFormat(OriginalColorFormat); bool isCompressed = IImage::isCompressedFormat(OriginalColorFormat);
@ -93,7 +107,7 @@ CSoftwareTexture2::CSoftwareTexture2(IImage* image, const io::path& name, u32 fl
if (!isCompressed) if (!isCompressed)
{ {
//image->copyToScalingBoxFilter ( MipMap[0],0, false ); //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 // if Original Size is used for calculation ( 2D position, font) it will be wrong
//OriginalSize = optSize; //OriginalSize = optSize;
@ -121,7 +135,11 @@ CSoftwareTexture2::~CSoftwareTexture2()
//! Regenerates the mip map levels of the texture. Useful after locking and //! Regenerates the mip map levels of the texture. Useful after locking and
//! modifying the texture //! modifying the texture
#if !defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
void CSoftwareTexture2::regenerateMipMapLevels(void* data, u32 layer) void CSoftwareTexture2::regenerateMipMapLevels(void* data, u32 layer)
#else
void CSoftwareTexture2::regenerateMipMapLevels(void* data)
#endif
{ {
int i; int i;
@ -155,7 +173,7 @@ void CSoftwareTexture2::regenerateMipMapLevels(void* data, u32 layer)
#endif #endif
//MipMap[i]->fill ( 0xFFFF4040 ); //MipMap[i]->fill ( 0xFFFF4040 );
//MipMap[i-1]->copyToScalingBoxFilter( MipMap[i], 0, false ); //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) else if (HasMipMaps && data)
@ -316,6 +334,9 @@ void CSoftwareTexture2::calcDerivative()
/* Software Render Target 2 */ /* Software Render Target 2 */
CSoftwareRenderTarget2::CSoftwareRenderTarget2(CBurningVideoDriver* driver) : Driver(driver) CSoftwareRenderTarget2::CSoftwareRenderTarget2(CBurningVideoDriver* driver) : Driver(driver)
#if defined(PATCH_SUPERTUX_8_0_1_with_1_9_0)
, IRenderTarget(0)
#endif
{ {
DriverType = EDT_BURNINGSVIDEO; DriverType = EDT_BURNINGSVIDEO;
@ -501,7 +522,7 @@ static inline int clipTest(absrect2 &o, const core::rect<s32>* a, const absrect2
//! stretches srcRect src to dstRect dst, applying a sliding window box filter in linear color space (sRGB->linear->sRGB) //! 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) // todo: texture jumps (mip selection problem)
void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect<s32>* dstRect, void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect<s32>* dstRect,
const video::IImage* src, const core::rect<s32>* srcRect) const video::IImage* src, const core::rect<s32>* srcRect,size_t flags)
{ {
const absrect2 dst_clip = { 0,0,(s32)dst->getDimension().Width,(s32)dst->getDimension().Height }; const absrect2 dst_clip = { 0,0,(s32)dst->getDimension().Width,(s32)dst->getDimension().Height };
absrect2 dc; absrect2 dc;
@ -519,8 +540,8 @@ void Resample_subSampling(eBlitter op, video::IImage* dst, const core::rect<s32>
const int dst_sRGB = dst->get_sRGB(); const int dst_sRGB = dst->get_sRGB();
const int src_sRGB = src->get_sRGB(); const int src_sRGB = src->get_sRGB();
#else #else
const int dst_sRGB = 1; const int dst_sRGB = (flags & CSoftwareTexture2::TEXTURE_IS_LINEAR) ? 0 : 1;
const int src_sRGB = 1; const int src_sRGB = (flags & CSoftwareTexture2::IMAGE_IS_LINEAR) ? 0 : 1;
#endif #endif