Forum
Contact





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



Latest Forum posts

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 19/05/2013 at 11:27:50

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22

 XNA 4.0
  Posted by: Anonymous
  When: 15/03/2013 at 19:43:57

 Error when I try to run.
  Posted by: Anonymous
  When: 15/03/2013 at 19:21:06

 Error With the Effect File
  Posted by: Anonymous
  When: 15/03/2013 at 18:21:01

 Can only get shadowmap
  Posted by: Anonymous
  When: 15/03/2013 at 15:48:52

 Vertex and Pixel Shader Versions?
  Posted by: Anonymous
  When: 15/03/2013 at 15:07:16

 Unsupported properties
  Posted by: Anonymous
  When: 15/03/2013 at 14:23:00

 Problem Loading Skybox
  Posted by: Rana
  When: 15/03/2013 at 10:34:45

 Black Screen Of Death - Help!
  Posted by: Anonymous
  When: 15/03/2013 at 03:43:43

 2.0 anyone?
  Posted by: Anonymous
  When: 15/03/2013 at 02:19:48

 Defitinition of tha rotation axis
  Posted by: Anonymous
  When: 15/03/2013 at 00:55:14




Topic: Add a gridTexture on top



  
Goto parent category
  
Create a new user account


   Add a gridTexture on top
 Poster : Ne0Que
 Posts: 23
 Country : Borger
 City: the Netherlands

  
Posted by Ne0Que on 27/03/2009 at 05:26:47
Hi,

Is there any example on how i can create a grid texture (1x1) on the terrain? I do not want to replace the multitextured terrain.

If there is a better way to show a squared grid, please tell me. I'm desperate on this because i've been asking this on a whole lot of forums and there was no answer in almost 2 months now. :(

Thank you
 Poster : Archenon
 Posts: 428
 Country : Romania
 City: Oradea

  
Posted by Archenon on 27/03/2009 at 12:10:59
I'm not sure if i understand it right but i think you want to draw a grid like most (3D modeling tools have)

If that is true you need to make the grid rom vertices and conenct them as triangles.

http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/Terrain_basics.php

Maybe something like this?
 Poster : Ne0Que
 Posts: 23
 Country : Borger
 City: the Netherlands

  
Posted by Ne0Que on 27/03/2009 at 14:14:34
Thank you,

No i meant something like this:
 Poster : Ne0Que
 Posts: 23
 Country : Borger
 City: the Netherlands

  
Posted by Ne0Que on 27/03/2009 at 14:16:14
Thank you,

No i meant something like this:

(the dark lines)
 Poster : Archenon
 Posts: 428
 Country : Romania
 City: Oradea

  
Posted by Archenon on 27/03/2009 at 15:36:59
Ohh i see what you mean. This amy have been obtained by modifieing the textures to have a black outline.

Or maybe from Pixel shader. If the Texccord X < 0.05 or bigger then 9.95 then you return black as a color. The same thing should be applied to the Y.

This should give you an outline to the texture without actualy modifieng it.
 Poster : Ne0Que
 Posts: 23
 Country : Borger
 City: the Netherlands

  
Posted by Ne0Que on 27/03/2009 at 18:08:13
Thanks,

Do you have a sample code for me? I don't know how to apply that black color within the pixel shader while using multitextures

Pixel shader code:

MTPixelToFrame MultiTexturedPS(MTVertexToPixel PSIn)
{
    MTPixelToFrame Output = (MTPixelToFrame)0;        
    
    float lightingFactor = 1;
    if (xEnableLighting)
        lightingFactor = saturate(saturate(dot(PSIn.Normal, PSIn.LightDirection)) + xAmbient);
        
    float blendDistance = 0.99f;
    float blendWidth = 0.005f;
    float blendFactor = clamp((PSIn.Depth-blendDistance)/blendWidth, 0, 1);
        
    float4 farColor;
    farColor = tex2D(TextureSampler0, PSIn.TextureCoords)*PSIn.TextureWeights.x;
    farColor += tex2D(TextureSampler1, PSIn.TextureCoords)*PSIn.TextureWeights.y;
    farColor += tex2D(TextureSampler2, PSIn.TextureCoords)*PSIn.TextureWeights.z;
    farColor += tex2D(TextureSampler3, PSIn.TextureCoords)*PSIn.TextureWeights.w;
    
    float4 nearColor;
    float2 nearTextureCoords = PSIn.TextureCoords*3;
    nearColor = tex2D(TextureSampler0, nearTextureCoords)*PSIn.TextureWeights.x;
    nearColor += tex2D(TextureSampler1, nearTextureCoords)*PSIn.TextureWeights.y;
    nearColor += tex2D(TextureSampler2, nearTextureCoords)*PSIn.TextureWeights.z;
    nearColor += tex2D(TextureSampler3, nearTextureCoords)*PSIn.TextureWeights.w;

    Output.Color = lerp(nearColor, farColor, blendFactor);
    Output.Color *= lightingFactor;
    
    return Output;
}


Thank you!
 Poster : Archenon
 Posts: 428
 Country : Romania
 City: Oradea

  
Posted by Archenon on 28/03/2009 at 05:07:20
After MTPixelToFrame Output = (MTPixelToFrame)0;
you add If(PSIn.TexCoords.X < 0.05 || PSIn.TexCoords.X > 0.95 || PSIn.TexCoords.Y <0.05 || TexCoords.Y > 0.95)
{

}
 Poster : Archenon
 Posts: 428
 Country : Romania
 City: Oradea

  
Posted by Archenon on 28/03/2009 at 05:08:37
In the middle of that if Add return Output.
Thix should return black instead of the edges of the texture. Hope this is waht you need.

  
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)