Rogy-Engine- icon indicating copy to clipboard operation
Rogy-Engine- copied to clipboard

When I change a different HDR, the engine cannot render

Open Ahaenhhhh opened this issue 3 years ago • 4 comments

When I change a different HDR, the engine cannot render.

Ahaenhhhh avatar Mar 04 '22 06:03 Ahaenhhhh

Do you mean different ToneMapping? what happens?

RogyDev avatar Mar 04 '22 21:03 RogyDev

image When I change a path,it will show this image don't render

Ahaenhhhh avatar Mar 05 '22 01:03 Ahaenhhhh

Here is a quick workaround: (I'm adding and fixing stuff and I will update the source code when I finish; thanks for reporting this bug:)) in the renderer.cpp, change the SetEnv_SkyCapture function:

void Renderer::SetEnv_SkyCapture(std::string path)
{
	if (SkyPath == path) 
		return;

	ibl.Init(); // ADD THIS
	SkyPath = path;
	ibl.DeleteCapture(m_SkyCapture);
	glDeleteTextures(1, &envCubemap);
        ibl.LoadHDR(SkyPath.c_str(), envCubemap );
	ibl.CreateCapture(envCubemap, m_SkyCapture);
}
// ----------

And we don't want to load the shaders again so in IBL::Init function you add:

void IBL::Init()
{
	// pbr: Load baking shaders (independent from MaterialLibrary)
	// ---------------------------------------------
	if (!shadersLoaded) // this
	{
		equirectangularToCubemapShader.loadShader("core/shaders/iblBaking/E2Cubemap.rsh");
		irradianceShader.loadShader("core/shaders/iblBaking/irradiance.rsh");
		prefilterShader.loadShader("core/shaders/iblBaking/prefilter.rsh");
		shadersLoaded = true; // and this
	}
        .......
}

Also define shadersLoaded in the IBL class as a boolean:

class IBL
{
public:
	IBL();
	~IBL();
         .........
private:
	bool shadersLoaded = false; // THIS
};

RogyDev avatar Mar 05 '22 14:03 RogyDev

It's ready to run

Ahaenhhhh avatar Mar 06 '22 09:03 Ahaenhhhh