Problems with XEffects and DirectX 9

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Problems with XEffects and DirectX 9

Post by aheymann »

Hallo

I have tried using the xeffects package to add shadowing to my scene and it won't work with DirectX 9. When using OpenGL it works fine. I am currently using Irrlicht 1.4.2. The problem seems to be the creation of the shadowmap texture :

ShadowMapTex = driver->createRenderTargetTexture(mapSize);

I am in a windowed application and when calling

driver->OnResize(Size);


it fails resetting the DirectX device.

What do I need to do to get this working?

Regards

Anton Heymann
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

What size are you trying to create the render target as? (if you have control over that)
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The size doesn't matter here, D3D devices always fail once an RTT is created. I hope to get this fixed for Irrlicht 1.5.
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Post by aheymann »

I have downloaded the latest SVN trunk for 1.5 and I am now trying to convert my code to use it. Getting lots of problems :

Maybe you can help here. In 1.4.2 'mode' I need to traverse the children of a lightscenenode with billboards attached. I use the following code snippet :

Code: Select all

   core::list<ISceneNode *>::ConstIterator it;
   vector3df pos = pCamera->getPosition();
   ILightSceneNode     *pLight;
   IBillboardSceneNode *pNode;
   
   LookAt->setSize(Size * LookAt->getPosition().getDistanceFrom(pos) * A1_SIZE);
   Size.set(35,35);
   for (Pos = m_Lights.GetHeadPosition(); Pos;) 
      {
      Light = (LIGHTSOURCEPTR) m_Lights.GetNext(Pos);
      pLight = Light->pIRRLight;
      
      it = pLight->getChildren().begin();
      if (*it)
         {
         pNode = (IBillboardSceneNode *) (*it);
         pNode->setSize(Size * pLight->getPosition().getDistanceFrom(pos) * A1_SIZE);
         }
      }      
This works fine. In 1.5. trunk I cannot convert (*it) to a IBillboardSceneNode) - how do I access the members of *it?

Thanks

Anton
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You shouldn't use a ConstIterator, because you want to alter the elements pointed to by the iterator. Or you have to use a const cast to cast away the const. Other than that I wouldn't expect any problems here. What's the actual error message?
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Post by aheymann »

I have managed to recompile a version based on current trunk. The SDK version is still set to 1.4.2 (which had me confused for a while). Running my sample app, with the 1.5. version, still made no difference. Using Blindsides effect wrapper, I still get problems when a resize is called :

Reset of device failed.

I am using the following code to start blindside's effectwrapper

Code: Select all

dimension2d<s32> shadowDimen = dimension2d<s32>(512,512);
			E_FILTER_TYPE filterType = EFT_4PCF;

			dimension2d<s32> ScreenRTT = dimension2d<s32>(512,512);
			
			effects = new effectHandler(pDevice,shadowDimen,(stringc) (LPCTSTR) MediaFolder,ScreenRTT);
In the code, the line


Code: Select all

ShadowMapTex = driver->createRenderTargetTexture(mapSize);
is where the problem is. Any advice on this will REALLY be appreciated.

Thanks

Anton[/url]
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, the problem is not yet fixed, I hope to get it fixed before the release is out. No more.
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Post by aheymann »

Is there not anything I can do? Other people seem to have this resolved with additional patches. Any help/advice will be appreciated. 1.5. looks great - static VBO's are fantastic!

Anton
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I was pretty confused about the "invalid command" return value which is delivered by reset() in the d3d drivers. But I guess it should work if you just release all RTT HW textures (not dropping them, but only releasing the d3d specific surfaces). Then reset and reallocate the surfaces. At least that's my plan (in order to avoid pointer corruption in materials etc).
If someone could implement this it would make things much faster, I can only finish it end of october or even later.
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Post by aheymann »

Hybrid

Sorry, can you be more specific. Is there anything I can do with 1.5. trunk as it is to overcome this problem. I really want to use DirectX as the speed does seem to be better than OpenGL and there are problems with lights is OpenGL as well. As I said, there appears to be patches going around, which does fix the problems. I took the OnResize out and of course it now works, but the resolution is very poor.

Thanks

Anton
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, there are no patches. You can simply drop the textures and remove it from texture cache, then reset. Make sure that all materials using the RTT will afterwards use the newly created RTT instead of the old, deleted pointer. But that's a purely application based solution, so a version integrated into the engine needs to do this stuff a little different...
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Post by aheymann »

Sorry for being thick here. I am happy with an app specific fix, as that gets me going. So, what your are saying, is if drop the created Texture (in this case ShadowMapTex), reset and then recreate it, it should work :)

Thanks

Anton[/url]
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, you have to drop it and remove the texture from texture cache as well. Otherwise the texture is not deleted properly, as the reference keeps the destructor from being called.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I think I can provide a work around in the wrapper. Yoran has already figured something out, so I'll try and incorporate his ideas in the next release. Basically it just checks if beginScene fails and recreates the rendertargets if thats so.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
aheymann
Posts: 153
Joined: Wed Aug 22, 2007 12:25 pm
Location: England

Post by aheymann »

Blindside. Do you mind sharing that information now. I am desperately trying to add shadows into my scene in DX mode.

Hybvrid - how do I delete a texture from the cache (how do I access the texture cache?). I used removeTexture, which the documentation says does delete the texture from the cache as well. Still no luck with the OnResize (reset) in DX mode.

I also called removeAllTextures() before the resize and the reset still failed :

Resetting D3D9 device.
Resetting failed due to invalid call.


Anton
Post Reply