Advertisement Jump to content
Sign in to follow this  
ali rahimi

Custom tilling per each MipMap level.

This topic is 2670 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[font="verdana, sans-serif"]Hello guys.[/font]
[font="verdana, sans-serif"] [/font][font="verdana, sans-serif"]I want to use a Custom tilling per each MipMap level for landscape (Like lumion). If you notice in lumion landscape tilling change based on camera distance. Close distance have more tile's. One way is to do the tilling in photoshop per each mipmap, but problem is then you will have a low res tilling in close distance. (Cause it tiled in photoshop). Therefore iam trying to do the tilling in a shader itself. I setup an array of float2. X is tilling amount and Y is the mipmap count. But it don't work correct for some reason.[/font]
[font="verdana, sans-serif"]And i am using Quest3D for this. [/font]
[font="verdana, sans-serif"] [/font][font="verdana, sans-serif"] [/font]
int UseTangent : UseTangent;
int UseBiNormal : UseBiNormal;

float4x4 wvp : WorldViewProjection;
float4x4 worldI : WorldInverse;
float4x4 world : World;

texture Texture_Map : TEXTURE0
string ResourceType = "2D";

sampler2D Texture_MapSampler = sampler_state
Texture = <Texture_Map>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;

static float2 Tile_UV_Index[10] =

// UV_Cordinate function
float4 UV_Cordinate (float3 VertexPosition)
float4 UV_Cordinate_Result = float4(0,0,0,0);
for(int i=0; i<10; i++)
float2 UV_X = float2(VertexPosition.y, VertexPosition.z);
float4 Output = float4((UV_X/(Tile_UV_Index.x)).xy, 0, Tile_UV_Index.y);
UV_Cordinate_Result += Output;
return UV_Cordinate_Result;
// input from application
struct a2v {
float4 position : POSITION;
float2 texCoord : TEXCOORD0;


// output to fragment program
struct v2f {
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
float4 wposition : TEXCOORD2;


// Ambient Pass Vertex Shader:
v2f av(a2v In)
v2f Out = (v2f)0;
Out.position = mul(In.position, wvp); //transform vert position to homogeneous clip space
Out.wposition = mul(In.position, world); //world space vertex position passed out
Out.wposition.xyzw = Out.wposition.xzyw; //Output vertex position in world space - swizzled for Y up
Out.wposition.y = -Out.wposition.y;
Out.texCoord = In.texCoord; //pass through texture coordinates from channel 1

return Out;

// Ambient Pass Pixel Shader:
float4 af(v2f In) : COLOR
float3 VertexPosition =;
float2 UV_X = float2(VertexPosition.y, VertexPosition.z);

// float4 Texture_Map = tex2Dlod(Texture_MapSampler, float4((UV_X/1).xy, 0, 1)); // correct result, last float1 at the end is mipmap level.
float4 Texture_Map = tex2Dlod(Texture_MapSampler,float4(UV_Cordinate(VertexPosition))); // But function dont look correct.
float3 input1 = Texture_Map.rgb;

float4 ret = float4(input1, 1);
return ret;

technique Complete
pass ambient
VertexShader = compile vs_3_0 av();
ZEnable = true;
ZWriteEnable = true;
CullMode = ccw;
ShadeMode = Gouraud;
AlphaBlendEnable = false;
AlphaTestEnable = FALSE;
PixelShader = compile ps_3_0 af();


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!