Texturing Interiors

19 views
Skip to first unread message

ashgavs

unread,
Oct 3, 2011, 12:38:43 PM10/3/11
to PhiloGL
Hey All,
I was wondering how one textures the interior of a primitive, in this
case a cylinder. I couldn't find it in the documentation, and for that
I apologize.
--Ashley

ashgavs

unread,
Oct 4, 2011, 3:12:14 PM10/4/11
to PhiloGL
I probably should've been more clear, it was actually a lighting
thing. I just flipped the normals by multiplying them all by -1 and
got the result I desired. Thanks!

Nicolas Garcia Belmonte

unread,
Oct 4, 2011, 3:47:20 PM10/4/11
to phi...@googlegroups.com
Hey, sorry for not getting back quickly, I happy you fixed your issue!

--
Nicolas Garcia Belmonte - http://philogb.github.com/

ashgavs

unread,
Nov 21, 2011, 7:30:54 AM11/21/11
to PhiloGL
So as it turns out I was just kidding myself.

Essentially what I am doing is building a fancy panorama viewer, but
texturing the interiors of cylinders with panoramic photos. I also
removed the caps on the tops and bottoms of the cylinder. So the
interior does have a texture (I didn't think it did before because of
another error I was having.) Unfortunately its horizontally flipped,
like looking in a mirror. I tried flipping the normals by multiplying
by -1 but that didn't seem to do it (also, I am not going to be using
lighting, although I tried it but it didn't work). Thoughts? Also when
its done I'll post the example, it has some good uses of picking and
other cool stuff....its just backwards!
--Ashley

On Oct 4, 2:47 pm, Nicolas Garcia Belmonte <phil...@gmail.com> wrote:
> Hey, sorry for not getting back quickly, I happy you fixed your issue!
>

ashgavs

unread,
Nov 21, 2011, 8:54:33 AM11/21/11
to PhiloGL
Wow, so I *actually* figured it out. When the normals didn't do the
trick I tried altering the texture coordinates directly. I multiplied
the x coordinates of the texCoords by -1, which did the trick. However
this seems really ugly. Is there a better way?
--Ashley

Nicolas Garcia Belmonte

unread,
Nov 23, 2011, 2:30:05 PM11/23/11
to phi...@googlegroups.com
Do you have the app somewhere? Maybe I can take a look at it and let
you know if I find a more elegant way for this.

--

ashgavs

unread,
Nov 29, 2011, 3:21:34 PM11/29/11
to PhiloGL
I cant put the app online because of where I work, but here is an
example of some code:

newCyl = new PhiloGL.O3D.Cylinder({
pickable: false,
nradial: 30,
nvertical: 30,
radius: 3.5,
height: 3.5,
topCap: false,
bottomCap: false,
textures: (id+1)+'.png',
uniforms: {
useReflection: false,
alpha: 1
}
});

//texCoords flip
for(var i = 0; i < newCyl.texCoords.length; i++){
if(i % 2 == 0)
newCyl.texCoords[i] *= -1;
}
//normals flip
for(var i = 0; i < newCyl.normals.length; i++){
newCyl.normals[i] *= -1;
}

Normals Flip makes it brighter on the inside of the cylinder, but does
not reverse the texture. Flipping the X texCoordinates does the
trick.

Here are my texture parameters:
parameters: [{
name: 'TEXTURE_MAG_FILTER',
value: 'LINEAR'
}, {
name: 'TEXTURE_MIN_FILTER',
value: 'LINEAR_MIPMAP_NEAREST',
generateMipmap: true
}]

Reply all
Reply to author
Forward
0 new messages