@@ -50,7 +50,7 @@ Renderer::Renderer(IVideoDriver* _driver, IAssetManager* _assetManager, scene::I
50
50
#ifdef _IRR_BUILD_OPTIX_
51
51
m_optixManager (), m_cudaStream(nullptr ), m_optixContext(),
52
52
#endif
53
- rrShapeCache (), rrInstances(), m_prevViewProj (), m_sceneBound(FLT_MAX,FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX,-FLT_MAX),
53
+ rrShapeCache (), rrInstances(), m_prevView (), m_sceneBound(FLT_MAX,FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX,-FLT_MAX),
54
54
m_maxRaysPerDispatch(0 ), m_staticViewData{{0 .f ,0 .f ,0 .f },0u ,{0 .f ,0 .f },{0 .f ,0 .f },{0u ,0u },0u ,0u },
55
55
m_raytraceCommonData{core::matrix4SIMD (),core::matrix3x4SIMD (),0 ,0 ,0 },
56
56
m_indirectDrawBuffers{nullptr },m_cullPushConstants{core::matrix4SIMD (),1 .f ,0u ,0u ,0u },m_cullWorkGroups(0u ),
@@ -994,7 +994,7 @@ void Renderer::deinit()
994
994
m_raytraceCommonData = {core::matrix4SIMD (),core::matrix3x4SIMD (),0 ,0 ,0 };
995
995
m_staticViewData = {{0 .f ,0 .f ,0 .f },0u ,{0 .f ,0 .f },{0 .f ,0 .f },{0u ,0u },0u ,0u };
996
996
m_maxRaysPerDispatch = 0u ;
997
- std::fill_n (m_prevViewProj .pointer (),16u ,0 .f );
997
+ std::fill_n (m_prevView .pointer (),12u ,0 .f );
998
998
m_sceneBound = core::aabbox3df (FLT_MAX, FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX);
999
999
1000
1000
m_rrManager->detachInstances (rrInstances.begin (),rrInstances.end ());
@@ -1021,32 +1021,25 @@ void Renderer::render(nbl::ITimer* timer)
1021
1021
1022
1022
// check if camera moved
1023
1023
{
1024
- const auto currentViewProj = camera->getConcatenatedMatrix ();
1025
- auto properEquals = [](const auto & rhs , const auto & lhs ) -> bool
1024
+ const auto currentView = camera->getViewMatrix ();
1025
+ auto properEquals = [](const auto & lhs , const auto & rhs ) -> bool
1026
1026
{
1027
- const float rotationTolerance = 1 .001f ;
1028
- const float positionTolerance = 1 .005f ;
1029
- const float projectionTolerance = 1 .0005f ;
1030
- const core::matrix4SIMD tolerance (
1031
- rotationTolerance,rotationTolerance,rotationTolerance,positionTolerance,
1032
- rotationTolerance,rotationTolerance,rotationTolerance,positionTolerance,
1033
- rotationTolerance,rotationTolerance,rotationTolerance,positionTolerance,
1034
- projectionTolerance,projectionTolerance,projectionTolerance,projectionTolerance
1035
- );
1036
- for (auto r=0 ; r<4u ; r++)
1027
+ const float rotationTolerance = 1 .005f ;
1028
+ const float positionTolerance = 1 .001f ;
1029
+ for (auto r=0 ; r<3u ; r++)
1037
1030
for (auto c=0 ; c<4u ; c++)
1038
1031
{
1039
1032
const float ratio = core::abs (rhs.rows [r][c]/lhs.rows [r][c]);
1040
1033
// TODO: do by ULP
1041
1034
if (core::isnan (ratio) || core::isinf (ratio))
1042
1035
continue ;
1043
- if (ratio>tolerance.rows [r][c] || ratio*tolerance.rows [r][c]<1 .f )
1036
+ const float tolerance = c!=3u ? rotationTolerance:positionTolerance;
1037
+ if (ratio>tolerance || ratio*tolerance<1 .f )
1044
1038
return false ;
1045
1039
}
1046
1040
return true ;
1047
1041
};
1048
- // static core::matrix4x3 prevView;
1049
- if (!properEquals (m_prevViewProj,currentViewProj))
1042
+ if (!properEquals (currentView,m_prevView))
1050
1043
{
1051
1044
m_raytraceCommonData.framesDispatched = 0u ;
1052
1045
@@ -1056,18 +1049,21 @@ void Renderer::render(nbl::ITimer* timer)
1056
1049
m_driver->clearColorBuffer (EFAP_COLOR_ATTACHMENT0, clearAccumulation);
1057
1050
}
1058
1051
1059
- m_prevViewProj = currentViewProj;
1060
- // prevView = camera->getRelativeTransformationMatrix();
1052
+ m_prevView = currentView;
1053
+ }
1054
+ else // need this to stop mouse cursor drift
1055
+ {
1056
+ core::matrix3x4SIMD invView;
1057
+ m_prevView.getInverse (invView);
1058
+ camera->setRelativeTransformationMatrix (invView.getAsRetardedIrrlichtMatrix ());
1061
1059
}
1062
- // else // need this to stop mouse cursor drift
1063
- // camera->setRelativeTransformationMatrix(prevView);
1064
1060
}
1065
1061
// draw jittered frame
1066
1062
{
1067
1063
// jitter with AA AntiAliasingSequence
1068
1064
const auto modifiedViewProj = [&](uint32_t frameID)
1069
1065
{
1070
- const float stddev = 1 . 25f ;
1066
+ const float stddev = 0 . 707f ;
1071
1067
const float * sample = AntiAliasingSequence[frameID];
1072
1068
const float phi = core::PI<float >()*(2 .f *sample[1 ]-1 .f );
1073
1069
const float sinPhi = sinf (phi);
@@ -1077,7 +1073,7 @@ void Renderer::render(nbl::ITimer* timer)
1077
1073
core::matrix4SIMD jitterMatrix;
1078
1074
jitterMatrix.rows [0 ][3 ] = cosPhi*r*m_staticViewData.rcpPixelSize .x ;
1079
1075
jitterMatrix.rows [1 ][3 ] = sinPhi*r*m_staticViewData.rcpPixelSize .y ;
1080
- return core::concatenateBFollowedByA (jitterMatrix,m_prevViewProj );
1076
+ return core::concatenateBFollowedByA (jitterMatrix,core::concatenateBFollowedByA (camera-> getProjectionMatrix (),m_prevView) );
1081
1077
}(m_raytraceCommonData.framesDispatched ++);
1082
1078
m_raytraceCommonData.rcpFramesDispatched = 1 .f /float (m_raytraceCommonData.framesDispatched );
1083
1079
0 commit comments