From 704c9eec833957473d6d7f3df53a081c28583156 Mon Sep 17 00:00:00 2001 From: engineer_apple Date: Thu, 27 Feb 2020 00:17:46 +0000 Subject: [PATCH] BurningVideo 0.51 - NormalMap git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6101 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 6 +- examples/Demo/CMainMenu.cpp | 2 +- source/Irrlicht/CSoftwareDriver2.cpp | 126 ++++++--------------------- source/Irrlicht/CSoftwareDriver2.h | 1 - source/Irrlicht/CTRNormalMap.cpp | 32 +++---- 5 files changed, 48 insertions(+), 119 deletions(-) diff --git a/changes.txt b/changes.txt index ab076bf0..543d2bde 100644 --- a/changes.txt +++ b/changes.txt @@ -1,13 +1,17 @@ -------------------------- Changes in 1.9 (not yet released) -- BurningVideo: 0.50 +- BurningVideo: 0.51 - 10 year anniversary update - Lighting model reworked. moved to eyespace like openGL. [Specular Highlights, Fog, Sphere/Reflection Map] - increased internal s4DVertex to support 4 Textures and 4 Colors [switchable] - Textures are handled as sRGB during Mipmap Generation. More accurate, less visual disruption - 2D is drawn as 3D like hardware drivers. [switchable]. enables viewport scaling, material2D - Texture Spatial Resolution Limiting working. [lower memory consumption,SOFTWARE_DRIVER_2_TEXTURE_MAXSIZE] + - NormalMap for 1 Light accurate. still all lights are accumulated - SuperTuxKart 8.0.1 playable + - Known Problems + - Depthbuffer range not equal to Hardware Drivers. Problems with Orthographic Stencil Shadows + - Triangle MipMap Selection. Wrong for TextureAtlas and Billboards - Fix CPLYMeshFileLoader checking for wrong vertex count when switching between 16/32 bit. Thanks @randomMesh for reporting. - Fix bug that AnimatedMeshSceneNode ignored ReadOnlyMaterials flag when checking materials for transparent render passes. - Unify checks if materials should use transparent render pass with new IVideoDriver::needsTransparentRenderPass function. diff --git a/examples/Demo/CMainMenu.cpp b/examples/Demo/CMainMenu.cpp index 2a69dc95..572db9ec 100644 --- a/examples/Demo/CMainMenu.cpp +++ b/examples/Demo/CMainMenu.cpp @@ -70,7 +70,7 @@ bool CMainMenu::run() gui::IGUIListBox* box = guienv->addListBox(core::rect(10,10,220,120), optTab, 1); box->addItem(L"OpenGL 1.5"); box->addItem(L"Direct3D 9.0c"); - box->addItem(L"Burning's Video 0.5"); + box->addItem(L"Burning's Video 0.51"); box->addItem(L"Irrlicht Software Renderer 1.0"); switch (driverType ) { diff --git a/source/Irrlicht/CSoftwareDriver2.cpp b/source/Irrlicht/CSoftwareDriver2.cpp index 906b86c9..0536491d 100644 --- a/source/Irrlicht/CSoftwareDriver2.cpp +++ b/source/Irrlicht/CSoftwareDriver2.cpp @@ -145,7 +145,7 @@ inline void rotateVec3Vec4(const irr::core::CMatrix4& m, T* burning_restrict out[3] = 0.f; } -//https://github.com/ekmett/approximate/blob/master/cbits/fast.c powf_fast_precise +//based on https://github.com/ekmett/approximate/blob/master/cbits/fast.c powf_fast_precise static inline float powf_limit(const float a, const float b) { if (a <= 0.0000001f) return 0.f; @@ -410,7 +410,6 @@ CBurningVideoDriver::~CBurningVideoDriver() } // delete triangle renderers - for (s32 i=0; iTangent.X + vp.y * tangent->Tangent.Y + vp.z * tangent->Tangent.Z ); - l.y = (vp.x * tangent->Binormal.X + vp.y * tangent->Binormal.Y + vp.z * tangent->Binormal.Z ); - l.z = (vp.x * tangent->Normal.X + vp.y * tangent->Normal.Y + vp.z * tangent->Normal.Z ); - #else - l.x = (vp.x * tangent->Tangent.X + vp.y * tangent->Binormal.X + vp.z * tangent->Normal.X ); - l.y = (vp.x * tangent->Tangent.Y + vp.y * tangent->Binormal.Y + vp.z * tangent->Normal.Y ); - l.z = (vp.x * tangent->Tangent.Z + vp.y * tangent->Binormal.Z + vp.z * tangent->Normal.Z ); - #endif - - - /* - f32 scale = 1.f / 128.f; - if ( dest->LightTangent[0].y != 0.f ) - scale /= dest->LightTangent[0].y; - - // emboss, shift coordinates - dest->Tex[1].x = dest->Tex[0].x + l.r * scale; - dest->Tex[1].y = dest->Tex[0].y + l.g * scale; - */ - dest->Tex[1].x = dest->Tex[0].x; - dest->Tex[1].y = dest->Tex[0].y; - - // scale bias - light_accu.x += l.x; - light_accu.y += l.y; - light_accu.z += l.z; + light_accu.x += (vp.x * tangent->Tangent.X + vp.y * tangent->Tangent.Y + vp.z * tangent->Tangent.Z ); + light_accu.y += (vp.x * tangent->Binormal.X + vp.y * tangent->Binormal.Y + vp.z * tangent->Binormal.Z ); + light_accu.z += (vp.x * tangent->Normal.X + vp.y * tangent->Normal.Y + vp.z * tangent->Normal.Z ); } - //normalize [-1,+1] to [0,1] - light_accu.normalize_pack_xyz(dest->LightTangent[0],0.5f, 0.5f); + //normalize [-1,+1] to [0,1] -> obsolete + light_accu.normalize_pack_xyz(dest->LightTangent[0],1.f, 0.f); + dest->Tex[1].x = dest->Tex[0].x; + dest->Tex[1].y = dest->Tex[0].y; + } else if (Material.org.Lighting) { @@ -2483,28 +2441,6 @@ s32 CBurningVideoDriver::addDynamicLight(const SLight& dl) return EyeSpace.Light.size() - 1; } -#if 0 -/*! - Camera Position in World Space -*/ -void CBurningVideoDriver::getCameraPosWorldSpace() -{ - transform_calc(ETS_VIEW_INVERSE); - - const f32 *M = Transformation[ETS_VIEW_INVERSE].pointer(); - - /* The viewpoint is at (0., 0., 0.) in eye space. - Turning this into a vector [0 0 0 1] and multiply it by - the inverse of the view matrix, the resulting vector is the - object space location of the camera. - */ - - EyeSpace.camworldpos.x = M[12]; - EyeSpace.camworldpos.y = M[13]; - EyeSpace.camworldpos.z = M[14]; - EyeSpace.camworldpos.w = 1.f; -} -#endif //! Turns a dynamic light on or off void CBurningVideoDriver::turnLightOn(s32 lightIndex, bool turnOn) @@ -2761,8 +2697,6 @@ void CBurningVideoDriver::setMaterial(const SMaterial& material) } - - //! Sets the fog mode. void CBurningVideoDriver::setFog(SColor color, E_FOG_TYPE fogType, f32 start, f32 end, f32 density, bool pixelFog, bool rangeFog) @@ -2806,8 +2740,7 @@ void CBurningVideoDriver::lightVertex_eye(s4DVertex *dest, u32 vertexargb) for (i = 0; i < EyeSpace.Light.size(); ++i) { - const SBurningShaderLight &light = EyeSpace.Light[i]; - + const SBurningShaderLight& light = EyeSpace.Light[i]; if (!light.LightIsOn) continue; @@ -2961,6 +2894,7 @@ void CBurningVideoDriver::lightVertex_eye(s4DVertex *dest, u32 vertexargb) dColor.sat(dest->Color[0], vertexargb); + } #endif @@ -3542,8 +3476,6 @@ const core::dimension2d& CBurningVideoDriver::getCurrentRenderTargetSize() } - - //! Draws a 3d line. void CBurningVideoDriver::draw3DLine(const core::vector3df& start, const core::vector3df& end, SColor color_start) @@ -3619,15 +3551,15 @@ void CBurningVideoDriver::draw3DLine(const core::vector3df& start, const wchar_t* CBurningVideoDriver::getName() const { #ifdef BURNINGVIDEO_RENDERER_BEAUTIFUL - return L"Burning's Video 0.50 beautiful"; + return L"Burning's Video 0.51 beautiful"; #elif defined ( BURNINGVIDEO_RENDERER_ULTRA_FAST ) - return L"Burning's Video 0.50 ultra fast"; + return L"Burning's Video 0.51 ultra fast"; #elif defined ( BURNINGVIDEO_RENDERER_FAST ) - return L"Burning's Video 0.50 fast"; + return L"Burning's Video 0.51 fast"; #elif defined ( BURNINGVIDEO_RENDERER_CE ) - return L"Burning's Video 0.50 CE"; + return L"Burning's Video 0.51 CE"; #else - return L"Burning's Video 0.50"; + return L"Burning's Video 0.51"; #endif } diff --git a/source/Irrlicht/CSoftwareDriver2.h b/source/Irrlicht/CSoftwareDriver2.h index 5ea7e351..803deae6 100644 --- a/source/Irrlicht/CSoftwareDriver2.h +++ b/source/Irrlicht/CSoftwareDriver2.h @@ -299,7 +299,6 @@ namespace video ETS_MODEL_VIEW, ETS_NORMAL, //3x3 ModelView Tansposed Inverse - //ETS_VIEW_INVERSE, ETS_COUNT_BURNING = 16 }; diff --git a/source/Irrlicht/CTRNormalMap.cpp b/source/Irrlicht/CTRNormalMap.cpp index 0e1ef40a..5df81c7a 100644 --- a/source/Irrlicht/CTRNormalMap.cpp +++ b/source/Irrlicht/CTRNormalMap.cpp @@ -229,8 +229,11 @@ void CTRNormalMap::fragmentShader() f32 inversew = FIX_POINT_F32_MUL; - tFixPoint tx0, tx1; - tFixPoint ty0, ty1; + tFixPoint tx0, ty0; + +#ifdef IPOL_T1 + tFixPoint tx1, ty1; +#endif tFixPoint r0, g0, b0; tFixPoint r1, g1, b1; @@ -296,11 +299,10 @@ void CTRNormalMap::fragmentShader() tx1 = tofix ( line.t[1][0].x,inversew); ty1 = tofix ( line.t[1][0].y,inversew); - // diffuse map getSample_texture ( r0, g0, b0, &IT[0], tx0, ty0 ); - // normal map + // normal map ( same texcoord0 but different mipmapping) getSample_texture ( r1, g1, b1, &IT[1], tx1, ty1 ); r1 = ( r1 - FIX_POINT_HALF_COLOR) >> (COLOR_MAX_LOG2-1); @@ -313,30 +315,22 @@ void CTRNormalMap::fragmentShader() lz = tofix ( line.l[0][0].z, inversew ); // DOT 3 Normal Map light in tangent space - ndotl = saturateFix ( FIX_POINT_HALF_COLOR + ((imulFix_simple(r1,lx) + imulFix_simple(g1,ly) + imulFix_simple(b1,lz) ) << (COLOR_MAX_LOG2-1)) ); + //max(dot(LightVector, Normal), 0.0); + ndotl = clampfix_mincolor( (imulFix_simple(r1,lx) + imulFix_simple(g1,ly) + imulFix_simple(b1,lz) ) ); #endif #ifdef IPOL_C0 - //getSample_color(a3,r3,g3,b3, line.c[0][0],inversew); - //a3 = tofix(line.c[0][0].x, inversew); + //LightColor[0] r3 = tofix(line.c[0][0].y, inversew); g3 = tofix(line.c[0][0].z, inversew); b3 = tofix(line.c[0][0].w, inversew); - // N . L - r2 = imulFix ( imulFix_tex1 ( r0, ndotl ), r3 ); - g2 = imulFix ( imulFix_tex1 ( g0, ndotl ), g3 ); - b2 = imulFix ( imulFix_tex1 ( b0, ndotl ), b3 ); + // Lambert * LightColor[0] * Diffuse Texture; + r2 = imulFix (imulFix_simple( r3, ndotl ), r0 ); + g2 = imulFix (imulFix_simple( g3, ndotl ), g0 ); + b2 = imulFix (imulFix_simple( b3, ndotl ), b0 ); -/* - // heightmap: (1 - neu ) + alt - 0.5, on_minus_srcalpha + add signed - // emboss bump map - a4 -= a1; - r2 = clampfix_maxcolor ( clampfix_mincolor ( imulFix ( r0 + a4, r3 ) ) ); - g2 = clampfix_maxcolor ( clampfix_mincolor ( imulFix ( g0 + a4, g3 ) ) ); - b2 = clampfix_maxcolor ( clampfix_mincolor ( imulFix ( b0 + a4, b3 ) ) ); -*/ //vertex alpha blend ( and omit depthwrite ,hacky..) if (a3 + 2 < FIX_POINT_ONE) {