Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 Texture on a 3d Object
  Posted by: ToastbrotX
  When: 10/09/2010 at 10:23:08

 Unable to Build
  Posted by: Rich_Zap
  When: 09/09/2010 at 15:39:33

 HLSL calculating normals
  Posted by: Rich_Zap
  When: 09/09/2010 at 15:34:56

 Texture on a 3d Object
  Posted by: ToastbrotX
  When: 09/09/2010 at 11:14:19

 DRIVER ERROR XBOX 360
  Posted by: Anonymous
  When: 09/09/2010 at 01:12:47

 Reflection problem in corners ...
  Posted by: Anonymous
  When: 08/09/2010 at 21:03:35

 Texture on a 3d Object
  Posted by: radulph
  When: 08/09/2010 at 17:34:01

 InvalidDataException???
  Posted by: Anonymous
  When: 08/09/2010 at 09:10:36

 Unable to Build
  Posted by: Anonymous
  When: 08/09/2010 at 07:49:36

 Suggestion to change a few lines
  Posted by: Insomnica
  When: 06/09/2010 at 14:37:05

 Collision with series 1
  Posted by: radulph
  When: 05/09/2010 at 13:33:14

 HLSL calculating normals
  Posted by: miroslavign
  When: 04/09/2010 at 17:26:26

 Collision with series 1
  Posted by: ToastbrotX
  When: 04/09/2010 at 16:52:02

 HLSL calculating normals
  Posted by: Rich_Zap
  When: 04/09/2010 at 15:00:20

 Collision with series 1
  Posted by: ToastbrotX
  When: 04/09/2010 at 12:28:41

 HLSL calculating normals
  Posted by: miroslavign
  When: 04/09/2010 at 08:46:31

 Walk along a wall
  Posted by: Anonymous
  When: 03/09/2010 at 10:28:02

 model problems
  Posted by: muffinman
  When: 03/09/2010 at 06:47:32

 Vertices problem
  Posted by: Anonymous
  When: 03/09/2010 at 05:48:35

 OcTree Question
  Posted by: Zorzomezz
  When: 03/09/2010 at 04:07:03




Topic: Big Problem model showing only in black



  
Goto parent category
  
Create a new user account


   Big Problem model showing only in black
 Poster : Apples
 Posts: 5
 Country : usa
 City:

  
Posted by Apples on 12/02/2009 at 15:06:19

foreach (Effect currentEffect in mesh.Effects)
                {
                    
                    currentEffect.CurrentTechnique = currentEffect.Techniques["Colored"];
                    currentEffect.Parameters["xWorld"].SetValue(xwingTransforms[mesh.ParentBone.Index] * worldMatrix);
                    currentEffect.Parameters["xView"].SetValue(viewMatrix);
                    currentEffect.Parameters["xProjection"].SetValue(projectionMatrix);
                    currentEffect.Parameters["xEnableLighting"].SetValue(true);
                    currentEffect.Parameters["xLightDirection"].SetValue(lightDirection);
                    currentEffect.Parameters["xAmbient"].SetValue(0.5f);
                }


ive followed every thing to a T.
your xwing.x file works perfectly, color and all.

Problem is, im using autodesk 3ds max 2009, i make a cube, color it red, with the material editor, and then i export it to .3ds, i then use conv3ds and convert it to .x and i rename it xwing replaceing your xwing file in content.
for some odd reason it keeps showing up in black! but when i relaod yours... its back in color. ive tryed everytyhing, ive messed around with the lighting, ive turned off lighthing. ive even tryed chainging it from colored to Textured, but that only turned it white... how did you get your xwing.x file to be color, and why is it i cant seem to get my own model to do the same? it keeps showing in black, and im so frustreated right now. please help me figure how to solv my hair pulling problem. ive spent he last 3 days hours and hours trying to figure a way around, ive read every post regarding this, and have not found an awnser to help me here.

-Apples
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 12/02/2009 at 17:03:04
I remember having issues with the same thing (and in fact, many other projects I've used the .X format in). It would seem that some modelling apps output slightly varying versions of the .x model format. For example, I used to export models from Blender for my last project. If I left all textures assigned to the model, it wouldnt display in the engine I was working on. However, if I removed all references to textures from the project (keeping the UV Coords) it would load and texture a-ok in the engine.

I know it's not much help, but you could try another modelling app (such as blender, it is free!) or changing the export method for your model. I also wouldnt recommend pumping it through file convertors as you don't know what data it might miss or add as it feels

gd luk!
 Poster : TekuConcept
 Posts: 19
 Country : United States
 City: Alpine

  
Posted by TekuConcept on 13/02/2009 at 00:13:53
I imported fbx model formates and most of the time came out with black models too... I belive that it is the .fx file that is the cause.

//------------------------------------------------------------
// Microsoft® XNA Game Studio Creator's Guide  
// by Stephen Cawood and Pat McGee
// Copyright (c) McGraw-Hill/Osborne. All rights reserved.
// http://www.mhprofessional.com/product.php?isbn=007149071X
//------------------------------------------------------------
float4x4 fx_WVP : WORLDVIEWPROJ;

struct gtVertex
{
    float4 f4Position : POSITION0;
    float4 f4Color : COLOR0;
};

struct gtPixelFormat
{
    float4 f4Position : POSITION0;
    float4 f4Color : COLOR0;
};

struct tScreenOutput
{
    float4 f4Color : COLOR0;
};

// alter vertex inputs
void vertex_shader(in gtVertex IN, out gtPixelFormat OUT)
{
     // transform vertex
    OUT.f4Position = mul(IN.f4Position, fx_WVP);
    OUT.f4Color = IN.f4Color;
}
// alter vs output and send to hardware one pixel at a time
void pixel_shader(in gtPixelFormat IN, out tScreenOutput OUT)
{
    float4 fColor = IN.f4Color;
    
    // set f4Color range between 0 and 1
    OUT.f4Color = clamp(fColor, 0, 1);
}

// the shader starts here
technique simple
{
    pass p0
    {
        vertexshader = compile vs_1_1 vertex_shader(); // declare and initialize vs
        pixelshader = compile ps_1_1 pixel_shader();   // declare and initialize ps
    }
}


this fx file is sure to display in color (at least for fbx models)

Add this to the top of the Game1 class:
// shader object - BasicShader.fx
        private Effect mfx;                             // shader object                
        private EffectParameter worldViewProjParam;     // cumulative matrix w*v*p (use this order)
        // sets wvp in shader


Next create a method after the Update() method:
private void init_XNA_app()
        {

            // load BasicShader.fx and set global params
            mfx = content.Load<Effect>(@"shadersBasicShader");
            worldViewProjParam = mfx.Parameters["fx_WVP"];
            mfx.CommitChanges();
            gfx.GraphicsDevice.RenderState.CullMode = CullMode.None; // see both sides
        }

In the Draw() method add this so is to make sure that the objects to be rendered are for that fx file:
// begin shader - BasicShader.fx
            mfx.Begin();
            mfx.Techniques[0].Passes[0].Begin();

            //draw_objects();

            // end shader - BasicShader.fx
            mfx.Techniques[0].Passes[0].End();
            mfx.End();


That is the way I would do it, if that helps.

NOTE:
any effect (unless otherwise) to objects that will be drawn with that fx file, must have the declared 'mfx'

ex:
mfx.CommitChanges();</
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 18/05/2009 at 17:41:31
Hi,

i also made this tutorial and i also have the problem with fbx models. So i read this thread, added the other shader and the lines of code, but it didn't work.

I just started to learn xna and i don't know much about shaders, so i maybe made a mistake. Does anybody else tried this?
 Poster : Archenon
 Posts: 397
 Country : Romania
 City: Oradea

  
Posted by Archenon on 19/05/2009 at 03:16:16
I think your FBX is textured and you forgot to pass the texture to the effect. So it is working with a null texture which is black.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 19/05/2009 at 11:52:52
Sorry for that, but i dont know if there is a texture. I made my first model in 3ds max and only painted it gray. If I render it there, it is gray as it should be and if I use the standard XNA procedure in adding a model it works, too.

could you give me an example?

btw: i call the mfx.Begin() before DrawModel() and stop it after it. The initialization is done when the other shader is initialized. is that correct? What else has to be done?

Thanks!
 Poster : Archenon
 Posts: 397
 Country : Romania
 City: Oradea

  
Posted by Archenon on 20/05/2009 at 00:56:51
Another common thing that have to be checked when working with models and it renders black is the lighting ... is lighting enabled and should it be enabled.

Try disabling the lighting from the graphics.GraphicsDevice.Renderstate.Light....
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 20/05/2009 at 07:05:40
Hi,

i think there is something wrong when using the shader.

when i initialize the model, i still use the effect.fx shader (see the method in the tutorial) and in my opinion i will redo the effects of the new one, when calling the "colored" techinque.

does something else have to be changed in the draw method? or how do i have to initialize it?

thanks
 Poster : Quasar
 Posts: 121
 Country : Australia
 City: Brisbane

  
Posted by Quasar on 21/05/2009 at 21:07:34
I had this same problem this morning. In my case it was the texture (or lack thereof). Try adding a texture to the model in your 3d editing software and re-exporting it.

If that doesn't work, assign a texture 2D to the shader in the draw call in Xna (just before you draw the model):

effect.Parameters["xTexture"].SetValue(myTexture2D);
 Poster : Quasar
 Posts: 121
 Country : Australia
 City: Brisbane

  
Posted by Quasar on 21/05/2009 at 21:13:44
To add a texture in 3ds Max (just in case you don't know :) ):

- Press "m" to bring up the material editor
- Go down and open the "Maps" rollout.
- Click the empty "diffuse" button.
- Select Bitmap.
- Find an image you like the look of, and click Open.
- Drag the new material from the material editor to your object.
- Re-export your object.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 08/01/2010 at 21:12:45
Make sure you export the normals (easier), or recreate them unpon loading the mesh (advanced).

If some models display and one is black, normals are at zero. If you disable lighting, you will see a flat-colored model.

If the model is white (or severely "over-exposed"), it means that the normals were scaled along with some model scaling. The devoec should have a NormalizeNormals function, or you can normalized them as a post-loading process.

Panda Exporter plugin works great from 3DS Max directly to .x mesh

Good luck.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 24/03/2010 at 08:34:11
Hi, im having big troubles trying to get the texture not black, im using maya and exporting to .fbx if anyone could help me asap, it would be greatly aprciated.

  
Post a new reply
 





Google
 
Web www.riemers.net
If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 3.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)