# How to make quare tiles look less squarish?

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

## Recommended Posts

I am making a terrain for my game and it uses tiledata(a grid of squares and the terrain type of each square),but it looks very squarish,even when I try to blur it on the blendmap:

[attachment=9041:terrain.png]

Is there a way to make the tiles be some other shape than a square?At most I managed to make them a little more circlish,using trigonometric functions,but all those operations just for the terrain diffuse color......

##### Share on other sites
Had the same problem with my terrain generator. Got awesome results with texture blending:

Render all textures on every polygon.
For each texture on each vertex, assign an alpha value. (Render multiple textures over each other)

The tricky part:
For a given vertex compute all textures around it (four squares touching the vertex).
The alpha value should be the weighted average of the materials.

Example:
Givven a quad of Grass (G) and Rock( R ) Snow(S) in the following formation:
GG
RG

The vertex in the middle should have 0.75 grass , 0.25 rock, and no snow.

Hope this helps. Edited by SillyCow

##### Share on other sites
[quote name='SillyCow' timestamp='1338070893' post='4943575']
Had the same problem with my terrain generator. Got awesome results with texture blending:

Render all textures on every polygon.
For each texture on each vertex, assign an alpha value. (Render multiple textures over each other)

The tricky part:
For a given vertex compute all textures around it (four squares touching the vertex).
The alpha value should be the weighted average of the materials.

Example:
Givven a quad of Grass (G) and Rock( R ) Snow(S) in the following formation:
GG
RG

The vertex in the middle should have 0.75 grass , 0.25 rock, and no snow.

Hope this helps.
[/quote][quote name='SillyCow' timestamp='1338070893' post='4943575']
Had the same problem with my terrain generator. Got awesome results with texture blending:

Render all textures on every polygon.
For each texture on each vertex, assign an alpha value. (Render multiple textures over each other)

The tricky part:
For a given vertex compute all textures around it (four squares touching the vertex).
The alpha value should be the weighted average of the materials.

Example:
Givven a quad of Grass (G) and Rock( R ) Snow(S) in the following formation:
GG
RG

The vertex in the middle should have 0.75 grass , 0.25 rock, and no snow.

Hope this helps.
[/quote]

wait I'm kind of confused,isn't the blending done in [b]pixel [/b]shader?You mentioned [b]vertex[/b].I might have not understood properly,the image you linked is not displaying for some reason

##### Share on other sites
Actually did this way before shader languages. I think it was with DirectX7 on a Geforce 2. So it was good old fixed pipeline (No shaders... ) . It doesn't matter. I had square terrain tiles (Easy for calculations) , and needed to remove the ugly square effect for rendering.

Fact of the matter is that for rendering it is better to assign material to vertex then to assign to square.

When you render a triangle, render it several times with different textures (fixed pipeline). Or render it once with several textures (HLSL pixel shader). The outcome is the same.

[quote]
[left][background=rgb(250, 251, 252)]Example:[/background][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]Givven a quad of Grass (G) and Rock( R ) Snow(S) in the following formation:[/background][/size][/font][/color][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]GG[/background][/size][/font][/color][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]RG[/background][/size][/font][/color][/left]

[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(247, 247, 247)]The vertex in the middle should have 0.75 grass , 0.25 rock, and no snow.[/background][/size][/font][/color][/left]

[/quote]

Use the above mentioned "algorithm" to calculate the alpha value for that vertex and texture

Here is an example of the result. Although terrain tiles are square, you cannot see them (besides the fact that I used a very repetitive texture here). Edited by SillyCow

##### Share on other sites
[quote name='SillyCow' timestamp='1338073529' post='4943582']
Actually did this way before shader languages. I think it was with DirectX7 on a Geforce 2. So it was good old fixed pipeline (No shaders... ) . It doesn't matter. I had square terrain tiles (Easy for calculations) , and needed to remove the ugly square effect for rendering.

Fact of the matter is that for rendering it is better to assign material to vertex then to assign to square.

When you render a triangle, render it several times with different textures (fixed pipeline). Or render it once with several textures (HLSL pixel shader). The outcome is the same.

[quote]
[left][background=rgb(250, 251, 252)]Example:[/background][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]Givven a quad of Grass (G) and Rock( R ) Snow(S) in the following formation:[/background][/size][/font][/color][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]GG[/background][/size][/font][/color][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]RG[/background][/size][/font][/color][/left]

[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(247, 247, 247)]The vertex in the middle should have 0.75 grass , 0.25 rock, and no snow.[/background][/size][/font][/color][/left]

[/quote]

Use the above mentioned "algorithm" to calculate the alpha value for that vertex and texture

Here is an example of the result. Although terrain tiles are square, you cannot see them (besides the fact that I used a very repetitive texture here).
[/quote]

[quote name='SillyCow' timestamp='1338073529' post='4943582']
Actually did this way before shader languages. I think it was with DirectX7 on a Geforce 2. So it was good old fixed pipeline (No shaders... ) . It doesn't matter. I had square terrain tiles (Easy for calculations) , and needed to remove the ugly square effect for rendering.

Fact of the matter is that for rendering it is better to assign material to vertex then to assign to square.

When you render a triangle, render it several times with different textures (fixed pipeline). Or render it once with several textures (HLSL pixel shader). The outcome is the same.

[quote]
[left][background=rgb(250, 251, 252)]Example:[/background][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]Givven a quad of Grass (G) and Rock( R ) Snow(S) in the following formation:[/background][/size][/font][/color][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]GG[/background][/size][/font][/color][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]RG[/background][/size][/font][/color][/left]

[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(247, 247, 247)]The vertex in the middle should have 0.75 grass , 0.25 rock, and no snow.[/background][/size][/font][/color][/left]

[/quote]

Use the above mentioned "algorithm" to calculate the alpha value for that vertex and texture

Here is an example of the result. Although terrain tiles are square, you cannot see them (besides the fact that I used a very repetitive texture here).
[/quote]

[left]ok just one last question - can you post a single-line example of ''setting the vertex to 0.75 grass''? I mean I'm new with HLSL and so far all I've done is the standart RGB blendmap with 3 textures in pixel shader. [/left]

##### Share on other sites
It'd be something like this (I'd personally do it in a pixel shader, as then you can perturb the boundaries with some noise to make it more natural and give you even more detail):

[CODE]float rockPercentage = 0.25 //amount to go for rock
float grassPercentage = 0.75 //amount to go for grass
float snowPercentage = 0 //amount to go for snow

float4 snow = snowTex.Sample(texcoords); //the pixel colour of the snow texture
float4 grass = grassTex.Sample(texcoords); //the pixel colour of the grass texture
float4 rock = rockTex.Sample(texcoords); // the pixel colour of the rock texture

float4 colour = snow * snowPercentage + rock * rockPercentage + grass * grassPercentage;[/CODE]

Then the pixel colour will be 0% snow, 25% rock and 75% grass.

Do the same with the normal maps for a nice blend of those too.

EDIT: commented it up Edited by NickUdell