Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Ayumi, ozgur), 650 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
scaling textures with object's scale? #399496
04/16/12 14:55
04/16/12 14:55
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
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 continueous side by side.
To build a castle looking structure you would scale 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 out of 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?

Last edited by Carlos3DGS; 04/16/12 15:10.

"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
Re: scaling textures with object's scale? [Re: Carlos3DGS] #399499
04/16/12 15:24
04/16/12 15:24
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
I know exactly what you mean; you can do this with a shader.

I did that once for another Gamestudio user with Normalmapping included; if you are interested, send me a PM.

Re: scaling textures with object's scale? [Re: HeelX] #399514
04/16/12 17:04
04/16/12 17:04
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Thought I might need a shader for it...
Ive started to work on some pseudo-code to get my ideas straight and the logic looks something like this so far:
Code:
float3 object_pos = my object's origin;
float3 pixel_pos = position relative to object origin;
float3 world_pos = object_pos + pixel_pos;

float3 normal = pixel surface's normal;

float2 texture_pos = world_pos;

texture_pos.x += world_pos.z * normal.x;
texture_pos.y += world_pos.z * normal.y;

float4 pixel = texture_sampler(texture_pos);//wrap


I am definately interested in your approach, sending you a pm right now


"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
Re: scaling textures with object's scale? [Re: Carlos3DGS] #399547
04/17/12 00:28
04/17/12 00:28
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
Update: I'm back to trying to do this myself. Since I'm going the shader route I will continue this in the shader forum. You can find it at the following link:
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=399546&#Post399546
Any pointers to shove me in the right direction or any help would be greatly appreaciated.


"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
Re: scaling textures with object's scale? [Re: Carlos3DGS] #399555
04/17/12 09:05
04/17/12 09:05
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
Hi,

isn't it possible via ent_getvertex/entsetvertex?

Cycling through all the vertices of an entity and getting the c.v (=D3DVERTEX) pointers, thus c.v.u1 and c.v.u2 are accessible for modification, i.e. their values can be scaled by multiplication/division?

I never tried it, I only set c.v.x/z/y and c.v.nx/nz/ny this way, but in theory it should work...


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: scaling textures with object's scale? [Re: sivan] #399556
04/17/12 09:07
04/17/12 09:07
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
....hmm probably it's not okay for blocks only models and terrains...


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: scaling textures with object's scale? [Re: sivan] #399564
04/17/12 10:18
04/17/12 10:18
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline OP
User
Carlos3DGS  Offline OP
User

Joined: Oct 2008
Posts: 513
even though I called them "blocks" some times they are not wed blocks. They are simple med models. I am trying the shader route here: http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=399546&#Post399546
but am open to any suggestions. What is that u1 u2 thing you mentioned for? Changing the UV texture mapping coordinates at runtime or something else?


"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
Re: scaling textures with object's scale? [Re: Carlos3DGS] #399573
04/17/12 12:00
04/17/12 12:00
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I wrote wrongly, I wanted to write u1 and v1 which are the texture uv coordinates


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: scaling textures with object's scale? [Re: sivan] #399574
04/17/12 12:04
04/17/12 12:04
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
by ent_getvertex it is possible to access the D3DVERTEX pointer of any model/terrain vertex called c.v if:

CONTACT* c = ent_getvertex(entity,NULL,vertex_number);

and as described in atypes.h:

typedef struct {
float x,y,z; // position in DirectX coordinates
float nx,ny,nz; // normal
float u1,v1; // first coordinate set, for textures
float u2,v2; // second coordinate set, for shadow maps
float x3,y3,z3,w3; // third coordinate set, for tangent vector and handedness
#ifdef A8
float tu4,tv4; // 4th coordinate set, for additional data
#endif
} D3DVERTEX;

very similar to mesh deformation, but now c.v.u1 and v1 are what you need (floats!). And then ent_setvertex(entity,c,vertex_number);


Free world editor for 3D Gamestudio: MapBuilder Editor

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1