shadows makes Mogre to CRASH

marc_antoine

23-01-2007 21:20:15

alright after a while seems i aisle the problem, that for instance i thought it was from directinput, but no, the problem is that when i select a shadow technique different to none or stencil additive, my application crashes with the following message:


"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."


why's that?... here are the setting i was using at the moment to the crash...:


mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC);
cam = mgr.CreateCamera("Camera");
cam.AutoAspectRatio = true;
cam.NearClipDistance = 5;
mRoot.AutoCreatedWindow.AddViewport(cam);
//input = new MyInput(hwnd, cam,mRoot);
//mWindow.AddViewport(cam);

//////////////////////////////////////////////////////////////////////
//Establecemos el color de la luz mbiental
mgr.AmbientLight = new ColourValue(1, 1, 1);
//Establecemos el tipo de sombra
mgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE;
//Establecemos la imagen del cielo
mgr.SetSkyBox(true, "Examples/SpaceSkyBox");



so i started to play with the shadow technique and the scene type, to see what combination works better but the scne type has nothing to do with the problem but the shadow technique does, since only the stencil_additive works fine, or setting the technique to NONE, the other shadow options doesn't work at all since when i use them no scene is rendered only the skybox. :S

so anyone knows a solution to this or i have to do something in my code?.. it is a bug?


thanks in advance...

smernesto

23-01-2007 21:53:42

I tried to reproduce your problem but in my code works well.

Bekas

23-01-2007 22:24:42

Are you using your own model or does the crash occur with any model ?

Use the debug version, enable "unmanaged debugging" for visual studio, and post the file/line where the crash occurs (you may need to get the source files so that you can open up the file).

I assume this is with the latest Mogre 0.1.9, right ?

marc_antoine

24-01-2007 01:43:23

nope it is with version 8... i'm loading my own model exported with oFusion from 3dsMax 8, everything is fine except for a billboard whose texture seems not to be loaded.. from that apart everything is ok with the model. i'll try new version 9 of Mogre the exact plce where the error is thrown is when the startrendering() is called i believe every ended frame..

void StartRenderLoop()
{
mRoot.StartRendering();
}

the funny thing is that happens when i use shadows.

Bekas

24-01-2007 01:55:56

If the problem persists with the 0.1.9 version, there's a good chance there's a problem with the model. Can you upload it somewhere so that I can test it out?

marc_antoine

24-01-2007 02:25:18

the model name is meshlv.osm and can be downloaded from :


ok still loading, but i just installed the 1.9 v of Mogre, rebuilded the project and i got the following error:


System.IO.FileLoadException was unhandled
Message="Could not load file or assembly 'Mogre, Version=0.1.9.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. No se pudo iniciar la aplicación porque su configuración es incorrecta. Reinstalar la aplicación puede solucionar el problema. (Exception from HRESULT: 0x800736B1)"
Source="MOGRELV_v1"
FileName="Mogre, Version=0.1.9.0, Culture=neutral, PublicKeyToken=null"
FusionLog=""
StackTrace:
at MOGRELV_v1.Program.Main()
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


seems im going from bad to worst :S

marc_antoine

24-01-2007 02:37:05

here is the file


http://www.filecrunch.com/file/~56gfr4


i builded the Mogre Samples but the same error shows.. i also replaced the older dll's (v1.8) ...so still can't make the new version of Mogre work :(

smernesto

24-01-2007 02:47:22

@marc_antoine for the problem with 0.1.9 you have,

System.IO.FileLoadException was unhandled
Message="Could not load file or assembly 'Mogre ...


please read this topic http://www.ogre3d.org/phpBB2addons/view ... 9135#19135 I think you have a similar problem.

Entering Spanish Mode.
Mira si estas usando las referencias adecuadas si usas referencia a debug mogre usa esos .dll y si referencias a los release dlls entonces usa esos.

smernesto

24-01-2007 02:57:57

Ahh I forgot.

I think the OSM loader in the Wiki has a bug in configuring the shadows I dont remember well but I had some problems with it. I don´t know if it is related with your problem.

I port the July 28 C++ OSM loader to C# becuase The Mogre OSM Loader in the wiki and forums is based in the OgreDotNet OSM Loader that has bugs and It is based in the june C++ OSM Loader but in July OFusion release another Loader.

I have to clean some comments in the code but I think the code load .osm files better than the old loader. And with the new Archive class in mogre 0.1.9 the loader is complete.

If you want I can give you the code of the OSM loader and help me to test it for put it later in the Wiki.

marc_antoine

24-01-2007 03:06:48

yes that would helpful (gracias ernesto, espero sea con el cargador de modelos el problema ) by the way i know i have to use dll's that correspond to the kind of biuld you are doing (debug or Release o wrote a small tutorial int he ogredotnet forum since in ogredotnet u have to compile the dll's . it is odd that smples doesn't work too.


spanish mode.. (hehe)

claro que si!! seria de mucha ayuda y de paso ahber si es eso el problema con las sombras.

se lo del detalle con respecto al tipo de librerias a utilizar, ya que cuando usas ogredotnet tienes que recompilar el fuente para obtener las librerias que se usan con c# .net o el c# de Mono (linux). solo que parece que algo estoy pasando por alto. ademas es extraño que los ejemplos no funcionen tampoco. voy a seguir tratando.

smernesto

24-01-2007 03:44:57

@marc_antoine

Well I downloaded your scene and loaded with an application I wrote for playing with oFusion. I didn´t get any exception but with the old OSM loader I didn´t see shadows with my loader I saw shadows in your scene.

But you have to change this line in your .osm file <lightColor r="0" g="0" b="0" /> you have to turn off ambient light and you will see shadows, in my osm loader it works fine, I will send you the code and maybe in a couple of days I can upload it to the wiki.

Another thing is that the .osm file actually have the type of shadows it will use <shadowTechnique type="17" tex_size="512" tex_count="1">.
You don´t have to set the shadow technique if you don´t want.

marc_antoine

24-01-2007 03:53:13

well i set a shadow technique becouse no shadow was appearing in the scene... when the model is loaded. also guess what i can't make the new version of Mogre work ,,, i just don't know why..

smernesto

24-01-2007 06:37:42

@marc_antoine I wrote you a Private message please read it.

marc_antoine

24-01-2007 16:10:05

yes already saw it ernesto :) thanks i will test it today and i'll tell you what happens, it was late yesterday that's why i didn't tested it, but i will as soon i get back from work.

marc_antoine

24-01-2007 20:41:50

making some tests with different setting in my app code and the OSM file code this is what i got:


using a shadow technique (code)

mgr.AmbientLight = new ColourValue(1, 1, 1);
//Establecemos el tipo de sombra
mgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE;
//Establecemos la imagen del cielo
mgr.SetSkyBox(true, "Examples/SpaceSkyBox");




and lights (OSM file)
<oe_scene>
<sceneManager type="1" />
<bkgcolor r="0" g="0" b="0" />
<lightColor r="1" g="1" b="1" />
<shadowTechnique type="17" tex_size="512" tex_count="1">
<color r="0" g="0" b="0" />
</shadowTechnique>
<skyTechnique type="2" material="_SkyMaterial/SkyBox" drawFirst="yes" tiling="10" scale="2000" dist="5000" bow="0" xSegments="16" ySegments="16" />
<entities>


i got this scene which produces a memory error in the rendering loop :
http://www.filecrunch.com/file/~2yjokw



--------------------------------------------------------------------------------
then using your sets (no light, no shadow technique)


app code

mgr.AmbientLight = new ColourValue(1, 1, 1);
//Establecemos el tipo de sombra
//mgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE;
//Establecemos la imagen del cielo
mgr.SetSkyBox(true, "Examples/SpaceSkyBox");




OSM file code
<sceneManager type="1" />
<bkgcolor r="0" g="0" b="0" />
<lightColor r="0" g="0" b="0" />
<shadowTechnique type="17" tex_size="512" tex_count="1">
<color r="0" g="0" b="0" />
</shadowTechnique>
<skyTechnique type="2" material="_SkyMaterial/SkyBox" drawFirst="yes" tiling="10" scale="2000" dist="5000" bow="0" xSegments="16" ySegments="16" />
<entities>



and i got this:

http://www.filecrunch.com/file/~mxqg4z


------------------------------------------------------------------------------------

finally i set it with shadow technique and no lights... and it crashes really fast, faster than with the first try (lights, and shadow techinique)


app code

mgr.AmbientLight = new ColourValue(1, 1, 1);
//Establecemos el tipo de sombra
mgr.ShadowTechnique = ShadowTechnique.SHADOWTYPE_STENCIL_MODULATIVE;
//Establecemos la imagen del cielo
mgr.SetSkyBox(true, "Examples/SpaceSkyBox");




OSM file CODE
<sceneManager type="1" />
<bkgcolor r="0" g="0" b="0" />
<lightColor r="0" g="0" b="0" />
<shadowTechnique type="17" tex_size="512" tex_count="1">
<color r="0" g="0" b="0" />
</shadowTechnique>
<skyTechnique type="2" material="_SkyMaterial/SkyBox" drawFirst="yes" tiling="10" scale="2000" dist="5000" bow="0" xSegments="16" ySegments="16" />
<entities>


this si the result that crashes fast.

http://www.filecrunch.com/file/~0qmxio

smernesto

24-01-2007 22:50:58

I tried again your scene with Mogre 0.1.8 and 0.1.9 and the application crash with SHADOWTYPE_STENCIL_MODULATIVE, but it crash in some parts of the scene.

With the DirectX9 plugin:

System.AccessViolationException: Intento de leer o escribir en la memoria protegida. A menudo, esto indica que hay otra memoria dañada.
en Ogre.Root.startRendering(Root* )
en Mogre.Root.StartRendering() en e:\projects\mogre\trunk\mogre\mogre\src\auto\mogreroot.cpp:línea 209
en Mogre.Demo.MogreForm.MogreForm.MogreForm_Load(Object sender, EventArgs e) en C:\OgreSDK\MogreForm\MogreForm.cs:línea 144
en System.Windows.Forms.Form.OnLoad(EventArgs e)
......
......


With the openGL plugin

Assertion failed!
Program:
File: e: projec ogre\trunkpiogrepg. ‘gresh. .ter.cpp
Line: 206
Expression: indexStart <= indexBuffer->getNumlndexes() && Index buffer overrun while generating shadow volume!’ You must increase the size of the shadow index buffer.
For informationon how your program can cause an assertion
failure, see the Visual C++ documentabon on asserts
(Press Retry to debug the application - JIT must be enabled)


Bekas can you compress and send me the .pdb files for the others .dll files of Mogre, OgreMain_d.pdb and OgrePlatform_d.pdb please.

Bekas

24-01-2007 23:44:06

OgreMain_d.pdb is in the "C:\OgreSDK\lib" folder, if you need OgrePlatform_d.pdb too let me know.

smernesto

25-01-2007 02:38:58

Yes Bekas I need OgreMain_d.pdb and OgrePlatform_d.pdb also.
I downloaded the source code of mogre, but I dont have the DX SDK now, I need it to compile?,

Well, but if you can give me the pdb files better :D

Thanks.

marc_antoine

25-01-2007 02:39:20

what is that pdb for?...

smernesto

25-01-2007 03:35:39

@marc_antoine

Well your scene crash in ogreMain.dll then I need the pdb that contains many debug information to know where in the code is the problem but the crash is in the ogre code Visual Studio debugger use the file to find where is the exception throw in the code.

If you see I posted 2 errors, one with d3d and another with openGl , the opengl error has good information but I don´t know much about shadows, maybe another person knows what is that error.

Bekas

25-01-2007 11:54:04

@smernesto: The pdb is here
You need the DirectX SDK to compile Ogre.

@marc_antoine: Read this

I suggest posting to the main Ogre forums, telling that you your model causes an assertion when stencil shadows are enabled:
Assertion failed!
Program:
File: e: projec ogre\trunkpiogrepg. ‘gresh. .ter.cpp
Line: 206
Expression: indexStart <= indexBuffer->getNumlndexes() && Index buffer overrun while generating shadow volume!’ You must increase the size of the shadow index buffer.

and asking for directions.

Don't mention that you use Mogre so that your post doesn't get locked down.

smernesto

25-01-2007 17:02:42

Thanks Bekas for the file,

I tried it but Visual Studio wants: e:\Projects\Mogre\trunk\Mogre\ogrenew\OgreMain\lib\Debug\OgreMain_d.pdb
Well I think is the path in your PC but the file is OgreMain_d.pdb, and I will can debug the scene with shadow problems.


Thanks

Bekas

25-01-2007 18:43:07

I tried it but Visual Studio wants: e:\Projects\Mogre\trunk\Mogre\ogrenew\OgreMain\lib\Debug\OgreMain_d.pdb
Did you copy OgreMain_d.pdb to the same folder as OgreMain_d.dll ?

smernesto

25-01-2007 20:18:45

Bekas, I don´t have OgreMain_d.pdb, the file that you upload was PlatformManager_Win32.pdb.

Bekas

25-01-2007 20:51:11

OgreMain_d.pdb is in the "C:\OgreSDK\lib" folder

smernesto

25-01-2007 21:53:42

Ouch, Sorry for the mistake I think I didn´t read well sorry.

smernesto

25-01-2007 22:35:13

@marc_antoine
The problem happens when you want to see only a part of the scene, but with others parts of the scene the app don´t crash.

I didn´t set the shadows manually, the OSM loader do it for me. With both the new and the old loader is the same crash, then I think is not problem with the OSM loader.

Well I used the debugger and the error ends in ogreshadowcaster.cpp in line 140.


*pIdx++ = darkCapStart;
Line 140 *pIdx++ = v1 + originalVertexCount;
*pIdx++ = v0 + originalVertexCount;


The debugger says the pIdx pointer is erroneous.
I don´t know what is the solution. Post all this info in the main forum how says bekas, and give them your scene maybe they can help you.

Beauty

18-02-2009 13:29:43

I also recognized this problem now.
Generally I can enable shadows in my application and it works.
But now it crashes when a special object (mesh) is in camera view.
Not at all, but if I move the cam along the object, I don't have to wait long ... AccessVialationException by calling root.RenderOneFrame();

It is reproducible. When I load my default scene (where the cam views to the object) and I enable SHADOWTYPE_STENCIL_MODULATIVE then it always crashes.

In the ogre.log is no error.
After enable and crash there is this entry:
14:11:04: Texture: spot_shadow_fade.png: Loading 1 faces(PF_R8G8B8,128x128x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
14:11:07: *-*-* OGRE Shutdown


The file spot_shadow_fade.png is not in my ressources (also not in packs).
Maybe this could be a reason?
But while there is no crash, I can see a shadow (with hard border).

Does somebody has an idea what could be the problem?

P.S.
I use Mogre.dll 0.2.2.0 with DirectX

marc_antoine

18-02-2009 15:11:42

hi beauty, i never got a solution for this, anyway i ended using the c++ version now, the 1.6.0

Maybe it is a problem in the .net wrapper+ Ofusion+3dsMax i can't tell, hope someone else kows a solution for this or a workaround, maybe try baking the textures so the light (and shadows) are embeded in the texture and only enable shadows to certain objects.

Beauty

18-02-2009 15:26:43

Thanks.
It's good, that I don't need shadows in my scientific application. But it's not nice if somebody enables the shadow option and sometime later there is a crash (where you don't associate with the shadow option). Maybe I should deactivate the checkbox for shadows.

I made a test with other shadow types:
SHADOWTYPE_STENCIL_ADDITIVE ... crashes
SHADOWTYPE_TEXTURE_ADDITIVE and SHADOWTYPE_TEXTURE_MODULATIVE ... no crash, no shadows

Beauty

26-12-2010 13:40:08

In the topic of the main forum I got an answer, which could help.
Please try it and give feedback if this solves the problem.

Have you tried setting your shadow buffer to a higher value with SceneManager::setShadowIndexBufferSize? I think you usually get an error specific to that problem but worth throwing it out there since that's the one place that shadows have broken for me so far.

Also you can follow these posts - maybe there are useful answers:
viewtopic.php?p=77658#p77658
http://www.ogre3d.org/forums/viewtopic. ... 23#p413523

CodeKrash

02-02-2011 22:53:49

I noticed that shadows break skyx, the wrapper author basically told me to not use em because they're old :(