Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / 3D Textured Tiled Offset scale and Angle

Author
Message
OminusPrime
8
Years of Service
User Offline
Joined: 30th Jun 2015
Location:
Posted: 22nd Nov 2015 20:14
Hi In the past ive programmed OpenGL and i wanted to Know if AGK2 can control the Offset Scale and Angle of the Textures applied to 3D objects. this should be possible since APG also uses OpenGL
Ive looked over the Image UV commands for sprites but they don't work with 3D objects.

For example if i made a floor and i had a sprite with a couple of floor tiles on it.
now i would like to repeat this across the surface . all attempts so far result in the single tile image stretched to fill the entire floor. Horrible.
Ive used MODO to artificially tile the floor object using its UV tools it works great within Modo but when imported to AGK2 it shows the single tile in one corner and the remaining floor is UN-textured. it doesn't repeat[img]null[/img]

Thks in Advance
haliop_New
User Banned
Posted: 23rd Nov 2015 05:39
at AppGameKit current stage you cant change the UV's of a 3d objects but we requested it
so hopefully it will come one day
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 23rd Nov 2015 11:34
Hi
In modo, what is the format ?
For a simple floor/ground (a basic plane), you can use blender, import and export your model from blender to .dae (collada).
The collada format (dae) can export the uvmapping for your model, perhap's in modo you can export in collada (.dae).
http://www.dracaena-studio.com
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 23rd Nov 2015 11:40
there is a memblock command to change the texture coords.
SetMeshMemblockVertexUV
AGK (Steam) V2.0.15c : Windows 10 Pro 64 Bit : AMD (15.201.1151.0) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
haliop_New
User Banned
Posted: 23rd Nov 2015 13:10
WOOT ?? I did not know of such command !
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 23rd Nov 2015 21:49
If you just want to repeat the image you should be able to use SetImageWrapU and SetImageWrapV, but on mobile devices the image must be a power of 2 in size, e.g. 32, 64, 128, etc
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 8th Jan 2016 18:39
Hi,
I have applied 64x64 png textures to 3D boxes (walls) created with CreateObjectBox(), and then I have used the SetImageWrapU() and SetImageWrapV() commands, but unfortunately the images are not repeated correctly and, especially when the walls are long, the images are rendered in a blurry way.

I have attached the results, as you can see they are not acceptable.
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 8th Jan 2016 18:41
sorry, I have missed to upload the file.

Attachments

Login to view attachments
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 8th Jan 2016 18:49
and this is the result using an image created dynamically from a memblock by repeating manually the 64x64 images a number of times proportional to the max length of the sides. The result is not perfect, because in the shorter sides the image is streched.
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 8th Jan 2016 18:50
the image...

Attachments

Login to view attachments
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 9th Jan 2016 17:53
do you an image in which you're repeating your texture ?
Your image size must be too big, isn't ?

I think you should use a shader for your texture, it's more easy to control the x/y repetitions.
In the vertexShader, you have just to change uvBounds0 :


For the fragment shader, you can use a very simple code to test, like that :


For this shader, it doesn't use the light/sun or ambient, but there are some example in the shader threads .

I hope this shader can help.
AGK2 tier1 - http://www.dracaena-studio.com
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 10th Jan 2016 18:11
Thanks, I have tried your shader but they give me a bunch of error during loading, see attachment. Have you tested your code with AGKv2, or have they been used in AGKv1 projects only? Maybe there are some changes in AGKv2. Waiting for some how-to on shaders on AGK.

Attachments

Login to view attachments
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 11th Jan 2016 07:58
Hi

To use this shader, you must use a new version of AGK2 (at least the 2.014, but you should use the 2.016 ). This shader doesn't work with agk1.
WIth agk2.016, it works perfectly (I have tested it on windows8 ).

Don't forget to use the wrap for image :
AGK2 tier1 - http://www.dracaena-studio.com
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 11th Jan 2016 10:26
I am using AppGameKit 2.016 (Steam version) on Windows 7. I have the same bunch of errors. The difference is that I am using Windows 7 on Dell laptop (with an integrated Intel graphic adapter).

wall.vs


wall.ps
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 11th Jan 2016 12:01
Hi

Could you try to replace :


by :


And tell me if it works
AGK2 tier1 - http://www.dracaena-studio.com
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Jan 2016 12:34
One thing that can help with UV mapping and shaders, is just don't UV map... especially with a floor object with a repeating texture. I mean, why not use the X/Z position in the shader to provide the UV coordinate. I've used this with terrains in the past and it can help - for example I set the UV coordinates of the terrain vertices to suit an image that covers the whole map, then use the XZ position for the actual terrain detail textures while the standard UV coordinates relate to the overlay image. This also saves you having to have another set of UV cords when you want a repeating detail texture over say, a baked ground texture.
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 17th Jan 2016 09:41
Thanks Blendman, now it works. Sorry, I am learning now something about GLSL, so I am beginning to understand syntax and semantics of the various types, operations, etc.
The problems is that walls are not cube, so the depth, width and height are generally very different, and the textures must be repeated by a different number of times depending on the face they are applied to.
If, for example, one texture is repeated 8 times horizontally and 10 times vertically, this behaviour will be applied to all faces, both, for example, 10x1 (top of a wall or tighter side of a wall) and to 10x10. In the dimension where the size is 1, the textures will be repeated 8 times and 10 times, and the result will be very unpleasant (very stretched tiles).
I should be able to set different repetition values depending on the face I am applying the texture to. The problem that, with cube and boxes, the textures are applied in the same way onto each face.
Any suggestions?
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 17th Jan 2016 14:28
MarcoBruti :
The better solution would be to create some assets (wall, ground...) with UVmapping in a modeler software (blender for example), and export them for your game.

If not, the solution would be to get the dimension of each face and apply a specific uvvariying (uvVarying = uv * uvBounds0.xy * 10 + uvBounds0.zw * 8 in including this dimension (or automatic detecting the dimension of each face where you apply your shader). But I don't know how you can do that with a shader ^^.
AGK2 tier1 - http://www.dracaena-studio.com
MarcoBruti
12
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 23rd Jan 2016 18:27 Edited at: 23rd Jan 2016 22:28
@Van B
Could you share a working example of what you have described?
I am trying to use the same shader kindly supplied by Blendman, to create a tiled terrain using a plane. But it does not work. Would you pls share the shader you have used for the terrain?
@Blendman if you have something similar, please share too.

[EDIT] Sorry, it was a mistake of mine, I have forgotten to use setImageWrapU() and setImageWrapV(). Anyway, if you have some shader to share...you're welcome.

Login to post a reply

Server time is: 2024-03-29 10:24:16
Your offset time is: 2024-03-29 10:24:16