Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to make quare tiles look less squarish?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Veil   Members   -  Reputation: 143

Like
0Likes
Like

Posted 26 May 2012 - 04:08 PM

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:

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

Sponsor:

#2 SillyCow   Members   -  Reputation: 848

Like
1Likes
Like

Posted 26 May 2012 - 04:21 PM

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, 26 May 2012 - 05:06 PM.

My new android game : Enemies of the Crown

My previous android game : Killer Bees


#3 Veil   Members   -  Reputation: 143

Like
0Likes
Like

Posted 26 May 2012 - 04:33 PM

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.

Posted Image

Hope this helps.

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.

Posted Image

Hope this helps.


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

#4 SillyCow   Members   -  Reputation: 848

Like
0Likes
Like

Posted 26 May 2012 - 05:05 PM

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.

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.



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

Attached Thumbnails

  • quest.jpg

Edited by SillyCow, 26 May 2012 - 05:13 PM.

My new android game : Enemies of the Crown

My previous android game : Killer Bees


#5 Veil   Members   -  Reputation: 143

Like
0Likes
Like

Posted 26 May 2012 - 08:03 PM

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.


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.



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


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.


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.



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



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.



#6 NickUdell   Members   -  Reputation: 288

Like
0Likes
Like

Posted 29 May 2012 - 06:34 AM

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):

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;

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, 29 May 2012 - 06:36 AM.

Sole Creator of Pigment - a procedural, block-base space trading sim.

PhD student working on medical imaging at the University of Southampton.

Enjoyer of games, films, books and cider.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS