Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Texturing a whole landscape?  (Read 1698 times)
tedlin01
Customers
Community Member
*****
Posts: 140


WWW
« on: September 22, 2009, 02:17:36 PM »

I have problems with texturing a whole landscape.. I have my colored texture which I apply with ExpandTexture. It works great and expands all over the chunks. Altough when I try to apply a normalmap-texture in the shader it only fits into each chunk each. How do I get it to stretch all over the landscape?
Logged

SylvainTV
Administrator
Community Member
*****
Posts: 4944


WWW
« Reply #1 on: September 23, 2009, 02:39:09 PM »

I think the problem is that you're using TEXCOORD1. These are detail map coordinates which are per chunk. Try to use TEXCOORD0 for Normalmap sampling.
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
tedlin01
Customers
Community Member
*****
Posts: 140


WWW
« Reply #2 on: September 29, 2009, 07:57:35 PM »

thank you, it solves the dish Smiley
Logged

tedlin01
Customers
Community Member
*****
Posts: 140


WWW
« Reply #3 on: September 30, 2009, 09:51:42 AM »

I noticed that im using inTexCoords : TEXCOORD0 so it didnt solve the dish Sad
Logged

SylvainTV
Administrator
Community Member
*****
Posts: 4944


WWW
« Reply #4 on: September 30, 2009, 11:16:15 AM »

Well show us your code / shader Smiley
Logged

Regards

Sylvain Dupont
TrueVision3D Developer
sylvain@truevision3d.com

TV3D IRC at http://chat.truevision3d.com or on server irc.truevision3d.com #Truevision3D. Come talk with us !
tedlin01
Customers
Community Member
*****
Posts: 140


WWW
« Reply #5 on: September 30, 2009, 08:50:24 PM »

Code:
//-------
//------- Vertex Shaders --------
//-------

SSceneVertexToPixel Scene_Shadow_BumpVS( float4 inPos : POSITION, float2 inTexCoords : TEXCOORD0, float3 inNormal: NORMAL0, float3 inTangent : TANGENT)
{
     SSceneVertexToPixel Output = (SSceneVertexToPixel)0;

     float4x4 xLightWorldViewProjection = mul(mWorld, mLightViewProjection);
Output.ShadowMapSamplingPos = mul(inPos, xLightWorldViewProjection);

float3x3 worldToTangentSpace;
     worldToTangentSpace[0] = mul(inTangent,mWorld);
     worldToTangentSpace[1] = mul(cross(inTangent,inNormal),mWorld);
     worldToTangentSpace[2] = mul(inNormal,mWorld);

     Output.Light = normalize(mul(worldToTangentSpace,vLightDir));   
     Output.Position = mul(inPos, mWorldViewProjection);
     Output.RealDistance = Output.ShadowMapSamplingPos.z * INV_MAX_DEPTH;
     Output.TexCoords = inTexCoords;
Output.ObjectPosition =  mul(inPos, mWorld);

     return Output;   
}

//-------
//------- Pixel Shaders --------
//-------

SScenePixelToFrame Scene_Shadow_Bump_QualityPS(SSceneVertexToPixel PSIn)
{
SScenePixelToFrame Output = (SScenePixelToFrame)0;

// Get the texture, normal and diffuse colors
float4 texCol = tex2D(ColoredTextureSampler, PSIn.TexCoords);

float3 vNormal = float3(0,0,0);
if( PSIn.ObjectPosition.x < 0.0f && PSIn.ObjectPosition.z > 0.0f ) {       
vNormal = (2 * (tex2D(BumpMapSampler01, PSIn.TexCoords))) - 1.0;
}
else if( PSIn.ObjectPosition.x > 0.0f && PSIn.ObjectPosition.z > 0.0f ) {
vNormal = (2 * (tex2D(BumpMapSampler02, PSIn.TexCoords))) - 1.0;
}
else if( PSIn.ObjectPosition.x < 0.0f && PSIn.ObjectPosition.z < 0.0f ) {
vNormal = (2 * (tex2D(BumpMapSampler03, PSIn.TexCoords))) - 1.0;
}
else if( PSIn.ObjectPosition.x > 0.0f && PSIn.ObjectPosition.z < 0.0f ) {
vNormal = (2 * (tex2D(BumpMapSampler04, PSIn.TexCoords))) - 1.0;
}

float Diffuse = saturate(dot(PSIn.Light,vNormal)) + fAmbient;

// Mix the colors
Output.Color = Diffuse * texCol;
Output.Color.rgb *= vLightColor;
}
Logged

AriusEso
Customers
Community Member
*****
Posts: 940

Esoteric


« Reply #6 on: September 30, 2009, 09:06:27 PM »

Can I please see the data structure for "SSceneVertexToPixel". I don't understand how the UV co-ords for your diffuse texture can work but not for normal. Just use the same co-ords. I need to see this structure to understand what you're doing. Thank you.
Logged

-...-

tedlin01
Customers
Community Member
*****
Posts: 140


WWW
« Reply #7 on: September 30, 2009, 10:30:48 PM »

I guess I'm just doing everything wrong and maybe I missinformed you so if you have a look at this you maybe can tell me the right way to go Smiley


This is how I generate my terrain:
Code:
int iChunks = 4;
m_pLand->GenerateTerrain("Game\\Levels\\Version01\\heightmap.dds", cTV_PRECISION_AVERAGE, iChunks , iChunks, -iChunks*256/2, 0, -iChunks*256/2, false);

I then wan't to split the texture for all the landscape into 4 pieces to keep quality so I use ExpandTexture and it shows up great.
It works great to draw it in my shader too IF I use the semantic TEXTURE0.

Now I want a normalmap to work with this. How do I solve it best way?
I think the best way would have been if I could just do ExpandTextureEx(Layer_normal) and add them up just like the diffusetexture and then use TEXTURE01 semantic in the shader but there is no ExpandTextureEx for landscapes :/

.. So instead I thought that I put together all 4 pieces of my normalmaps and use SetTextureEx(1, texture) but then it doesnt scale over the whole landscape..

so instead I set each piece with the SetEffectTextureParameter and work with them in the shader. One for each bumpmap and then I check the worldposition of the pixel and fetches the the pixel from the correct normalmaptexture.


Anyway here's the code you asked for:


Code:
struct SSceneVertexToPixel
{
    float4 Position              : POSITION;

    float4 RealDistance          : TEXCOORD1;
    float2 TexCoords             : TEXCOORD2;
float3 Light : TEXCOORD3;
float4 ShadowMapSamplingPos : TEXCOORD4;
float4 ObjectPosition        : TEXCOORD5;
};



Code:
Texture xColoredTexture : TEXTURE0;
sampler ColoredTextureSampler = sampler_state { texture = <xColoredTexture> ; MaxAnisotropy = 16; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};

texture BumpMap01;
sampler BumpMapSampler01 = sampler_state { texture = <BumpMap01> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = clamp; AddressV = clamp;};

texture BumpMap02;
sampler BumpMapSampler02 = sampler_state { texture = <BumpMap02> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = clamp; AddressV = clamp;};

texture BumpMap03;
sampler BumpMapSampler03 = sampler_state { texture = <BumpMap03> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = clamp; AddressV = clamp;};

texture BumpMap04;
sampler BumpMapSampler04 = sampler_state { texture = <BumpMap04> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = clamp; AddressV = clamp;};
« Last Edit: September 30, 2009, 11:05:11 PM by tedlin01 » Logged

tedlin01
Customers
Community Member
*****
Posts: 140


WWW
« Reply #8 on: October 07, 2009, 05:13:57 PM »

ok, since I get no answer i Will try to resummon a question.

Question: How do I set several textures on a landscape when I am using ExpandTexture for the diffuse texture?

Right now it seems like if the ExpandTexture fooks up the SetTextureEx since it will start wrapping.
« Last Edit: October 07, 2009, 05:15:49 PM by tedlin01 » Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks