Web Toolbar by Wibiya

Problem loading textures using XNA renderer


A place to ask questions or discuss issues relating to implementing applications with Axiom. If you are unsure of where to post, post here.

Team Member
Team Member

Posts: 213

Joined: Tue Nov 17, 2009 1:56 pm

Post Wed Oct 13, 2010 4:19 am

Problem loading textures using XNA renderer

Hi, I'm trying to get a simple scene going for an XNA Windows Game project.
I have the following:

Entity ninja = scene.CreateEntity("bob", "ninja.mesh");
SceneNode ninjaNode = scene.RootSceneNode.CreateChildSceneNode();
ninjaNode.AttachObject(ninja);

But when I run the Game, it renders absolutely nothing. I check the log file and it tells me it can't find nskingr.jpg

Anyway, I set the ninja material to:
ninja.MaterialName = "BaseWhite";

and I can see the ninja, albeit without his texture.

I'm fairly certain this has something to do with the Content Project. Does the XnaResourceGroupManager look for .xnb's or the normal extensions?

I find it odd, because the ResourceGroupManager found the ninja.mesh resource, but can't locate the texture.
User avatar

Team Member
Team Member

Posts: 1591

Joined: Thu Mar 02, 2006 11:29 pm

Location: Boston, MA, USA

Post Wed Oct 13, 2010 5:34 am

Re: Problem loading textures using XNA renderer

If you are using the XnaResourceGroupManager, then yes, it is looking for Textures to have been processed by the Content Pipeline, as internally it uses a call to content.Load<>() to load the Texture. This would put the textures, and shaders into xnb files. It's able to find the Mesh, because it's only specifically looking for Textures and GPUPrograms using the ContentPipeline.
Borrillis
The Steward of Axiom

Team Member
Team Member

Posts: 213

Joined: Tue Nov 17, 2009 1:56 pm

Post Wed Oct 13, 2010 11:52 pm

Re: Problem loading textures using XNA renderer

Alright, I know that the .xnb's are present. Perhaps you can shed some light on why it's not finding the textures. I have the following code:

  Code:
protected override void SetupResources()
        {

            (new XnaResourceGroupManager()).Initialize(new string[]
                                                         {
                                                             "png", "jpg", "bmp", "dds", "jpeg", "tiff"
                                                         });
           

            string titleLocation = string.Empty;

#if (XBOX || XBOX360)
            titleLocation = StorageContainer.TitleLocation + "\\";
#endif
            ResourceGroupManager.Instance.AddResourceLocation(titleLocation + "Content\\Compositors", "Folder");
            ResourceGroupManager.Instance.AddResourceLocation(titleLocation + "Content\\Fonts", "Folder");
            ResourceGroupManager.Instance.AddResourceLocation(titleLocation + "Content\\GpuPrograms", "Folder");
            ResourceGroupManager.Instance.AddResourceLocation(titleLocation + "Content\\Materials", "Folder");
            ResourceGroupManager.Instance.AddResourceLocation(titleLocation + "Content\\Meshes", "Folder");
            ResourceGroupManager.Instance.AddResourceLocation(titleLocation + "Content\\Particles", "Folder");
            ResourceGroupManager.Instance.AddResourceLocation(titleLocation + "Content\\Skeletons", "Folder");
            ResourceGroupManager.Instance.AddResourceLocation(titleLocation + "Content\\Textures", "Folder");


            base.SetupResources();
        }


images in the texture folder are set to compile, and to never copy to output directory. Use Content Pipeline is set to false.
Ideas?
User avatar

Team Member
Team Member

Posts: 1591

Joined: Thu Mar 02, 2006 11:29 pm

Location: Boston, MA, USA

Post Thu Oct 14, 2010 7:06 am

Re: Problem loading textures using XNA renderer

Try setting Use Content Pipeline to true.
Borrillis
The Steward of Axiom

Team Member
Team Member

Posts: 213

Joined: Tue Nov 17, 2009 1:56 pm

Post Thu Oct 14, 2010 1:40 pm

Re: Problem loading textures using XNA renderer

Won't I be needing a valid vertex and pixel shader set for every draw?

Edit:
Ok, I set on Save Generated Shaders, and it generated 10.hlsl, which contains both a fragment and vertex program. I split the file in two (one for the VP one for the FP), and added it to the content project.
Then I set the entry points, told the vertex program to use VS_2_0 and the fragment program to use PS_2_0.
I then created 10.program and added the gpu programs, and then edited the material script.
Well, it built, with Use Content Pipeline = Yes, but I still don't see the ninja. The log file reports no errors.

I'm still pretty iffy on shaders (and frankly I've got no idea what's going on inside that 10.program script) so perhaps you can see a problem in one of these.

10VP.hlsl
  Code:
/***************************************************************************************
* This shader was generated by a tool; any changes made to this file may be lost
* Axiom Fixed Function Emulation Layer
* Vertex Program Entry Point : VS
* Fragment Program Entry Point : FP
* Vertex Buffer Delcaration : Float3 Position0;
Float3 Normal0;
Float2 TexCoords0;

* Fixed Function State : Axiom.RenderSystems.Xna.FixedFunctionEmulation.FixedFunctionState
***************************************************************************************/
struct VS_INPUT
{
   float4 Position0 : POSITION0;
   float3 Normal0 : NORMAL0;
   float2 Texcoord0 : TEXCOORD0;
};

float4x4  World;
float4x4  View;
float4x4  Projection;
float4x4  ViewIT;
float4x4  WorldViewIT;
shared float4x4  TextureMatrix0; //technique: None
float4 BaseLightAmbient;
float4 MaterialAmbient=float4(1,1,1,1);
float4 MaterialDiffuse=float4(1,1,1,1);
float4 MaterialSpecular=(float4)0;

struct VS_OUTPUT
{
   float4 Pos : POSITION;
   float2 Texcoord0 : TEXCOORD0;
   float4 Color: COLOR0;
   float4 ColorSpec: COLOR1;
};

VS_OUTPUT VS( VS_INPUT input )
{
   VS_OUTPUT output = (VS_OUTPUT)0;
   float4 worldPos = mul( World, input.Position0);
   float4 cameraPos = mul( View, worldPos );
   output.Pos = mul( Projection, cameraPos );
   float3 Normal = input.Normal0;
   //debug info : texture stage 0 coordindex: 0
   {
      float4 texCordWithMatrix = float4(input.Texcoord0, 1, 1);
      texCordWithMatrix = mul(texCordWithMatrix, TextureMatrix0 );
      output.Texcoord0 = texCordWithMatrix.xy;
   }
   output.ColorSpec =MaterialSpecular;
   output.Color = MaterialAmbient;
   return output;
}


10FP
  Code:
/***************************************************************************************
* This shader was generated by a tool; any changes made to this file may be lost
* Axiom Fixed Function Emulation Layer
* Vertex Program Entry Point : VS
* Fragment Program Entry Point : FP
* Vertex Buffer Delcaration : Float3 Position0;
Float3 Normal0;
Float2 TexCoords0;

* Fixed Function State : Axiom.RenderSystems.Xna.FixedFunctionEmulation.FixedFunctionState
***************************************************************************************/
struct VS_INPUT
{
   float4 Position0 : POSITION0;
   float3 Normal0 : NORMAL0;
   float2 Texcoord0 : TEXCOORD0;
};

float4x4  World;
float4x4  View;
float4x4  Projection;
float4x4  ViewIT;
float4x4  WorldViewIT;
shared float4x4  TextureMatrix0; //technique: None
float4 BaseLightAmbient;
float4 MaterialAmbient=float4(1,1,1,1);
float4 MaterialDiffuse=float4(1,1,1,1);
float4 MaterialSpecular=(float4)0;

struct VS_OUTPUT
{
   float4 Pos : POSITION;
   float2 Texcoord0 : TEXCOORD0;
   float4 Color: COLOR0;
   float4 ColorSpec: COLOR1;
};
sampler2D Texture0 : register(s0);

float4 FP( VS_OUTPUT input ) : COLOR
{
   float4 finalColor= input.Color + input.ColorSpec;
   {
      float4 texColor=float4(1.0,1.0,1.0,1.0);
      texColor  = tex2D(Texture0, input.Texcoord0);
      float4 source1 = texColor;
      float4 source2 = finalColor;
      finalColor = source1 * source2;
   }
   return finalColor;
}


10.program
  Code:
vertex_program 10VP hlsl
{
   source 10VP.hlsl
   entry_point VS
   target vs_2_0
   
   default_params
   {
      param_named Light0_Ambient float4 1 1 1 1
      param_named_auto Light0_Diffuse light_diffuse_colour 0
      param_named_auto Light0_Specular light_specular_colour 0
      param_named_auto Light0_Direction light_direction_object_space 0
      param_named_auto eyePosition camera_position_object_space
      param_named_auto worldViewProj worldviewproj_matrix
      param_named_auto worldViewIT inverse_transpose_worldview_matrix
      param_named_auto viewIT inverse_transpose_view_matrix
   }
}

fragment_program 10FP hlsl
{
   source 10FP.hlsl
   entry_point FP
   target ps_2_0
}

Team Member
Team Member

Posts: 213

Joined: Tue Nov 17, 2009 1:56 pm

Post Sun Oct 17, 2010 12:12 am

Re: Problem loading textures using XNA renderer

Can anyone see a problem with these scripts?

Team Member
Team Member

Posts: 114

Joined: Wed Apr 22, 2009 2:18 am

Post Sun Oct 17, 2010 7:48 am

Re: Problem loading textures using XNA renderer

hi doublea,

first, variables are case sensitive, so you need to take care if that (param_named_auto WorldViewIT inverse_transpose_worldview_matrix)
second, you'r trying to update variables which are not in your shader (eyepos for example).

and, can you post your code where you handle your ninja?

unfortunatly i dont have that much time today, otherwise we could meet IRC. if you have some time tomorrow, we can talk there.

//bostich

Team Member
Team Member

Posts: 213

Joined: Tue Nov 17, 2009 1:56 pm

Post Sun Oct 17, 2010 5:01 pm

Re: Problem loading textures using XNA renderer

Thanks for the reply, I look forward to talking. I'd really like to get this project going.

Team Member
Team Member

Posts: 213

Joined: Tue Nov 17, 2009 1:56 pm

Post Wed Oct 20, 2010 5:46 pm

Re: Problem loading textures using XNA renderer

Alright, I believe I'm fairly close here. A couple of questions.

First, in my .program file I set some default params
  Code:

       //vertex program
   default_params
   {
      param_named_auto World world_matrix
      param_named_auto View camera_position_object_space
      param_named_auto Projection world_matrix
      param_named_auto ViewIT inverse_transpose_view_matrix
      param_named_auto WorldViewIT inverse_transpose_worldview_matrix
      param_named_auto BaseLightAmbient float4 1 1 1 1
   }


now then in my vertex shader, it has the following variables to be initialized.
  Code:
float4x4  World;
float4x4  View;
float4x4  Projection;
float4x4  ViewIT;
float4x4  WorldViewIT;
shared float4x4  TextureMatrix0; //technique: None
float4 BaseLightAmbient;
float4 MaterialAmbient=float4(1,1,1,1);
float4 MaterialDiffuse=float4(1,1,1,1);
float4 MaterialSpecular=(float4)0;


now then in setting the default_params, I don't include MaterialAmbient, MaterialDiffuse, or MaterialSpecular, because they're already initialized. But do I need to set a value for TextureMatrix0? I'm kind of confused on the shared keyword, as well as I don't know what kind of value to be giving it.

Alright then, in my log, it tells me:
Invalid param_named_auto attribute - expected 2 or 3 parameters.

but I don't know what's asking for the parameters, and what parameters to give it

again, help would be greatly appreciated.

Team Member
Team Member

Posts: 213

Joined: Tue Nov 17, 2009 1:56 pm

Post Fri Oct 22, 2010 12:56 am

Re: Problem loading textures using XNA renderer

This is being quite the headache, and I apologize to anyone annoyed by my frequent questions in this.
Alright, I solved my shader problems (or so I believe), unfortunately my ninja has yet to make an appearance. I have been able to get particles to render properly however...

Anyway, in my log file it reports:

[11:49:55] No codec available for media with extension .mesh
[11:49:55] Mesh: Loading 'ninja.mesh'...
[11:49:55] Skeleton: Loading 'ninja.skeleton'...
[11:49:55] No codec available for media with extension .skeleton

is this the reason that my ninja's not loading?

Return to General Q & A

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.