Jump to content

Sky with Sun is black


photo

Recommended Posts

Posted

Hi,

 

We have created few worlds in Editor and they render really nice. When we take them in our application; the sun and sky is black. It is also with the samples when we load them in our application. I thought I am missing something so from editor I have saved render.settings and applied them through script.

 

Please find attached simple world. Put it in data folder and its enough.

 

Please check attached image for the issue. Sky is black when sun object is there in the world.

 

 

post-41-0-90027600-1489130392_thumb.png

 

simple.zip

Posted

Hi Rohit,

 

I've opened your simple world and it doesn't look black at all. Am I missing something? 

Thanks!

 

Hi Silent... I have found one probable bug in SDK... 

First of all you are correct.. The simple world is rendering nice in editor.

In our application we have used the Texture Render and Viewport to render engine rendering onto texture. Then we  pass this texture to our application for further processing.

 

Did you check the image above. In editor it is good but in our application the sky is black. LightWorld has one property Scattering type. None, Sun  and Moon. When it is None the same thing I am getting in the application. 

 

What I feel here is the Texture render class or Viewport implementation is missing some passes and that's why scattering and render_haze are only working with disabled settings. Otherwise it is a problem.

 

Due to this we are stuck. Please suggest a way. 15th is our exhibition.

 

Rohit

Posted

Hi Rohit,

 

When you set scattering to None the sky color is taken from the Rendering Settings --> Common --> Background color. Sun disc will be not rendered on sky in that mode.

 

You can replace solid color from the background to the cubemap texture. Just set Rendering Settings -> Environment -> Environment color to white (change the alpha channel value to 255) and assign any cubemap texture you want in to the Texture slot. 

 

In attachment you can found a screenshot with scattering set to none and non-black sky.

 

scattering_none.png

 

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Hi Rohit,

 

When you set scattering to None the sky color is taken from the Rendering Settings --> Common --> Background color. Sun disc will be not rendered on sky in that mode.

 

You can replace solid color from the background to the cubemap texture. Just set Rendering Settings -> Environment -> Environment color to white (change the alpha channel value to 255) and assign any cubemap texture you want in to the Texture slot. 

 

In attachment you can found a screenshot with scattering set to none and non-black sky.

 

attachicon.gifscattering_none.png

 

Hi Silent,

I have done these changes in the world and environment settings.

 

<environment_preset_0_texture_color>1 1 1 1</environment_preset_0_texture_color>

and 

<scattering>0</scattering> for the light world.

 

Then changed the settings and now render.settings have the same like above which I load.

<environment_preset_0_texture_color>1 1 1 1</environment_preset_0_texture_color>

 

Still the problem is same. I think some issue with passes or combining these passes when rendering through texture render and view port.

 

Please guide me what should I do now. 

 

Rohit

Posted

In simple words. Scattering is not functional when we use render to Texture using TextureRender and Viewport.

Without this approach we can not integrate Unigine with our application.

Please suggest a way out...

 

Rohit

Posted

Hi Rohit,

 

What is the texture format that are you rendering to? Is it possible to change it to RGB without alpha and see the difference (maybe the black part is the alpha)? Is there any related code with m_pViewPort and m_pTextureRender declaration?

 

A really small test sample will be very helpful. Right now we can't get 100% reproduction on our side.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

I used RGB8 and RGBA8. Still no Scattering.

 

Here is my code for render to texture.

#include "stdafx.h"

#include "RealiaGraphics\include\UnigineUtils.h"
#include "RealiaGraphics\include\UnigineMathLib.h"
#include "RealiaGraphics\include\Unigine.h"
#include "RealiaGraphics\include\UnigineApp.h"
#include "RealiaGraphics\include\UnigineTexture.h"
#include "RealiaGraphics\include\UnigineTextureRender.h"
#include "RealiaGraphics\include\UnigineRender.h"
#include "RealiaGraphics\include\UnigineImage.h"
#include "RealiaGraphics\include\UniginePlayer.h"
#include "RealiaGraphics\include\UnigineGame.h"
#include <d3d11.h>
#include "RealiaTextureView.h"

using namespace Unigine;

namespace engine3D
{

	RealiaTextureView::RealiaTextureView() 
	{
		m_mat4ModelView.setIdentity();
		
		m_iViewportMask		= 1;
		m_iReflectionMask	= 0;
		m_iUseShadows		= 1;
		m_iUseVisualizer	= 0;
	}

	RealiaTextureView::~RealiaTextureView() 
	{
		Destroy();
	}

	fx::ErrorID RealiaTextureView::CreateView(DWORD _dwWidth, DWORD _dwHeight)
	{
		m_pTextureRender = TextureRender::create();
		m_pTextureRender->create2D(_dwWidth,_dwHeight );
		
		m_pTexture = Texture::create();
		m_pTexture->create2D(_dwWidth,_dwHeight,Texture::FORMAT_RGB8,Texture::USAGE_RENDER ); 

		m_pTextureDS = Texture::create();
		m_pTextureDS->create2D(_dwWidth,_dwHeight,Texture::FORMAT_D24,Texture::USAGE_RENDER ); 

		m_pViewPort = Viewport::create();
		m_pViewPort->setMode(Viewport::MODE_DEFAULT);
		//m_pViewPort->setNodeLightUsage(Viewport::USAGE_WORLD_LIGHT);
		//m_pViewPort->setNodeEnvironmentTextureName("J:\\bin\\TwisterHD\\x64\\Generic\\content\\data\\core\\textures\\common\\environment_default.dds");

		m_pCamera = Camera::create();

		return ERRORTOOLA_FN(fx, eSuccess);
	}

	void RealiaTextureView::Update()
	{

	}

	void RealiaTextureView::Render()
	{
		PlayerPtr playerCam = Game::get()->getPlayer();
		m_pCamera = Camera::create();
		if( playerCam.get() )
		{
			m_pCamera->setModelview(playerCam->getCamera()->getModelview());
			m_pCamera->setProjection(playerCam->getProjection());
	
			if( !m_pTextureRender->isEnabled() )
				m_pTextureRender->enable();
			
			m_pTextureRender->setColorTexture(0, m_pTexture);
	
			m_pViewPort->render(m_pCamera);
			//m_pTextureRender->flush();
			m_pTextureRender->disable();
		}
	}

	
	ID3D11Texture2D* RealiaTextureView::GetD3D11Texture2D()
	{
		void* ptr = m_pTexture->getD3D11Texture();
		return ( (ID3D11Texture2D*) m_pTexture->getD3D11Texture());
	}

	void RealiaTextureView::Destroy()
	{
		m_pTextureRender->destroy();
		m_pTexture->destroy();
		m_pTextureDS->destroy();
	}
}

I have one app created for the whole application to work. The app code is shared on support ticket 000675.

#ifndef __REALIA_TEXTURE_VIEW_H__
#define __REALIA_TEXTURE_VIEW_H__
#include "RealiaGraphics_2.0\sdk\include\UnigineTextures.h"
#include "RealiaGraphics_2.0\sdk\include\UnigineViewport.h"

using namespace Unigine;

namespace engine3D
{

class RealiaTextureView : public IRealiaTextureView
{
private:
	TexturePtr			m_pTexture;
	TexturePtr			m_pTextureDS;
	TextureRenderPtr	        m_pTextureRender;
	ViewportPtr			m_pViewPort;
	CameraPtr			m_pCamera;

	UNIGINE_MAT4 m_mat4ModelView;
	UNIGINE_MAT4 m_mat4projection;
	int m_iViewportMask;
	int m_iReflectionMask;
	int m_iUseShadows;
	int m_iUseVisualizer;

public:
	
	RealiaTextureView();
	virtual ~RealiaTextureView();

	virtual fx::ErrorID CreateView(DWORD _dwWidth, DWORD _dwHeight);
	virtual void Update();
	virtual void Render();
	
	ID3D11Texture2D* GetD3D11Texture2D();
	virtual void Destroy();
};

}

#endif //__REALIA_TEXTURE_VIEW_H__



You can use app code from that ticket. Put this file too. Use this class to render onto texture.

 

later for rendering cycle you may use,

 

m_spHeadlessObject->update(); //app update

m_spRealiaTextureView->Render(); // render to texture
m_spHeadlessObject->swap(); // app swap
 
Then you need to save texture to check the problems or render it to something else.
 
Please see if you can use the code from ticket. 
 
Rohit
Posted

Hi Rohit,

 

As far as we can see, the texture itself is created with sky. In attachment you can find simple test scene that will render single frame to a texture. How to use:

  1. Create new C++ project form SDK browser named sample_sky;
  2. Replace sample_sky.cpp in newly generated project to the attached file;
  3. Open sample_sky.vcxproj in Visual Studio;
  4. In Solution Explorer do a right mouse click on AppSystemLogic.cpp / h and select Exclude from Project;
  5. In Solution Explorer do a right mouse click on AppWorldLogic.cpp / h and select Exclude from Project;
  6. Build and run application;
  7. DDS texture will be saved into <Project>/data/test_sky.dds texture.

Please, make sure that you have environment enabled in your application: render_environment 1. You also can try to change the output format to RGBA16F and upgrade your GPU drivers to the latest.

Unfortunately, without a small test sample with reproduction we can't give you more advises.
 

Thanks!

 

sample_sky.cpp

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Posted

Hi Silent,

 

I have changed my rendering from 

m_context.m_spHeadlessObject->update(); //App Update
m_spRealiaTextureView[_outputUnit]->Render(); //TextureRender Render
m_context.m_spHeadlessObject->swap(); // App Swap

to

m_context.m_spHeadlessObject->update(); //App Update
m_context.m_spHeadlessObject->render(); // App Render == This is so importnat i feel
m_spRealiaTextureView[_outputUnit]->Render(); //TextureRender Render
m_context.m_spHeadlessObject->swap(); // App Swap

Now scattering and render_haze issue mentioned earlier is resolved. I can see sun and scattering. It means.. app->render call is very important as it must be doing some work inside engine and setting up few things. Just using texture render will not have all the effects.

Am I right? 

Posted

Hi Rohit,

 

Glad that you solve this issue! :)

 

App -> render() is required to prepare common resources such as sky LUTs and so on, so it's very important. These resources later are shared between multiple viewports.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

×
×
  • Create New...