179{
180 textureBakerCamera = appState->cameras.main;
181 textureBakerCamera.aspect = 1.0f;
182 textureBakerCamera.position[0] = textureBakerCamera.position[1] = textureBakerCamera.position[2] = 0.0f;
183 textureBakerCamera.position[2] = 1.0f;
184 textureBakerCamera.rotation[0] = textureBakerCamera.rotation[1] = textureBakerCamera.rotation[2] = 0.0f;
185 textureBakerCamera.perspective = false;
186 textureBakerCamera.UpdateCamera();
187
188 float tmp[3];
189
190 if(isPreview)
191 {
192 tmp[0] = tmp[1] = 512.0f;
193 }
194 else
195 {
196 tmp[0] = tileResolution;
197 tmp[1] = tileResolution;
198 }
199
200 tmp[2] = 1.0f;
201
202 Shader* shader = appState->shaders.terrain;
203 shader->Bind();
204 shader->SetMPV(textureBakerCamera.pv);
205 shader->SetUniformMat4("_Model", appState->models.coreTerrain->modelMatrix);
206 shader->SetLightCol(appState->lightManager->color);
207 shader->SetLightPos(appState->lightManager->position);
208 shader->SetUniform3f("_Resolution", tmp);
209 shader->SetUniform3f("_CameraPos", appState->cameras.main.position);
210 shader->SetUniform3f("_HMapMinMax", heightMapMinMax);
211 shader->SetUniformf("_SeaLevel", appState->seaManager->level);
212 shader->SetUniformf("_Scale", appState->globals.scale);
213 shader->SetUniformf("_TextureBake", 1.0f);
214 shader->SetUniformf("_CameraNear", appState->cameras.main.cNear);
215 shader->SetUniformf("_CameraFar", appState->cameras.main.cFar);
216 shader->SetUniformf("_Slot", static_cast<float>(currentTextureSlot));
217 shader->SetUniformf("_Tiled", useTiledExport ? 1.0f : 0.0f);
218 shader->SetUniformf("_NumTiles", static_cast<float>(tileCount));
219 shader->SetUniformf("_TileX", static_cast<float>(-1 * tileX));
220 shader->SetUniformf("_TileY", static_cast<float>(-1 * tileY));
221 appState->shadingManager->UpdateShaders();
222 appState->models.coreTerrain->Render();
223}