Question about texturing objects.
-
- Halfling
- Posts: 62
- Joined: Mon Jan 29, 2018 8:19 am
Question about texturing objects.
Hi everyone. I have a basic cuboid that should stretch on different axes, and I need there to be a tiled texture on each face.
How would I get the texture to tile properly rather than stretch based on each face’s size?
Thanks.
How would I get the texture to tile properly rather than stretch based on each face’s size?
Thanks.
-
- Bronze Sponsor
- Posts: 614
- Joined: Mon Apr 14, 2003 11:48 pm
- Location: Was LA now France
- x 25
Re: Question about texturing objects.
I'm not sure but it would seem you would need to dynamically change the uv's.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: Question about texturing objects.
or map the texture using world space
-
- Halfling
- Posts: 62
- Joined: Mon Jan 29, 2018 8:19 am
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: Question about texturing objects.
you'll need to modify the shaders, but the problem is that Hlms is not so easy to customize per datablock, it is possible, I do it, I can share, but since its not that easy I prefer to confirm that this is what you need:
When projecting from world space the texture will stay put in the world, so if you move the object the texture will start to offset as you move it:
if all the objects in your scene needs the same treatment then customizing the shaders for every object is very straightforward
When projecting from world space the texture will stay put in the world, so if you move the object the texture will start to offset as you move it:
if all the objects in your scene needs the same treatment then customizing the shaders for every object is very straightforward
-
- Halfling
- Posts: 62
- Joined: Mon Jan 29, 2018 8:19 am
Re: Question about texturing objects.
That’s exactly what I need, and I think it should be fine for every object.
I’ll try and have a go later on but I’d appreciate it if you could point me in the right direction.
Thanks!
I’ll try and have a go later on but I’d appreciate it if you could point me in the right direction.
Thanks!
-
- Halfling
- Posts: 62
- Joined: Mon Jan 29, 2018 8:19 am
Re: Question about texturing objects.
Actually, A lot of objects will be moving, so if the texture stays put in the world then it won’t look too impressive. Is there any solution that would have the texture scale according to the world but moves with the object?
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: Question about texturing objects.
That would be some kind of object space texturing, let me see If I am able to do that, give me a day (I am busy with some stuffs )
-
- Halfling
- Posts: 62
- Joined: Mon Jan 29, 2018 8:19 am
Re: Question about texturing objects.
Ok sounds good thanks.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 168
Re: Question about texturing objects.
(Ogre 2.2, don't know which version you are using) Just for a quick test replacing this piece of code:
with this one (only if the object already has an uv):
you will get what you need but only projected from top!
what you really need is to implement triplanar mapping:
viewtopic.php?f=25&t=93596
but instead of using the world pos as texture coordinates use the local vertex pos ( inVs_vertex ) and multiply it with the corresponding scale component of the worldMat:
Code: Select all
outVs.uv@n = inVs_uv@n;
Code: Select all
outVs.uv@n = inVs_vertex.xz * vec2( worldMat[0].x, worldMat[2].z );
what you really need is to implement triplanar mapping:
viewtopic.php?f=25&t=93596
but instead of using the world pos as texture coordinates use the local vertex pos ( inVs_vertex ) and multiply it with the corresponding scale component of the worldMat:
Code: Select all
inVs_vertex.xz * vec2( worldMat[0].x, worldMat[2].z ) from top/bottom
inVs_vertex.xy * vec2( worldMat[0].x, worldMat[2].y ) from front/back
inVs_vertex.yz * vec2( worldMat[0].y, worldMat[2].z ) left/right