texture coords

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
pond
Posts: 25
Joined: Mon Jul 11, 2011 5:54 am

texture coords

Post 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
Attachments
texturemapping.zgeproj
(363.24 KiB) Downloaded 570 times
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hmm,

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

K
pond
Posts: 25
Joined: Mon Jul 11, 2011 5:54 am

Post 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
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Attachments
Scale.zgeproj
(1.47 KiB) Downloaded 594 times
pond
Posts: 25
Joined: Mon Jul 11, 2011 5:54 am

Post 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 :)
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
pond
Posts: 25
Joined: Mon Jul 11, 2011 5:54 am

Post by pond »

um, any tips on where to start with opengl?
Last edited by pond on Tue Jul 19, 2011 11:24 am, edited 1 time in total.
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
pond
Posts: 25
Joined: Mon Jul 11, 2011 5:54 am

Post 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?
User avatar
Kjell
Posts: 1924
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Post Reply