How to make quare tiles look less squarish?
[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......
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.
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.
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.
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
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.
[background=rgb(250, 251, 252)]Example:[/background]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(250, 251, 252)]Givven a quad of Grass (G) and Rock( R ) Snow(S) in the following formation:[/background][/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(250, 251, 252)]GG[/background][/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(250, 251, 252)]RG[/background][/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(247, 247, 247)]The vertex in the middle should have 0.75 grass , 0.25 rock, and no snow.[/background][/font]
[/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).
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.
[background=rgb(250, 251, 252)]Example:[/background]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(250, 251, 252)]Givven a quad of Grass (G) and Rock( R ) Snow(S) in the following formation:[/background][/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(250, 251, 252)]GG[/background][/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(250, 251, 252)]RG[/background][/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(247, 247, 247)]The vertex in the middle should have 0.75 grass , 0.25 rock, and no snow.[/background][/font]
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]
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.
[background=rgb(250, 251, 252)]Example:[/background]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(250, 251, 252)]Givven a quad of Grass (G) and Rock( R ) Snow(S) in the following formation:[/background][/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(250, 251, 252)]GG[/background][/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(250, 251, 252)]RG[/background][/font]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]
[background=rgb(247, 247, 247)]The vertex in the middle should have 0.75 grass , 0.25 rock, and no snow.[/background][/font]
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]
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.
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