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.

DarkBASIC Professional Discussion / Painting terrain when texture is scaled

Author
Message
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 15th Oct 2012 12:24
I've learned how to paint on terrain. You gather the image width and height and scale it to the uv coords with the pick commands and involve memblocks to edit the image your drawing on... my question is, the uv data changes if u scale the texture, so how do I increase the texture scale of either one of the textures... (the base and drawing image) without increasing the uv scale.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 15th Oct 2012 23:13
okay a better question then - since the uv data is scaled twice its size (going from 0 to 1 twice [if the object texture is scaled using the scale obj. tex. command]) how do I paint the texture as if it wasn't scaled...

what I am trying to do is paint various textures on a terrain - the user can select the image to be painted - I've painted on objects in the fashion that this would be done... but the things I can't gather how to do off of my head are:

1) make a temp copy of the texture image (painted over terrain planes) so that painting doesn't occur over all terrain items with the same image on it.

2) Scaling the image on the terrain planes before painting (and painting another image on the terrain which the user chooses.)

3) scaling the paint image as you do the base texture

I am lost as to how you scale the first image and the second. Points and tips help, I don't need code - I just need to understand methodology and operation.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Kezzla
17
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 16th Oct 2012 09:04
when I do stuff like this I tend to get the object size(plane in my case)
then divide it by the image width or height pixels and then multiply by the position you want to paint

1: I would have a default blank image setup in you media folder that you can load and then save as the new texture, then paint from there.

2: not sure what you mean by this, do you want to have a looping texture as the background and then paint an image onto it like some kind of decal system? If it's decals, I use textured planes as decal overlays.

3: i would use relative scales for each image, just keep track of their x and y lengths and convert between them as you switch from one to the other.

Is that what you mean by scale image?

do you mean the actual image size? or the texture looping scale on the object?

Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 16th Oct 2012 09:25
Okay lol - say you have an object that is 256 wide and deep... your image is 512 wide and deep. Getting the position isn't the issue, its how to scale the texture on the object AND return the correct painting location.

I know how to use the uv coords and image size/object size and pick commands to return the correct location on the object that you want to paint - its the change in UV coords that occurs if you (((Scale object Texture Obj, 20,20))) that I dont understand... perhaps it would be better if you post an example.

I have 12X12 objects (planes) that all have the same texture on it. I want to paint on the terrain (or plane grid) various textures - as the user will be raising or lowering the terrain and may wish to paint snow, rocks, grass, sand and so on... I need to scale both images as the user pleases and make temp images from the base image (the default image of grass loaded on the terrain when the user starts this app.), as I don't want to all at once paint on every plane...

I dont know how to allow painting on a scaled texture. Try it for yourself... set the texture of a plane to twice its size. (Scale Object Texture ((Object Number)), 2, 2)) Then try to paint on it as you would an unscaled texture... you get 4 drawing locations all painting the same design as you would if you hadn't scaled it.)

I am sooooo confused

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 17th Oct 2012 05:44 Edited at: 17th Oct 2012 08:12
okay how about this: Is there a way that I can scale an image using memblocks... like make it appear scaled but not actually scale it via object texture scaling... just make the image bigger.

EDIT - Here is a visualization of what I am trying to do.



The black boxes divided by the green lines = object bounds
the red lines within the object bounds in the upper right = the scale of the texture on the object.

If you scale an objects texture to twice its size, the uv data goes as such:

U = 0.0 to 1.0 (twice) on x axis
V = 0.0 to 1.0 (twice) on z axis

THAT SAID... lets say I have an image of equal width and height, lets say 100x100 pixels. If the uv data is scaled, when writing/drawing on the textures image how do I report the correct drawing location?

On an unscaled image, if I draw in the center of the object, the dot appears at 50, 50. But if I scale the image to twice the size, the dot appears in fourths (in the image, in the center of the red lines)

How do I fix this?

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 17th Oct 2012 07:38
You can set different uv texture scales on the same object like you would for a base and detail texture,then either use the blend mapping command or a shader to blend the images.but you would need a separate image for the painting for each object.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 17th Oct 2012 07:42
Hi paul... you and I were msn'ing a while ago concerning this project - care to msn again... I have had much progress

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
paul5147
20
Years of Service
User Offline
Joined: 11th Jan 2006
Location: Hot & Sunny
Posted: 18th Oct 2012 21:27
Hi Daryn,send me an email with what you have so far and ill take a look when i get a bit of free time.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 20th Oct 2012 01:58
okay so here is what i've decided to do

1) Make the base texture / load the base texture and scale it to my liking

2) Make a memblock (not make mem. from image) and set all color and alpha to zero. this is the alpha map for the next image. Convert to image

3) Make / load third image for 2nd stage on object.

4) Scale the third image in memblock commands, not texture commands.

5) draw to the alpha map and report its values to the third image.

this way the first image can be scaled, the alpha image can be reset for new textures and the other textures can be scaled as well. I am having trouble with the blending... can anyone take a look


Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 22nd Oct 2012 23:03
anyone ?

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.

Login to post a reply

Server time is: 2026-07-08 06:45:55
Your offset time is: 2026-07-08 06:45:55