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 Chat / Best way to draw on a texture

Author
Message
Carharttguy
2
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 9th Jan 2018 15:01
Hello

I'm fairly new to terrain texturing. And now I need to "draw" textures onto each other to make paths on terrains and such.
While Googling around, I think I need "Texture splatting" as you can see in this image:
[img]https://en.wikipedia.org/wiki/Texture_splatting#/media/File:Texture_splatting.png[/img]

What is the easiest way to do this in AppGameKit? I guess it has something to do with shaders?

and an extra question: Is it in any way possible to also combine normal or diffuse maps? Ideally, grass should have another normal map than a path or sand.

Thank you for any help or leads!
Van B
Moderator
15
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jan 2018 15:25
Nah, no way to do texture splatting in AppGameKit - you really need fast and efficient access to vertex data and the render pipeline.

What I would suggest is you use a key image. Say you have 4 terrain textures, you could assign each one a channel in the key image. Sand might be the default textures, then RED for rock, GREEN for grass, BLUE for paths. Then, if you UV map the whole terrain that way, it can accept a colour multiplier image for better lighting, and the key texture would be scaled to the terrain - meaning that a 256x256 image can be used, or a 4096x4096 image without needing to adjust any code.

On the shader, you have the key image as a texture, and grab its colour value then each component can be used to distribute the texture on the terrain.

You could make a terrain painter in AppGameKit quite easily too - using a render target or memblock image to generate the key image, then you just need to work out the position that you clicked on the terrain, and convert that to the 0.0-1.0 UV coordinates.

Normal maps can't be combined with diffuse textures - we only ever get 4 channels maximum, so a diffuse needs 3, and a normal needs 3 - so the absolute minimum would be a diffuse and normal texture, no way to cheat with normal mapping. If you made a bump map shader, then you could keep the height texture inside the diffuse as the alpha channel. I have a program I use for UE4 that takes a diffuse and height map, generates a normal map with a roughness map in alpha, and stores the height in the diffuse alpha. This means 2 textures, but it's damn close to PBR - you can calculate ambient occlusion and specular using the roughness and height maps. If you just had the height map and diffuse, then that's just 1 texture, but you'd have to sample more than once to calculate the normal mapping in the shader... like sample the pixels at each side to calculate the axis slopes and apply that as a normal. It does help to be familiar with GL shaders and AppGameKit is a great way to get familiar. I think that learning some shader techniques would help you a lot to maximise what you can do with your terrains.... making your own terrain shader is a must IMO.
The code is dark and full of errors
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 9th Jan 2018 16:21 Edited at: 9th Jan 2018 16:28
?? HUH? Yes you can do texture splatting with AppGameKit .... it and its something that I was working on last night via a pixel shader.
https://en.wikipedia.org/wiki/Texture_splatting
Its just using the alpha channel (or R, G, or B channels) to blend multiple textures onto a surface as defined on the wiki page that he linked. Then you described the same thing.

I think you might have been thinking of volume mapping? Theres some common terminology there in splatting (3d volumes) vs just texture blending.

Anyway, using 2,3,4 colour textures and then a key kexture (like you said) is fairly common and can be done with a pixel shader in AGK.
janbo
9
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Jan 2018 17:09 Edited at: 9th Jan 2018 17:13
So we all made or will make the same shader ? -> ShaderPack - Terrain
I think we could add normalmapping to the terrain if we can combine the diffuse textures into one huge atlas texture and the same with the normal maps.
This would result in 2 atlas textures and a super/splat map... Aaaand we could do this twice, because we have 5 texture stages left, resulting in 8 different diffuse textures with their corresponding normalmap and some spare alpha channels we just wasted
Scraggle
VIP Member
15
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Jan 2018 17:41
Quote: "So we all made or will make the same shader ?"

Are you suggesting that everybody should hand over their money to you instead?
I respect your decision to try to make money from your work but suggesting that people don't write their own shaders because you have already done that and you want them to buy yours is like suggesting that we all stop writing games because there are already some games that we can buy.
janbo
9
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Jan 2018 18:52 Edited at: 9th Jan 2018 19:08
Uh I never said that ? did it sound like that ?
That wasn't my intention ...I'm sorry.
Is it because of the link to my thread ? I do that very often, not only to my threads but to everywhere in the WorldWideWeb to help others to find everything and understand what I try to say.
The "we" in my previous message suggests that I'm more than fine with it (happy )... actually I noticed the useful shader thread is pretty silent lately.
Need to post a 17th free shader in the useful shader thread... I could take them from the web, but I did not, Instead I promised to make them much better
I somehow slipped into making this shader pack... actually others talked about me making a shader pack, before i knew it
I like shaders and I like it when more people play with shaders...I tried to be a nice guy and wanted to communicate the very opposite of what you understood, I think
I also love all the nice words and attention from our awesome community, but who would not ...

Basically it was:
Hey there, I try the same, what a coincidence.
Here are my thought about creating such an effect !
Carharttguy
2
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 9th Jan 2018 19:16
Hi folks

Thanks for the answers!
@Van b and Bengismo: Thanks for the explanation and extra info. But I think I'm really not ready yet to write shaders now. I still have a lot to learn in AppGameKit itself!

@Janbo

I certainly did not perceive your reaction as 'gimme money'. It's really helpful, and now that I know that your shader pack will include a terrain shader in the future, your pack is an instabuy for me. Are future shaders always included? Or do they become part of a 'shader pack 2'?

Everything that speeds up the production of my product is a win for me, trying to fiddle with shaders myself would be an utter waste of time at this moment.
Van B
Moderator
15
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Jan 2018 19:31
@Bengismo - Ahh, I always refer to it as key'ing, I was thinking about decal mapping for some reason... been a long day (:
The code is dark and full of errors
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 9th Jan 2018 22:52 Edited at: 9th Jan 2018 23:02
Van B wrote: "@Bengismo - Ahh, I always refer to it as key'ing, I was thinking about decal mapping for some reason... been a long day (:"


No worries! Your post was actually very good and useful!

I thought you described the texture blending operation perfectly and made sense so im glad you posted the response you did! Its was a good description of the texture blending that can be achieved on a surface. Like you said...its possible to make an editor in AppGameKit if wanted... to control which texture is most visible at what point on the map by editing the keying texture. Your answer regarding normal mapping was spot on too (we only have so many channels and texture stages). So...Thanks for the info!

janbo wrote: "
Hey there, I try the same, what a coincidence.
Here are my thought about creating such an effect !"

i appreitiated your post too to be honest, Ive been playing with AppGameKit and terrain mapping for a few days as well as trying shaders but mainly just so I can fully understand it all and get an idea of how to fully utilize it. Its a really big subject (terrain shading) with lots of different methods used by different game engines. There are loads of possibilities and potential solutions. I've been contemplating ideas of additional vertex attributes, vertex colours, keying textures, alpha blending etc.... Its amazing what you can do with pixel shaders and vertex shaders. Thanks for the hard work producing pixel shaders for AGK. Your idea of the terrain megashader sounds awesome.

We will not necessarily end up with the same thing though! (different shaders for different problems ...right) Im sure your terrain shader will be a lot more capable then my 3 texture simple solution. Its up to everyone to choose what they want to use.

Anyway, a simple pixel shader for Terrain would be great. Perhaps more importantly is a good description and example code of how to use it for people who dont know about shaders or 3D rendering is invaluable.
Xaby
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 9th Jan 2018 22:56
So could we archive "Splatoon" like color on the floor with this solution? Or like in Portal 2 the gels?
MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 9th Jan 2018 23:33 Edited at: 9th Jan 2018 23:35
Just a little test of 3D editor (and beginning of terrain editor) without any shader ("simple texturing method" only with memblocks :p)

Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 9th Jan 2018 23:41
Looks good Mike! Good to see it up and working.

No shader needed...just a decent size main texture. How many pixels (x,y) is the image your using for that?
janbo
9
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Jan 2018 23:49 Edited at: 9th Jan 2018 23:54
Thanks guys, yes you get free updates, I just made a Glass, colour grading and glow effect for the latest version.
I have read that quite often, that shaders are to hard to understand, but if you get the hang of it, it is very powerful, so I want to encourage you guys to dive into the realm of shaders.

@Xaby that's a neat idea. I think they use a deferred render pipeline but it should be pretty possible to achieve this effect with splatoon maps I also have object texture drawing code laying around somewhere... You want to make a Splatoon game ?
I'll try to find the texture drawing code...

@MikeMax nice, how are you creating the white preview circle on the terrain ? Is it within the terrain shader or some sort of projection with an external object ?
MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 9th Jan 2018 23:54
for textures : 4x4 sectors with 1024x1024 texture for each so .. 4096x4096 in total. but could be infinite (until GPU max memory is reached lol)

This is far to be perfect and i will use blendmap shaders with also memblocks writes depending on needed effects.

heightmap is only 256x256.

janbo
9
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Jan 2018 23:57 Edited at: 10th Jan 2018 00:07
Quote: "4x4 sectors with 1024x1024 texture for each so"

That's what I was talking about...now I know it's working
Still not sure how you want to get infinite textures as you need a blend map channel for every texture in the splat map.
So the bottleneck are the channels in the splat maps.
MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 10th Jan 2018 00:14 Edited at: 10th Jan 2018 00:48
janbo wrote: "@MikeMax nice, how are you creating the white circle on the terrain ? Is it within the terrain shader or some sort of projection with an external object ?
"


All is done by memblocks with SetObject(Mesh)Image on the terrain at each sync() (it's pretty fast despite what I would have thought) . I'm using a png "shape" image as a mask (here is a simple RGB black circle for this brush but could be a square, a star or anything else). Then for the selected brush, i read all the black pixels to define the shape to "write" on the terrain. If it's for terrain modeling, i simply average original RGB terrain texture with white over the selected shape (circle in this case) and replace the terrain texture with it until the next frame. For terrain painting, it's the same thing with terrain texture and selected brush texture. I simply temporary resize the shape image to reduce/increase brush size

For the terrain modeling, i also use memblocks to play with the shape and the heightmap image (which actually needs to be saved on disk .. that's why i asked Paul to also allow the use of an heightmap imageID already in memory for better performance).

There is no shader actually janbo ! Sorry (except for the terrain texture which uses a "classic" detail map for aesthetic reasons only ... no relation with texturing or modeling basic technique i used here)
janbo
9
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 10th Jan 2018 13:08 Edited at: 10th Jan 2018 13:10
I see, looks good still and you can use infinite textures indeed
Rick Nasher
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 10th Jan 2018 16:13 Edited at: 10th Jan 2018 16:19
@MikeMax:

That's awesome. I was under the impression it wouldn't be possible to modify terrain on the fly in AGK.

I'd like to use this for creating impact craters after launching a grenade like I was doing on Blitz3d terrains


Could you please post a bit of code as an example of how to achieve terrain modification?
MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 10th Jan 2018 22:12 Edited at: 10th Jan 2018 22:14
Rick, I only modify the original heightmap greyscale (with memblocks) and reload the terrain with the CreateObjectFromHeightMap() at each frame

The only particular thing to know is about image memblocks => how to get (or set) a specific pixel of an image memblock.

as a reminder :

Assuming :


Read a Pixel RGBA from x,y position of the image defined by width and height :


Write a Pixel RGBA to x,y position of the image defined by width and height :



After memblock modifications, you have obviously to do this to "update" the Terrain :




With a 3D position on the terrain you can easily determine HeightMap x,y position for your impact craters :

Rick Nasher
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 11th Jan 2018 17:40
Quote: "Rick, I only modify the original heightmap greyscale (with memblocks) and reload the terrain with the CreateObjectFromHeightMap() at each frame "


Many thanks, very helpful. I had no idea that just reloading the map every time would actually work for this.
I would expect to see a severe slowdown like that, no real-time modification possible, so I didn't even try, but your video showed otherwise.

Now I understand your remarks in the convo above that you requested for Paul to make it possible to modify the map directly in memory, which I before asked also as a feature request.







MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 11th Jan 2018 21:30
Quote: "Now I understand your remarks in the convo above that you requested for Paul to make it possible to modify the map directly in memory, which I before asked also as a feature request."


Yes. I'm working on a SSD Disk which helps when rewriting heightmap file. Working directly in memory will help a lot and improve performances.
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 11th Jan 2018 22:19 Edited at: 11th Jan 2018 22:44
It is possible to work directly in memory on terrain though. You can use a Mesh memblock. You can edit the y values in the mesh and then update the mesh (without any writes to disk). Its just manipulation of float values. It does involve generating new normals too if you want it to look "correct" but i've got a good function for that and theres plenty on the web to use too.

The terrain mesh...(one that you create from scratch or one that is loaded and generated from an image)...is just a big list of X,Y,Z values. (Each vertex contains x,y,z,normal and texture coordinates) The Y values are the heights

You can apply any float values you like to the heights. You can even animate the mesh in real time by updating the mesh every frame...lets say with a sin(t# ) distance function



If I had a screen recorder id show you it rippling! (Oooh err?? )

Theres nothing wrong with editing an image then recreating the meshmodel from that, but as Mike said it involves an image modification and a disk write (saving the image) then the process of creating a mesh from the image on the disk which is quite a slow/round about way of doing the job. If it works quick enough though, thats fine.
MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 11th Jan 2018 22:45
The problem with direct modification of the mesh is in mathematics. You have to calculate all the deformations yourself instead of letting the heightmap function do it. That's why i prefer re-using the base heightmap file with simple visual modifications
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 11th Jan 2018 23:01 Edited at: 11th Jan 2018 23:05
I can understand that the 3D maths puts people off. i just wanted to point out that the facilities are all there in AppGameKit to do this.

I can see how people can get very comfortable with the idea of an image being EASY to work on as its just X,Y with RGB data in each X,Y slot. 3D is VERY similar but it has X,Y,Z....

A simplistic example would be:
You want to make a crater, so you find the vertex that is closest to where you want a crater and you simply lower its Y value.

For a much "smoother" crater.... you itterate through the vertices....work out how far the vertex is from your NEW 'crater' position ....then if the vertex is inside the crater (distance# < CraterWidth) then take the existing y position and lower its value. (ideally you lower its value a lot in the middle of the crater and little or nothing at the edge.

Then you update the mesh: SetObjectMeshFromMemblock()

The only other thing to keep in mind is Normals but these can be filled with calculated values easily too.


Anyway...im sorry....ive sort of derrailed this thread as it was about drawing on terrains...not modifying the shape of them. Plus you would only then need a way of saving the new mesh too for your program but thats not hard either.

Great work...the editor looks brilliant.
MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 11th Jan 2018 23:25
Yes AppGameKit allows a lot of things Everything is possible with meshes and vertices directly. Sometimes we have no choice. But heightmaps are especially suitable for terrain generation so ... why don't use them ?

Quote: "Anyway...im sorry....ive sort of derrailed this thread as it was about drawing on terrains...not modifying the shape of them. "


Sure, but terrain/meshes modifications is something very interesting

Thanks for your comments

Rick Nasher
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 12th Jan 2018 15:51 Edited at: 12th Jan 2018 15:55
To derail it even further. lol , in blitz3d I'd used this to do the crater stuff.



Of course there's no such thing in AppGameKit as the ModifyTerrain(terrain,grid_x,grid_z,height#[,realtime]) command (and a nice Plot(x,y) for that matter ) and I'm sure can be worked around, but I do hope Paul will include something like this a new AppGameKit update for would save us lots of hassle, also for writing a terrain editor that would easily allow writing back the modified heightmap back to disk.
Xaby
FPSC Reloaded TGC Backer
11
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 12th Jan 2018 22:43
@janbo, at Splatoon

I am thinking of a kind like contest, like the mini-game-examples and templates, where we could focus on specific game mechanics, effects from known games

like:

- Super Mario 64 Movement
- Minecraft blockbuilding
- Splatoon Ink
- Assassins Creed climbing
- Zelda cooking
- Portal portals
- Half Life 2 physics (gravity) gun
...

something like that
MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 13th Jan 2018 10:30
Quote: "Of course there's no such thing in AppGameKit as the ModifyTerrain(terrain,grid_x,grid_z,height#[,realtime]) command (and a nice Plot(x,y) for that matter ) and I'm sure can be worked around, but I do hope Paul will include something like this a new AppGameKit update for would save us lots of hassle, also for writing a terrain editor that would easily allow writing back the modified heightmap back to disk."


You can easily do something like that using heightmap memblock
Rick Nasher
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 13th Jan 2018 12:18
Appears so. It doesn't currently have my focus as I'm too busy with my framework (and real job/life/gf etc lol ), but when finished I wil try to do a conversion and post it for might be handy for anybody who needs such a routine.



Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 14th Jan 2018 20:11 Edited at: 14th Jan 2018 20:13
Rick Nasher wrote: "Of course there's no such thing in AppGameKit as the ModifyTerrain(terrain,grid_x,grid_z,height#[,realtime]) command (and a nice Plot(x,y) for that matter ) and I'm sure can be worked around, but I do hope Paul will include something like this a new AppGameKit update for would save us lots of hassle, also for writing a terrain editor that would easily allow writing back the modified heightmap back to disk.
"


Here you go...



You have to update the Mesh from the memblock after using it but thats easy.
Rick Nasher
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 15th Jan 2018 22:16
@Bengismo

Wow that's pretty cool thanks. This will really come in handy.
Carharttguy
2
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 17th Jan 2018 20:52
Thanks to everybody in this thread, It helped me a lot.
But I still have 1 main question after seeing the nice video of MikeMax:

Let's say I have a 256x256 heightmap. And let's assume 1pixel is 1 meter. How big is your texture?
Lets say I want to draw this texture as grass: http://texturelib.com/Textures/grass/grass/grass_grass_0118_02_preview.jpg

That is a 600x600 grass texture, let's say it covers 1 by 1 meter. So the texture is 600 times larger than the heightmap?
That's 153600 x 153600 pixels? That would be several gigabytes of data for the texture on the heightmap.

I must make some mistake here, how is MikeMax getting the details for those cobble stones in his editor movie?

I'm reading he's using a 4096x4096 texture. But 4096/265(heightmap) is only 16x16 pixels per 1 heightmap pixels. But those cobblestones are WAAY more than 16x16 pixels?

I'm kind of lost there :') If someone can enlight me, I would be so happy
puzzler2018
User Offline
Joined: 8th Oct 2017
Location:
Posted: 17th Jan 2018 20:57
Looks good doesnt it - ill assume that the map has some kind of array with numbers - 1 = rough terrain, 2= pathways, 3= cobble texture,4=water... etc etc

Only MikeMax can offer how he did it on the vid but thats how i would
puzzler2018
User Offline
Joined: 8th Oct 2017
Location:
Posted: 17th Jan 2018 21:11 Edited at: 17th Jan 2018 21:13
I created a texture function which will create them if your interested.Its in my 3D bag of new things , use the function to give some detail to a certain coloured texture

https://forum.thegamecreators.com/thread/221110

Although it just textures "green" say, it doesnt put other details in
puzzler2018
User Offline
Joined: 8th Oct 2017
Location:
Posted: 17th Jan 2018 21:31
We all have think of distance on a map too. we dont want to texture the whole map - cause this will degrade performance.

So if the viewing distance when sat a character on the map is 2 feet in front, then dont apply any objects /textures /or what ever within that 2 feet on distance.

and if move character then programmatically bring in the details- otherwise make it look like fog in the distance.

Performance tip
MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 17th Jan 2018 23:29
.
Quote: "Let's say I have a 256x256 heightmap. And let's assume 1pixel is 1 meter. How big is your texture?
"


The "secret" resides in Splitting the terrain. With a split number of 4 (4x4), i can assign 16 different textures of 4096x4096 each (and not one texture of 4096x4096 on the whole terrain).

indeed, the size of the texture define the details of the brush you will use (1pix of your brush is 1pix of your terrain texture) ... so, to have a correct proportion of the brush, you must either increase the texture size of the terrain's parts or resize the grass to a smaller texture size.
And you can blend different detail texture over the terrain's parts for better results
Carharttguy
2
Years of Service
User Offline
Joined: 8th Jul 2016
Location: Belgium
Posted: 18th Jan 2018 15:21 Edited at: 18th Jan 2018 15:37
Aha, so you're using 64x64 for 1 heightmap pixel. That's quite a nice result!

Little side question, how do you load a texture on a individual part of the heightmapobject? The CreateObjectFromHeightmap does only return 1 object isn't it?
MikeMax
AGK Academic Backer
6
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 18th Jan 2018 18:54
When you split the terrain in the command .. it creates submeshes...

Here is the original thread which talk about it with source code and a fix to make the submeshes textures to fit correctly :

https://forum.thegamecreators.com/thread/221265
fubarpk
AGK Developer
Gold Codemaster
13
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 4th Apr 2018 03:55 Edited at: 12th Apr 2018 22:15
@Bengismo

I am trying to understand what the variables in your modifyterrain function are about

I assumed gridx and gridz was the size of the array and x and y were your coordinates
in the world ie Get3DVectorXFromScreen(pointer_x,pointer_y) but it doesn't seem to
modify the terrain I also call SetObjectMeshFromMemblock( TerrainObjectID,2048 + (1024*xPixel#), TerrainMemblock)
ModifyTerrain (TerrainMemblock,2048,1024,10,unit_x#,unit_z#)

full code below if anyone can help


I have got the painting the texture working and updating just not modifying the mesh memblock with your
function. Thanks for any help anyone can give
fubar
fubarpk
AGK Developer
Gold Codemaster
13
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 5th Apr 2018 04:18 Edited at: 12th Apr 2018 22:16
I partially worked out my problem now the problem is how do I make one memblock store a mesh with all of its meshes

I started writing the following but it don't work as of yet


The plan is to create a memblock that I can then create the object mesh from if at all possible
fubar
fubarpk
AGK Developer
Gold Codemaster
13
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 10th Apr 2018 16:17 Edited at: 12th Apr 2018 22:16
The following creates a terrain mesh and allows modifying on the fly

It works much better if you modify the grayscale texture and save and load that and recreate the mesh but this
is a different way of modifying a mesh
fubar
Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 10th Apr 2018 16:56 Edited at: 10th Apr 2018 16:57
fubarpk wrote: "@Bengismo

I am trying to understand what the variables in your modifyterrain function are about ModifyTerrain (TerrainMemblock,2048,1024,10,unit_x#,unit_z#)

I assumed gridx and gridz was the size of the array and x and y were your coordinates
in the world ie Get3DVectorXFromScreen(pointer_x,pointer_y) but it doesn't seem to
modify the terrain
"


Ive only just seen this as I was away on holiday for the last week.

ModifyTerrain (msblk as integer,grid_x,grid_z,heightA as float,x as integer,y as integer)

msblk: is the HeightmapMeshMemBlock you want to edit
grid_x: is the vertex coordinate from the left hand side you want to edit
grid_z: is the vertex coordinate from the back you want to edit
x: is the width of the image you used to create the HeightmapMesh
y: is the height of the image you used to create the HeightmapMesh (You dont actually need that variable at all)

You had x mixed with grid_x and y mixed with grid_z so it wont have worked for you. In any case, I think you managed to get there in the end. Great work!


Modifying the heightmap mesh in the memblock isnt hard. Mapping the raycast to the correct vertex to edit is harder but isnt too bad. The really hard bit is setting new normals that are correct once you have set new heights in your mesh.

Editing the heightmap mesh by changing the image and relaoding it also works fine and I think mikemax showed that that was fast enough for editing. Its a much easier solution. Editing the mesh directly isnt hard though. 2 different solutions to one problem and both work.
george++
11
Years of Service
User Offline
Joined: 13th May 2007
Location: Hellas
Posted: 10th Apr 2018 17:22 Edited at: 10th Apr 2018 17:23
Quote: "Are you suggesting that everybody should hand over their money to you instead?"

Excuse me for refreshing this post but I feel that it is unfair for janbo. Although he is selling shaders, he always gives us tips for any related issue and he always gives us solutions without money.
https://forum.thegamecreators.com/thread/214598?page=5
As far as I know, many of us are doing this for hobby and we are unable to face all possible issues when developing a game. Personally I am very happy when I can find a solution (for example the janbo's shaders) for a reasonable amount of money.
PHeMoX
User Offline
Joined: 9th Jan 2018
Location:
Posted: 11th Apr 2018 13:50
I think most people will understand a little bit of promotion of the shader pack can hardly do anyone any harm. I don't feel any information is being withheld just to sell a few more shader packs anyway. This here is a good community, so I've got to agree with George++ here.

Login to post a reply

Server time is: 2018-07-23 07:12:41
Your offset time is: 2018-07-23 07:12:41