I started a thread in the "starting with gamestudio" section, but since I am going the shader route I decided it would be best to continue here. Some backround on what I am trying to achieve with this shader:

Originally Posted By: Carlos3DGS
Hard to describe this clearly in the title, so let me try get the idea across in more detailed explanation:
I have lots of square cube blocks in my game, the player can place and scale the height of these blocks, kind of like a simplified minecraft. These blocks all have tileable textures so they look contiguos side by side.
To build a castle-looking structure you could try to achieve it by scaleing a block to a height of x12, the block beside to height x10, and continue altering heights of your blocks between x12 and x10 till you have built the complete structure of the castle out of different height blocks.

My problem is this: When scaling the height of a block, the texture on the sides (walls) are streched, so the tileable textures on the sides (wall) no longer match the wall textures of the blocks beside it.

My question is, to avoid this "stretching" problem on the textures... Is there any way to tile the texture on the objects depending on it's size instead of stretching it?


I have started to think on how to achieve this and so far I have this pseudo-code planning out the shader logic:

Code:
//THIS FIRST PART WORKS FOR HORIZONTAL PLANES (TOP OF BLOCK)
float3 object_world_pos = my object's origin;
float3 pixel_local_pos = position relative to object's origin;

float3 pixel_world_pos = object_world_pos + pixellocal__pos;
float2 texture_pos = (pixel_world_pos.x, pixel_world_pos.y);//texcoord

//THIS PART ALSO TAKES INTO ACCOUNT VERTICAL WALLS (SIDES OF THE CUBES)
float3 normal = pixel surface's normal;
texture_pos.x += pixel_world_pos.z * normal.x;
texture_pos.y += pixel_world_pos.z * normal.y;

float4 pixel = texture_sampler(texture_pos);//wrap?



So how does the logic look so far? Am I heading in the right direction?
Any help would be great.


"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1