Forum
Contact





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



Latest Forum posts

 DVD movies through media streamer
  Posted by: VIKIVannessa
  When: 16/04/2014 at 02:25:09

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 16/04/2014 at 02:20:51

 Blu-ray to Apple ProRes
  Posted by: Applefly
  When: 12/04/2014 at 00:47:46

 HD H.264 MP4 format
  Posted by: Applefly
  When: 12/04/2014 at 00:43:23

 DVD collection to computer
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:13:33

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:11:27

 DVD movies to play on Galaxy Tab 3 10.1
  Posted by: VIKIVannessa
  When: 04/04/2014 at 07:11:27

 DVD Ripper to populate
  Posted by: Applefly
  When: 04/04/2014 at 05:01:35

 kids and family watch DVD
  Posted by: Applefly
  When: 04/04/2014 at 04:59:21

 Blu-ray movie for your lovely kids
  Posted by: VIKIVannessa
  When: 02/04/2014 at 05:47:49

 DVD to DNxHD Converter for Mac
  Posted by: VIKIVannessa
  When: 02/04/2014 at 05:46:04

 play HD Videos on Galaxy
  Posted by: Applefly
  When: 01/04/2014 at 03:16:39

 video on iPhone 6
  Posted by: Applefly
  When: 01/04/2014 at 03:15:18

 MessageBox
  Posted by: net777
  When: 31/03/2014 at 03:34:55

 Play MVI/MKV/AVI on Galaxy NotePro 12.2
  Posted by: VIKIVannessa
  When: 31/03/2014 at 01:30:21

 Create family videos with iMovie on Mac
  Posted by: VIKIVannessa
  When: 31/03/2014 at 01:29:25

 WMV format from DVD
  Posted by: Applefly
  When: 28/03/2014 at 02:55:09

 BD/DVD to FCP X
  Posted by: Applefly
  When: 28/03/2014 at 02:53:35

 Put all kinds videos to Kurio 7S
  Posted by: VIKIVannessa
  When: 27/03/2014 at 01:20:22

 play movie & video on Nexus 6
  Posted by: VIKIVannessa
  When: 27/03/2014 at 01:19:47




Topic: multitexture 2.0 ps



  
Goto parent category
  
Create a new user account


   multitexture 2.0 ps
 Poster : hammer
 Posts: 7
 Country :
 City:

  
Posted by hammer on 10/03/2007 at 05:57:03
Hi there can you explain more on the fx files???
And can the multi texturing be done with a ps 1.1 ??
Because 2.0 is kind of new technique and not every VGA supports it. :) Thanks in advance.
 Poster : hammer
 Posts: 7
 Country :
 City:

  
Posted by hammer on 10/03/2007 at 23:51:32
I just got the idea to show you the error i get from c# :)

     Output.Color = tex2D(SandTextureSampler, PSIn.TextureCoords)*PSIn.TextureWeights.x;
     Output.Color += tex2D(GrassTextureS ampler, PSIn.TextureCoords)*PSIn.TextureWeights.y;
     Output.Color += tex2D(RockTextureSampler, PSIn.TextureCoords)*PSIn.TextureWeights.z;
     Output.Color += tex2D(SnowTextureSampler, PSIn.TextureCoords)*PSIn.TextureWeights.w;
     Output.Color *= saturate(lightingFactor + xAmbient);

error X4512: cannot access w component from texcoord in general expression
(201): ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
ID3DXEffectCompiler: Compilation failed    
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 11/03/2007 at 16:52:39
Well, the whole third series is on fx files ;)

My tuts should run perfectly on every graphics card produced in the last 5 years. You can always try this page to get xna working on older pcs:
http://www.riemers.net/eng/Tutorials/XNA/Csharp/ShortTuts/Reference_device.php
 Poster : Hammer
 Posts: 7
 Country :
 City:

  
Posted by Hammer on 12/03/2007 at 02:35:48
Yes i understand but the problem is that you use pixel shader 2.0 which is not supported by some cards for example below ati 9500. So my question is can you make it work using the pixel shader 1.1, 1.2, 1.3 or 1.4 versions???
 Poster : Hammer
 Posts: 7
 Country :
 City:

  
Posted by Hammer on 12/03/2007 at 02:40:05
I tried using : http://www.riemers.net/eng/Tutorials/XNA/Csharp/ShortTuts/Reference_device.php

But then the rendering is so slow that i can go to take a nap before the frames are rendered .... So please can you make the fx-file compatible with pixel shaders maximum 1.4 version. Thanks in advance.
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 12/03/2007 at 13:28:18
Instead of simply asking someone else to fix their code to suite your needs, why don't you try and explore the code a little, and do some cross reference on the older shaders first. You seem to be making demands with no gratitude for what has already been provided for us.

Thank you Riemer for everything so far, the tutorials are great, keep up the excellent work.
 Poster : hammer
 Posts: 7
 Country :
 City:

  
Posted by hammer on 12/03/2007 at 14:24:32
I am not pulling a knife on you and saying "do it". I am just asking. I've looked up at msdn some reference on the pixel shaders but nothing detailed ... thats why i ask him to help me out. If you can help by providing information where i can read about this please do.
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 12/03/2007 at 14:58:27
Well the answer is easy: it's not possible. The main difference between v1.x and v2.0 is the huge increase of possible instructions in the pixel and vertex shader.

It's impossible to make the shaders of series 3 compatible with anything below v2.0.

You'll have to get out and buy a 30$ graphics card, or learn to live with low framerates ;)
 Poster : Hammer
 Posts: 7
 Country :
 City:

  
Posted by Hammer on 15/03/2007 at 08:03:13
Okay i've made it work using one more textcoord :)
Here is the code working for pixel shaders lower than 2.0.
Again Thanks for the great tutorials.
//////////////////////
//----------------------------------------------------
//--                                                --
//--             www.riemers.net                 --
//--         Series 4: Advanced terrain             --
//--                 Shader code     -  some edits by hammer                --
//--                                                --
//----------------------------------------------------

//------- Constants --------
float4x4 xView;
float4x4 xProjection;
float4x4 xWorld;
float3 xLightDirection;
float xAmbient;
bool xEnableLighting;

//------- Texture Samplers --------

Texture xTexture;

sampler TextureSampler = sampler_state { texture = <xTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};


Texture xGrassTexture;

sampler GrassTextureSampler = sampler_state { texture = <xGrassTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};
Texture xSandTexture;

sampler SandTextureSampler = sampler_state { texture = <xSandTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};
Texture xRockTexture;

sampler RockTextureSampler = sampler_state { texture = <xRockTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};
Texture xSnowTexture;

sampler SnowTextureSampler = sampler_state { texture = <xSnowTexture>; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};




//------- Technique: Colored --------

struct ColVertexToPixel
{
    float4 Position     : POSITION;    
    float4 Color        : COLOR0;
    float LightingFactor: TEXCOORD0;
};

struct ColPixelToFrame
{
    float4 Color : COLOR0;
};

ColVertexToPixel ColoredVS( float4 inPos : POSITION, float4 inColor: COLOR, float3 inNormal: NORMAL)
{
    ColVertexToPixel Output = (ColVertexToPixel)0;
    float4x4 preViewProjection = mul (xView, xProjection);
    float4x4 preWorldViewProjection = mul (xWorld, preViewProjection);
    
    Output.Position = mul(inPos, preWorldViewProjection);
    Output.Color = inColor;

    float3 Normal = normalize(mul(normalize(inNormal), xWorld));
    Output.LightingFactor = 1;
    if (xEnableLighting)
        Output.LightingFactor = saturate(dot(Normal, -xLightDirection)+xAmbient);
    
    return Output;    
}

ColPixelToFrame ColoredPS(ColVertexToPixel PSIn)
{
    ColPixelToFrame Output = (ColPixelToFrame)0;
    
    Output.Color = PSIn.Color*PSIn.LightingFactor;

    return Output;
}

technique Colored
{
    pass Pass0
    {
        VertexShader = compile vs_1_1 ColoredVS();
        PixelShader = compile ps_1_1 ColoredPS();
    }
}

//------- Technique: Textured --------

struct TexVertexToPixel
{
    float4 Position         : POSITION;    
    float4 Color            : COLOR0;
    float3 Normal            : TEXCOORD0;
    float2 TextureCoords    : TEXCOORD1;
    float4 LightDirection    : TEXCOORD2;

};

struct TexPixelToFrame
{
    float4 Color : COLOR0;
};

TexVertexToPixel TexturedVS( float4 inPos : POSITION, float3 inNormal: NORMAL, float2 inTexCoords: TEXCOORD0)
{
    TexVertexToPixel Output = (TexVertexToPixel)0;
    float4x4 preViewProjection = mul (xView, xProjection);
    float4x4 preWorldViewProjection = mul (xWorld, preViewProjection);
    
    Output.Position = mul(inPos, preWorldViewProjection);
    Output.Normal = mul(normalize(inNormal), xWorld);
    Output.TextureCoords = inTexCoords;
    Output.LightDirection.xyz = -xLightDirection;
    Output.LightDirection.w = 1;
    
    return Output;    
}

TexPixelToFrame TexturedPS(TexVertexToPixel PSIn)
{
    TexPixelToFrame Output = (TexPixelToFrame)0;
    
    float lightingFactor = 1;
    if (xEnableLighting)
        lightingFactor = saturate(saturate(dot(PSIn.Normal, PSIn.LightDirection)) + xAmbient);

    Output.Color = tex2D(TextureSampler, PSIn.TextureCoords)*lightingFactor;

    return Output;
}

technique Textured
{
    pass Pass0
    {
        VertexShader = compile vs_1_1 TexturedVS();
        PixelShader = compile ps_1_1 TexturedPS();
    }
}



//------- Technique: MultiTextured --------

struct MultiTexVertexToPixel
{
     float4 Position         : POSITION;    
     float4 Color            : COLOR0;
     float3 Normal            : TEXCOORD0;
     float4 TextureCoords    : TEXCOORD1;
     float4 LightDirection    : TEXCOORD2;
     float2 TextureWeights0    : TEXCOORD3;
     float2 TextureWeights1 : TEXCOORD4;
};

struct MultiTexPixelToFrame
{
     float4 Color : COLOR0;
};

MultiTexVertexToPixel MultiTexturedVS( float4 inPos : POSITION, float3 inNormal: NORMAL, float4 inTexCoords: TEXCOORD0, float4 inTexWeights: TEXCOORD1)
{
     MultiTexVertexToPixel Output = (MultiTexVertexToPixel)0;
     float4x4 preViewProjection = mul (xView, xProjection);
     float4x4 preWorldViewProjection = mul (xWorld, preViewProjection);
    
     Output.Position = mul(inPos, preWorldViewProjection);
     Output.Normal = mul(normalize(inNormal), xWorld);
     Output.TextureCoords = inTexCoords;
     Output.LightDirection.xyz = -xLightDirection;
     Output.LightDirection.w = 1;
     Output.TextureWeights0.x = inTexWeights.x;
     Output.TextureWeights0.y = inTexWeights.y;
     Output.TextureWeights1.x = inTexWeights.z;
     Output.TextureWeights1.y = inTexWeights.w;
    
     return Output;    
}

MultiTexPixelToFrame MultiTexturedPS(MultiTexVertexToPixel PSIn)
{
     MultiTexPixelToFrame Output = (MultiTexPixelToFrame)0;
    
     float lightingFactor = 1;
    
     if (xEnableLighting)
         lightingFactor = saturate(saturate(dot(PSIn.Normal, PSIn.LightDirection)) + xAmbient);

     Output.Color = tex2D(SandTextureSampler, PSIn.TextureCoords)*PSIn.TextureWeights0.x;
     Output.Color += tex2D(GrassTextureSampler, PSIn.TextureCoords)*PSIn.TextureWeights0.y;
     Output.Color += tex2D(RockTextureSampler, PSIn.TextureCoords)*PSIn.TextureWeights1.x;
    
     Output.Color += tex2D(SnowTextureSampler, PSIn.TextureCoords)*PSIn.TextureWeights1.y;
    
     Output.Color *= saturate(lightingFactor + xAmbient);
    

     return Output;
}

technique MultiTextured
{
     pass Pass0
     {
         VertexShader = compile vs_1_1 MultiTexturedVS();
         PixelShader = compile ps_1_4 MultiTexturedPS();
     }
}
/////////////////////
 Poster : prateekm
 Posts: 1
 Country : India
 City: Faridabad

  
Posted by prateekm on 27/05/2007 at 09:07:15
When I saw the first tutorial and did as was told, a problem came up while running game1.cs :
It says :

"Could not find a Direct3D device that has a Direct3D9-level driver and supports pixel shader 1.1 or greater."

(Minus quotes)
Under the heading :

"NoSuitableGraphicsDeviceException was unhandled"

(Minus qoutes)

Does it mean that I have to install an updated driver?

By the way, I read your tutorials. They are very nice. Keep up the good work.
 Poster : me26493
 Posts: 87
 Country : Australia
 City: Melbourne

  
Posted by me26493 on 27/05/2007 at 16:10:25
I have exactly the same problem on some computers. Has anyone found a solution (or is it just that the graphics card is bad?)

Also, I debugged the game and it says that the graphics card can cope with PixelShader v1_1.

I tried Riemers code for CPU processsing - still have the same problem. It works fine on newer computers (i.e. my computer, at home)
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 28/05/2007 at 03:49:28
To be honest, I haven't yet had the time to test XNA dev on a descent range of computer systems. But officialy, your PC needs a vs1.1 and ps1.1 compatible graphics card.
If you have debugged your app, and it says it is compatible, then I don't have a clue ;)

  
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 4.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)