Texture only one side on a cube

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
bozhang
Gnoblar
Posts: 3
Joined: Mon May 22, 2017 7:21 am

Texture only one side on a cube

Post by bozhang »

Hello folks, I need to texture only one side of cube and the rest not-textured. The following puts it on all sides. I've tried tuning the params and also try out cubic_texture, but no avail. Anyone can help me? :cry:

Code: Select all

texture_unit
      {
        texture checkerboard.png
        tex_coord_set 0
      }
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Texture only one side on a cube

Post by kubatp »

I am not really sure what are you trying to achieve (the description is not really clear to me), but here are few suggestions from top of my head:
  • Why don't you remove the faces from the model, where you dont want to have textures? Is there any particular reason to have these faces without texture?
  • Set different (new) material for those faces, where you don't want to have texture. For this new material, don't use the texture and make it transparent.
  • You can also use the same material for the whole cube, but use shader and some special UV mapped parameters for those faces you want to have transparent. In shader you discard those faces you want to have transparent.
bozhang
Gnoblar
Posts: 3
Joined: Mon May 22, 2017 7:21 am

Re: Texture only one side on a cube

Post by bozhang »

kubatp wrote:I am not really sure what are you trying to achieve (the description is not really clear to me), but here are few suggestions from top of my head:
  • Why don't you remove the faces from the model, where you dont want to have textures? Is there any particular reason to have these faces without texture?
  • Set different (new) material for those faces, where you don't want to have texture. For this new material, don't use the texture and make it transparent.
  • You can also use the same material for the whole cube, but use shader and some special UV mapped parameters for those faces you want to have transparent. In shader you discard those faces you want to have transparent.
Thanks for the reply. Excuse me for blurry description. I've tried your first option to skip this issue. However, in case I need a cube where all sides are covered with different texture, say a dice with a variety of dots. In this case how could I apply the texture on this cube?
kubatp
Gnome
Posts: 368
Joined: Tue Jan 06, 2009 1:12 pm
x 43

Re: Texture only one side on a cube

Post by kubatp »

bozhang wrote:Thanks for the reply. Excuse me for blurry description. I've tried your first option to skip this issue. However, in case I need a cube where all sides are covered with different texture, say a dice with a variety of dots. In this case how could I apply the texture on this cube?
If you want to have the same mesh (cube) used in different scenarios where in one you want some faces to be transparent and in another one to be textured, you can go for the second or third suggested option.

Basically the second option is easier, but you might end up with six different materials for cube (one per each side/face). The number of materials depends on flexibility you want to have.

The third option is a bit more difficult, but you can "encode" for each cube face (side) special UV mapping (in the modelling tool or in case you use manualobject in your code) and by setting customparameter for the cube entity, you can hide (discard) some faces of the cube in the shader.
Post Reply