@@ -51,9 +51,8 @@ Renderer::Renderer(IVideoDriver* _driver, IAssetManager* _assetManager, scene::I
51
51
m_optixManager (), m_cudaStream(nullptr ), m_optixContext(),
52
52
#endif
53
53
m_prevView (), m_sceneBound(FLT_MAX,FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX,-FLT_MAX),
54
- m_maxRaysPerDispatch(0 ), m_framesDispatched(0u ),
55
- m_staticViewData{{0 .f ,0 .f ,0 .f },0u ,{0 .f ,0 .f },{0 .f ,0 .f },{0u ,0u },0u ,0u },
56
- m_raytraceCommonData{core::matrix3x4SIMD (),vec3 (),0 ,0 ,0 },
54
+ m_maxRaysPerDispatch(0 ), m_framesDispatched(0u ), m_rcpPixelSize{0 .f ,0 .f },
55
+ m_staticViewData{{0 .f ,0 .f ,0 .f },0u ,{0u ,0u },0u ,0u }, m_raytraceCommonData{vec3 (),0 .f ,0u ,0u ,0u ,0u ,0u },
57
56
m_indirectDrawBuffers{nullptr },m_cullPushConstants{core::matrix4SIMD (),1 .f ,0u ,0u ,0u },m_cullWorkGroups(0u ),
58
57
m_raygenWorkGroups{0u ,0u },m_visibilityBuffer(nullptr ),m_colorBuffer(nullptr )
59
58
{
@@ -151,11 +150,10 @@ Renderer::Renderer(IVideoDriver* _driver, IAssetManager* _assetManager, scene::I
151
150
auto sampler = m_driver->createGPUSampler (samplerParams);
152
151
{
153
152
154
- constexpr auto raygenDescriptorCount = 2u ;
153
+ constexpr auto raygenDescriptorCount = 1u ;
155
154
IGPUDescriptorSetLayout::SBinding bindings[raygenDescriptorCount];
156
155
fillIotaDescriptorBindingDeclarations (bindings,ISpecializedShader::ESS_COMPUTE,raygenDescriptorCount,EDT_COMBINED_IMAGE_SAMPLER);
157
156
bindings[0 ].samplers = &sampler;
158
- bindings[1 ].samplers = &sampler;
159
157
160
158
m_raygenDSLayout = m_driver->createGPUDescriptorSetLayout (bindings,bindings+raygenDescriptorCount);
161
159
}
@@ -661,7 +659,7 @@ void Renderer::init(const SAssetBundle& meshes, core::smart_refctd_ptr<ICPUBuffe
661
659
{
662
660
deinit ();
663
661
664
- core::smart_refctd_ptr<IGPUImageView> depthBuffer, visibilityBuffer;
662
+ core::smart_refctd_ptr<IGPUImageView> visibilityBuffer;
665
663
// set up Descriptor Sets
666
664
{
667
665
// captures m_globalBackendDataDS, creates m_indirectDrawBuffers, sets up m_mdiDrawCalls ranges
@@ -685,8 +683,7 @@ void Renderer::init(const SAssetBundle& meshes, core::smart_refctd_ptr<ICPUBuffe
685
683
assert (film.cropOffsetY == 0 );
686
684
m_staticViewData.imageDimensions = {static_cast <uint32_t >(film.cropWidth ),static_cast <uint32_t >(film.cropHeight )};
687
685
}
688
- m_staticViewData.rcpPixelSize = { 2 .f /float (m_staticViewData.imageDimensions .x ),-2 .f /float (m_staticViewData.imageDimensions .y ) };
689
- m_staticViewData.rcpHalfPixelSize = { 1 .f /float (m_staticViewData.imageDimensions .x )-1 .f ,1 .f -1 .f /float (m_staticViewData.imageDimensions .y ) };
686
+ m_rcpPixelSize = { 2 .f /float (m_staticViewData.imageDimensions .x ),-2 .f /float (m_staticViewData.imageDimensions .y ) };
690
687
}
691
688
692
689
// figure out dispatch sizes
@@ -933,12 +930,10 @@ void Renderer::init(const SAssetBundle& meshes, core::smart_refctd_ptr<ICPUBuffe
933
930
m_driver->updateDescriptorSets (7u ,writes,0u ,nullptr );
934
931
// set up m_raygenDS
935
932
{
936
- depthBuffer = createScreenSizedTexture (EF_D32_SFLOAT);
937
- setImageInfo (infos+0 ,asset::EIL_SHADER_READ_ONLY_OPTIMAL,core::smart_refctd_ptr (depthBuffer));
938
933
visibilityBuffer = createScreenSizedTexture (EF_R32G32B32A32_UINT);
939
- setImageInfo (infos+1 ,asset::EIL_SHADER_READ_ONLY_OPTIMAL,core::smart_refctd_ptr (visibilityBuffer));
934
+ setImageInfo (infos+0 ,asset::EIL_SHADER_READ_ONLY_OPTIMAL,core::smart_refctd_ptr (visibilityBuffer));
940
935
941
- setDstSetAndDescTypesOnWrites (m_raygenDS.get (),writes,infos,{EDT_COMBINED_IMAGE_SAMPLER,EDT_COMBINED_IMAGE_SAMPLER });
936
+ setDstSetAndDescTypesOnWrites (m_raygenDS.get (),writes,infos,{EDT_COMBINED_IMAGE_SAMPLER});
942
937
}
943
938
m_driver->updateDescriptorSets (descriptorUpdateCounts[2 ],writes,0u ,nullptr );
944
939
// set up m_closestHitDS
@@ -971,7 +966,7 @@ void Renderer::init(const SAssetBundle& meshes, core::smart_refctd_ptr<ICPUBuffe
971
966
972
967
973
968
m_visibilityBuffer = m_driver->addFrameBuffer ();
974
- m_visibilityBuffer->attach (EFAP_DEPTH_ATTACHMENT,std::move (depthBuffer ));
969
+ m_visibilityBuffer->attach (EFAP_DEPTH_ATTACHMENT,createScreenSizedTexture (EF_D32_SFLOAT ));
975
970
m_visibilityBuffer->attach (EFAP_COLOR_ATTACHMENT0,std::move (visibilityBuffer));
976
971
977
972
m_colorBuffer = m_driver->addFrameBuffer ();
@@ -1102,8 +1097,9 @@ void Renderer::deinit()
1102
1097
m_indirectDrawBuffers[1 ] = m_indirectDrawBuffers[0 ] = nullptr ;
1103
1098
m_indexBuffer = nullptr ;
1104
1099
1105
- m_raytraceCommonData = {core::matrix3x4SIMD (),vec3 (),0 ,0 ,0 ,0u };
1106
- m_staticViewData = {{0 .f ,0 .f ,0 .f },0u ,{0 .f ,0 .f },{0 .f ,0 .f },{0u ,0u },0u ,0u };
1100
+ m_raytraceCommonData = {vec3 (),0 ,0 ,0 ,0u };
1101
+ m_staticViewData = {{0 .f ,0 .f ,0 .f },0u ,{0u ,0u },0u ,0u };
1102
+ m_rcpPixelSize = {0 .f ,0 .f };
1107
1103
m_framesDispatched = 0u ;
1108
1104
m_maxRaysPerDispatch = 0u ;
1109
1105
std::fill_n (m_prevView.pointer (),12u ,0 .f );
@@ -1182,8 +1178,8 @@ void Renderer::render(nbl::ITimer* timer)
1182
1178
const float truncated = sample[0 ]*0 .99999f +0 .00001f ;
1183
1179
const float r = sqrtf (-2 .f *logf (truncated))*stddev;
1184
1180
core::matrix4SIMD jitterMatrix;
1185
- jitterMatrix.rows [0 ][3 ] = cosPhi*r*m_staticViewData. rcpPixelSize .x ;
1186
- jitterMatrix.rows [1 ][3 ] = sinPhi*r*m_staticViewData. rcpPixelSize .y ;
1181
+ jitterMatrix.rows [0 ][3 ] = cosPhi*r*m_rcpPixelSize .x ;
1182
+ jitterMatrix.rows [1 ][3 ] = sinPhi*r*m_rcpPixelSize .y ;
1187
1183
return core::concatenateBFollowedByA (jitterMatrix,core::concatenateBFollowedByA (camera->getProjectionMatrix (),m_prevView));
1188
1184
}(m_framesDispatched++);
1189
1185
m_raytraceCommonData.rcpFramesDispatched = 1 .f /float (m_framesDispatched);
@@ -1229,12 +1225,10 @@ void Renderer::render(nbl::ITimer* timer)
1229
1225
m_cullPushConstants.currentCommandBufferIx ^= 0x01u ;
1230
1226
1231
1227
// prepare camera data for raytracing
1232
- core::matrix4SIMD inverseMVP;
1233
- modifiedViewProj.getInverseTransform (inverseMVP);
1234
1228
const auto cameraPosition = core::vectorSIMDf ().set (camera->getAbsolutePosition ());
1235
- for ( auto i= 0u ; i< 3u ; i++)
1236
- m_raytraceCommonData.ndcToV . rows [i] = inverseMVP. rows [ 3 ]* cameraPosition[i]-inverseMVP. rows [i] ;
1237
- // m_raytraceCommonData.camPos = ;
1229
+ m_raytraceCommonData. camPos . x = cameraPosition. x ;
1230
+ m_raytraceCommonData.camPos . y = cameraPosition. y ;
1231
+ m_raytraceCommonData.camPos . z = cameraPosition. z ;
1238
1232
}
1239
1233
// path trace
1240
1234
m_raytraceCommonData.depth = 0u ;
0 commit comments