Normal Mapping

Sep 7, 2012 at 2:02 AM

Hi, I'm new using your engine, i'm using the NormalMap linked effect, but i doesn't work. can you help me?

Coordinator
Sep 7, 2012 at 6:41 AM

Can you give more detail?

Sep 7, 2012 at 7:12 PM

Hi again.

This is my LoadContent method,

 Components.Add(new InputComponent(Window.Handle));
            Components.Add(new FrameRate(GraphicsDevice, Content.Load<SpriteFont>("SpriteFont1")) { Position = new Vector2(10, 10) });

            camera = new My3dProject.Camera.FreeCamera(1, 1000, Vector3.Zero, Vector3.Zero, Vector3.Zero, GraphicsDevice);
            model = Content.Load<Model>("buggy");
            LinkedEffect normal = Content.Load<LinkedEffect>("NormalMappingEffect");
            model.ConvertEffectTo(normal);

            light = new PointLightEffect(GraphicsDevice);
            light.Lights[0].Attenuation = 50;
            light.Lights[0].DiffuseColor = Color.White.ToVector3() * .5f;
            light.Lights[0].Range = 3000;
            light.Lights[0].SpecularColor = Color.White.ToVector3() * .5f;
            
            sFx = new ScreenEffect(GraphicsDevice);
            sFx.Effects.Add(new Nine.Graphics.ScreenEffects.AdoptionEffect(GraphicsDevice) { Speed = 2 });
            sFx.Effects.Add(new Nine.Graphics.ScreenEffects.AntiAliasEffect(GraphicsDevice));
            
            mBatch = new ModelBatch(GraphicsDevice);
            pBatch = new PrimitiveBatch(GraphicsDevice);

 

and this is my NormalMappingEffect.xml

<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
  <Asset Type="Nine.Content.Pipeline.Graphics.Effects.LinkedEffectContent">
    <EffectParts>
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.PositionNormalTextureEffectPartContent"></Item>
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.VertexTransformEffectPartContent"></Item>
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.VertexShaderOutputEffectPartContent"></Item> 
      
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.BasicTextureEffectPartContent">
        <Texture>buggy_diff</Texture>
      </Item>

      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.NormalMapEffectPartContent">
        <NormalMap>buggy_nrm</NormalMap>
      </Item>

      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.MaterialEffectPartContent">
        <SpecularColor>1 1 1</SpecularColor>
      </Item>
      
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.BeginLightEffectPartContent"></Item>
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.AmbientLightEffectPartContent">
        <AmbientLightColor>0.7 0.7 0.7</AmbientLightColor>
      </Item>
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.DirectionalLightEffectPartContent">
        <DiffuseColor>0.5 0.5 0.5</DiffuseColor>
        <Direction>0 -0.707107 -0.707107</Direction>
        <SpecularColor>0.3 0.3 0.3</SpecularColor>
      </Item>
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.PointLightEffectPartContent">
        <DiffuseColor>1 1 1</DiffuseColor>
        <Position>2 2 1</Position>
        <Range>5</Range>
        <SpecularColor>1 1 1</SpecularColor>
      </Item>
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.SpotLightEffectPartContent">
        <DiffuseColor>1 0 0</DiffuseColor>
        <Direction>-1 0 0</Direction>
        <Falloff>2</Falloff>
        <Position>0 0 1</Position>
        <Range>16</Range>
        <SpecularColor>1 1 1</SpecularColor>
      </Item>      
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.EndLightEffectPartContent"></Item>
      
      <Item Type="Nine.Content.Pipeline.Graphics.Effects.EffectParts.PixelShaderOutputEffectPartContent"></Item>
    </EffectParts>
  </Asset>
</XnaContent>