MCPcopy Create free account
hub / github.com/TheRealMJP/BakingLab / RenderDriver

Function RenderDriver

BakingLab/MeshBaker.cpp:1099–1221  ·  view source on GitHub ↗

Runs a single iteration of the ground truth render thread. This function will compute a single radiance for every pixel within a tile, and blend with with the previous result.

Source from the content-addressed store, hash-verified

1097// Runs a single iteration of the ground truth render thread. This function will compute
1098// a single radiance for every pixel within a tile, and blend with with the previous result.
1099static bool RenderDriver(RenderThreadContext& context)
1100{
1101 if(context.CurrNumTiles == 0)
1102 return false;
1103
1104 const uint64 tileIdx = InterlockedIncrement64(context.CurrTile) - 1;
1105 const uint64 passIdx = tileIdx / context.CurrNumTiles;
1106 const uint64 passTileIdx = tileIdx % context.CurrNumTiles;
1107
1108 const uint64 sqrtNumSamples = context.CurrNumSamples;
1109 const uint64 numSamplesPerPixel = sqrtNumSamples * sqrtNumSamples;
1110 if(passIdx >= numSamplesPerPixel)
1111 return false;
1112
1113 const uint64 numPixelsPerTile = TileSize * TileSize;
1114
1115 const Float4x4 viewProjInv = context.ViewProjInv;
1116 const uint64 screenWidth = context.OutputWidth;
1117 const uint64 screenHeight = context.OutputHeight;
1118 const uint64 numTilesX = (screenWidth + (TileSize - 1)) / TileSize;
1119 const uint64 numTilesY = (screenHeight + (TileSize - 1)) / TileSize;
1120 const uint64 tileX = passTileIdx % numTilesX;
1121 const uint64 tileY = passTileIdx / numTilesX;
1122 const uint64 startX = tileX * TileSize;
1123 const uint64 startY = tileY * TileSize;
1124 const uint64 endX = std::min(startX + TileSize, screenWidth);
1125 const uint64 endY = std::min(startY + TileSize, screenHeight);
1126
1127 const Float3x3 cameraRot = context.CameraOrientation.ToFloat3x3();
1128 const Float3 cameraX = cameraRot.Right();
1129 const Float3 cameraY = cameraRot.Up();
1130
1131 const float focusDistance = AppSettings::FocusDistance;
1132 const float apertureSize = AppSettings::ApertureWidth;
1133
1134 const float numSides = float(AppSettings::NumBlades);
1135 const float polyAmt = AppSettings::BokehPolygonAmount;
1136
1137 const uint64 passIdxX = passIdx % sqrtNumSamples;
1138 const uint64 passIdxY = passIdx / sqrtNumSamples;
1139
1140 const bool32 enableDOF = AppSettings::EnableDOF;
1141
1142 const uint64 numThreads = context.Samples->size();
1143 const IntegrationSamples& samples = (*context.Samples)[passTileIdx % numThreads];
1144
1145 const int32 pathLength = AppSettings::EnableIndirectLighting ? AppSettings::MaxRenderPathLength : 2;
1146
1147 uint64 tilePixelIdx = 0;
1148 for(uint64 y = startY; y < endY; ++y)
1149 {
1150 for(uint64 x = startX; x < endX; ++x)
1151 {
1152 const uint64 pixelIdx = (y * screenWidth + x);
1153 IntegrationSampleSet sampleSet;
1154 sampleSet.Init(samples, tilePixelIdx, passIdx);
1155
1156 Float2 pixelSample = sampleSet.Pixel();

Callers 1

RenderThreadFunction · 0.85

Calls 14

Float3Class · 0.85
PathTraceFunction · 0.85
ClampFunction · 0.85
ToFloat3x3Method · 0.80
PixelMethod · 0.80
LensMethod · 0.80
ToFloat4Method · 0.80
TransformClass · 0.50
Float4Class · 0.50
RightMethod · 0.45
UpMethod · 0.45

Tested by

no test coverage detected