Page 1 of 1

texture coords

Posted: Sat Jul 16, 2011 3:05 am
by pond
hello

when using "generated" TexCoords in a MaterialTexture, is it possible to have it map the sides of a mesh, the way it does in "ModelDefined" mode?

reason being, i want separate control of the mesh scale and the texture scale, so the texture isnt squashed with the mesh, but rather the mesh surfaces are windows over the texture, if that makes sense. (it works this way in "generated" mode, but the sides are looking like licorice allsorts )

thanks

Posted: Sat Jul 16, 2011 9:31 am
by Kjell
Hmm,

You can still control the texture scale in ModelDefined mode as well :wink:

K

Posted: Sat Jul 16, 2011 10:26 am
by pond
yes but the difference being a change in meshtransform.scale will squash or stretch the texture, whereas in generated mode it will crop it, which is what i would prefer it to do

Posted: Sat Jul 16, 2011 10:47 am
by Kjell
:)

You can counter that by setting the Texture Scale. It's a little more work then simply using generated texture coordinates, but it's the easiest way to prevent the "licorice" sides. Attached is a example ..

K

Posted: Sat Jul 16, 2011 1:25 pm
by pond
:) thats what i thought too, but because i was scaling XYZ independently and also rotating the texture it didnt hold up...
is this something i would be better off learning how to do using shaders?

this is my first foray into 3d (and coding for that matter) so i am kind of prioritizing what i learn by what obstacle ive hit, hehe. i appreciate all your help :)

Posted: Sat Jul 16, 2011 1:46 pm
by Kjell
Ah,

Ok, I think I understand what effect you're after now .. like this right?

http://www.youtube.com/watch?v=iGxdV2SuyJE

You're going to need 3D texture coordinates to do that. Unfortunately ZGE only supports 2D texture coordinates ( at the moment ), even though the TexCoord property on MeshExpression is actually a Vector3f. So, either if your mesh is very simply, you can generate it with the proper texture coordinates every frame, or as you said use Shaders / OpenGL calls.

K

Posted: Sat Jul 16, 2011 2:19 pm
by pond
um, any tips on where to start with opengl?

Posted: Sat Jul 16, 2011 4:41 pm
by Kjell
Hi pond,

If you haven't watched this video already, start here ..

http://www.youtube.com/watch?v=ZVWTL7S0o0Y

Then pretty much all the information you need is in the OpenGL manual and the OpenGL thread on our own forum :)

K

Posted: Tue Jul 19, 2011 11:27 am
by pond
okay thanks. should i be looking to call opengl just for the material, or will i need to recreate the mesh in a shader?

Posted: Tue Jul 19, 2011 2:26 pm
by Kjell
Hi pond,

Depends on your preference. If you take the OpenGL-route, you can't use the Mesh component. If you take the Shader-route you can use the Mesh, but you still can't use the Texture Coordinates of the Mesh.

Personally I'd make that decision based on whether you want to support older hardware ( that doesn't support Shaders ) or not.

K