Skybox upside down [2.1]

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 151
Contact:

Skybox upside down [2.1]

Post by spookyboo »

I've made a skybox from a cubemap and a cube.mesh. The problem is that the cubemap is projected nicely inside my cube.mesh, but it is upside down. I don't want to modify the Ogre code and I don't want to flip the texture file itself, so I ended up with editting my cube.mesh (or at least the xml). I tried flipping the normals and the vertices (multiply them with -1) ect. but the cubemap stays either upside down or is completely deformed. Any suggestions? (I also tried adding a new workspace, but it keeps crashing so this approach looked like a good alternative).
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Skybox upside down [2.1]

Post by dark_sylinc »

Picture?

Is this on both GL & D3D11? Are you using PBSM_REFLECTION? Did you render the cubemap yourself?
User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 151
Contact:

Re: Skybox upside down [2.1]

Post by spookyboo »

Image
I am using a simple datablock with PBSM_REFLECTION applied to a cube.mesh (large scale; in the picture you are looking inside the cube). On the outside of the cube, the cubemap is upright (the same as the sphere).
This is with D3D11 and GL (I had to enable two sided lighting in case of GL. This was not needed for D3D11)
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Skybox upside down [2.1]

Post by dark_sylinc »

I cannot reproduce in the 2.1-pso branch (it will soon merge with 2.1). Haven't tested in 2.1.

However it's also that you're rendering the sky like we do in SkyPostprocess. We've discovered there was a bug there. To correct it you need to flip the Z coordinate before sampling the cubemap.
User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 151
Contact:

Re: Skybox upside down [2.1]

Post by spookyboo »

Ok. I'm reverting to the TutorialSky_PostprocessWorkspace approach again (so, without the cube.mesh). The skybox renders perfect in GL, but I get an exception with D3D11.

Code: Select all

D3D11 ERROR: ID3D11DeviceContext::Draw: The Shader Resource View dimension declared in the shader code (TEXTURECUBE) does not match the view type bound to slot 0 of the Pixel Shader unit (TEXTURE2D).  This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #354: DEVICE_DRAW_VIEW_DIMENSION_MISMATCH]
This exception occurs both with my own application but also with the TutorialSky_PostprocessWorkspace example (and only D3D11. TutorialSky_PostprocessWorkspace works fine with GL). Anyone else has the same experience? I will rebuild everything from scratch again, just in case
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Skybox upside down [2.1]

Post by dark_sylinc »

Nope, it's working fine here (except D3D11 loads texture without gamma correction, which is a bug).

Maybe your repository has some changes or an extra file overriding a material or shader?
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51
Contact:

Re: Skybox upside down [2.1]

Post by SolarPortal »

the only thing i get with the Skybox Post FX Sample in D3D11 is a black sky and no texture shows on any 2-1 branch.
Only the OpenGL3+ works for me :) Hope this helps :)
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Skybox upside down [2.1]

Post by dark_sylinc »

Let me guess... you both have NVIDIA cards? (The sample works fine on Intel and AMD cards.)
User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 151
Contact:

Re: Skybox upside down [2.1]

Post by spookyboo »

Yes. I have NVidia.
Just updated to the latest branch and did a clean install. Sample_TutorialSky_Postprocess.exe crashed again with D3D11 (same exception).
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Skybox upside down [2.1]

Post by dark_sylinc »

Mmmm.... perhaps the cube texture is not correctly loaded as such; maybe even a branch based on some D3D11 report. More research would be needed.

Try checking what happens inside void D3D11Texture::_create2DResourceView(). It should follow a cubemap path.

Can you send a RenderDoc capture? (it shouldn't crash because RenderDoc will force-ignore the error)
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: Skybox upside down [2.1]

Post by al2950 »

I have been away from a computer for a little while so can't check code but could this be anything to-do with a bug I found a while ago and completely forgot about? :oops:
http://ogre3d.org/forums/viewtopic.php? ... 4a#p524851
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Skybox upside down [2.1]

Post by dark_sylinc »

That does sound like the problem. Does that fix it for you SolarPortal & spookeyboo?
User avatar
SolarPortal
OGRE Contributor
OGRE Contributor
Posts: 203
Joined: Sat Jul 16, 2011 8:29 pm
Location: UK
x 51
Contact:

Re: Skybox upside down [2.1]

Post by SolarPortal »

surprisingly, it has fixed the demo in ogre3d source for me now, but it didn't back then on those posts when i tried... but like i said then, i could have easily made a mistake especially if it was late night hehe :P
Perhaps its all the updates/changes to the ogre engine lol :P Thanks again... just have to get that sky working in our engine on DX11 now which sets cubic textures to the material manually from code to change skybox on the fly :)

Edit: The skybox is still black if i set the cubictexture to the material in c++ either as a cubemap texture or 6 individual textures and OpenGL does not chagne the textures now with this code . OpenGL did before because i used a blitting method which crashed in DX11 so had to change to this code:

Code: Select all

	
	Ogre::RenderSystem *renderSystem = Ogre::Root::getSingletonPtr()->getRenderSystem();
	//Ogre::String shaderSyntax = "GLSL";
	//if (renderSystem->getName() == "Direct3D11 Rendering Subsystem") { return; }

	Ogre::String skyMatFile = skyBoxMaterial;//+".material";

	Ogre::CompositorNodeDef *nodeDef;
	Ogre::CompositorManager2 *compositorManager = Ogre::Root::getSingleton().getCompositorManager2();
	nodeDef = compositorManager->getNodeDefinitionNonConst("AurasoftUK_StartingNode");

	if (!state){
		// Disable Skybox -- todo <<<
		return;
	}

	std::string filePath = skyResource.getV1MaterialResourceFilePath(skyMatFile);

	if (filePath != ""){
		QFileInfo fi(filePath.c_str());

		std::string path = fi.absolutePath().toStdString();
		std::string baseName = fi.baseName().toStdString();

		SkyMaterial2::StoreData data = skyResource.getMaterialDataFromFile(filePath, baseName, "Scene", "");

		if (data.convertRequired){
			if (data.isUsed && data.isCubic){
				Ogre::MaterialPtr baseSkyMat = Ogre::MaterialManager::getSingleton().getByName("SkyPostprocess");
				if (baseSkyMat.isNull()) return;

				if (data.isSeperate){
					Ogre::String mReflectTexNames[6];

					for (int i = 0; i < 6; i++){
						skyResource.loadTextureResource(data.diffuseTetxureNames[i], false, "General");					
						mReflectTexNames[i] = data.diffuseTetxureNames[i];
					}

					baseSkyMat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setCubicTextureName(mReflectTexNames);
				}else{
					skyResource.loadCubicTextureResource(data.diffuseTetxureName, "General");
					baseSkyMat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setCubicTextureName(data.diffuseTetxureName);
				}

				assert(nodeDef->getNumTargetPasses() >= 1);
				Ogre::CompositorTargetDef *targetDef = nodeDef->getTargetPass(0);
				const Ogre::CompositorPassDefVec &passDefs = targetDef->getCompositorPasses();
				assert(passDefs.size() >= 1);
				Ogre::CompositorPassDef *passDef = passDefs[1];
				if (passDef->getType() != Ogre::PASS_QUAD && dynamic_cast<Ogre::CompositorPassQuadDef*>(passDef));
				Ogre::CompositorPassQuadDef *quadDef = static_cast<Ogre::CompositorPassQuadDef*>(passDef);
				quadDef->mMaterialName = "SkyPostprocess";
			}
			else{
				lprint("Error: Only Cubmap or 6 frame textures can be used to create a material.");
			}
		}
		else{
			//2-1UPGRADEREQUIRED -- | How to apply Material files that are correct and "not" HLMS!
			// Edit: It is the old way of material loading that is required, but how to tell if it is correct and intact.
			return;

			assert(nodeDef->getNumTargetPasses() >= 1);
			Ogre::CompositorTargetDef *targetDef = nodeDef->getTargetPass(0);
			const Ogre::CompositorPassDefVec &passDefs = targetDef->getCompositorPasses();
			assert(passDefs.size() >= 1);
			Ogre::CompositorPassDef *passDef = passDefs[1];
			assert(passDef->getType() == Ogre::PASS_QUAD && dynamic_cast<Ogre::CompositorPassQuadDef*>(passDef));
			Ogre::CompositorPassQuadDef *quadDef = static_cast<Ogre::CompositorPassQuadDef*>(passDef);
			quadDef->mMaterialName = skyMatFile;
		}

	}
Edit2: The code does appear to change if a single cubemap image is loaded for the sky in OpenGl contrary to what i said before, but not for individual frames. :)
Please Note: that some code is specific to our engine for grabbing resources through our own resource system. Saying this though, the textures are fully loaded and in ogre at time of setting material texture.

Also, the other error i get, is when changing some reflection textures in Datablocks. The sky post processor material also changes to the Datablock Reflection Cubemap image, which doesn't really help lol :P
Again, DX11 just stays black in the sky with this error also. :) Hope this helps :D
Lead developer of the Skyline Game Engine: https://aurasoft-skyline.co.uk
User avatar
spookyboo
Silver Sponsor
Silver Sponsor
Posts: 1141
Joined: Tue Jul 06, 2004 5:57 am
x 151
Contact:

Re: Skybox upside down [2.1]

Post by spookyboo »

Changing the material into "texture SaintPetersBasilica.dds cubic gamma" did the trick. Sometimes things can be easily solved :D
Both GL and D3D11 work now.
Thanks
Post Reply