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 / Has anyone gotten SetMeshMemblockVertexColor working?

Author
Message
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 28th Jan 2018 16:51
Has anyone manged to get this command, or the getmeshmemblockvertexcolor command working? I;ve tried with models in .X, .lwo, 3DS, OBJ and even with stuff created in AppGameKit - none of them have vertex colors set. I can adjust heights and coords no problem - but everything I've tried says no color data exists.

Is this only for shaders???
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 28th Jan 2018 17:57 Edited at: 28th Jan 2018 18:23
Well....Im assuming im allowed to post on your thread....

Like you have said...it depends on your model having vertex color data saved in them which many dont. Stock 3D items in AppGameKit normally have position, normal and UV's only

The stock rendering system will render vertex colours if they are in the vertices for the model like below....



The vertex colour is used if there are no tex coords (like on the right) and if there are some texture coords and a texture is set then it typically just multiplies the colour that is in the texture (like on the left.

Obviously if you create from a memblock with attributes correctly set then it is used and SetMeshMemblockVertexColor() works fine. Vertex color can be used in shaders too of course provided the color is set in each vertex. Most models simply dont require both texture coordinates and vertex colour as its duplicated information.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 28th Jan 2018 20:26
Lol.......ah, go on then.

What was the model format that you used that stored colour data? I can't find a single one that works.

Essentially what I am trying to do is modify the colours of the vertices of an object generated in agk using the height map commands. May not be possible then, without a shader. I've managed to modify the shader from the terrain demo in the folder and it's kind of doing It, but it's producing some odd results.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 31st Jan 2018 23:02
So it was a tak, but I figured there were two options:

1) Create a memblock and then "build" a duplicate of the mesh generated by AppGameKit, filling in the vertex color points so that it could be then used to create a new object where vertice colours could be changed
2) Build a shader to make it do the work

So (having zero experience with shaders) I looked in the demo folder, found some decent tutorials online and came up with something that works quite well. This is simple - all it does is take the vertex height of each and then blend 3 textures into it based around some set parameters (which can be changed - Iplan to have these generated by a planet seed).

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 31st Jan 2018 23:04
Interesting book
http://thebookofshaders.com/
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 31st Jan 2018 23:06
The video shows it creating a water effect automatically in the second half.....I reckon this could be modified and used to greate effect for a Civ style landscale...maybe I'll revisit that project one day.



Next up - adding better light and looking at wetness effects.
puzzler2018
User Banned
Posted: 31st Jan 2018 23:09
Perfect example of a map that would roll when comes into play... Just a mind set of needing rolling maps in apps

Ill get into Shaders later in the year - but this is prime example of designers preferring to use rolling maps

Thanks for that.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 31st Jan 2018 23:14
Thanks for the link -I'll check it out.

Yip, I;ve always avoided shaders like the plague to be honest, having no C experience. It took some squinting, but I'm getting there. The hardest part was passing the vertex height to the fragment shader and working out the blend ratios.

This would work totally fine for a rolling map though - it could in toery be as long as you wanted. I aim to generate images then use them as hight maps....will see how that works. Right now I REALLY wish AppGameKit had threading.....
puzzler2018
User Banned
Posted: 31st Jan 2018 23:14
that video is using perlin noise rolling maps...Yippeee
puzzler2018
User Banned
Posted: 31st Jan 2018 23:17
id doesnt have threading cause we gotta make games for mobile - they dont have that so will be slow on them and super fast on pc

unless they could and have a function like

SetThreading(on),but for the time being its time to think
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 1st Feb 2018 20:30 Edited at: 1st Feb 2018 20:32
To answer the question, .x files can store vertex colours but most applications dont export them without a bit of extra work. Blender will but you have to manually put them in
.Obj files can also store them but AppGameKit wont load them - or at least it didnt when I tried.
Ive a custom exporter for MS3D that will do it too.
Also 3DS max files can store vertex colour

You didnt really want any of those though. Like you said, manually adding vertex colours int the membock is possible. Considering what your doing theres no need for vertex colours at all. A shader IS a much better way of doing it.

You do know there is a pair of shaders in the terrain project that ships with AppGameKit for doing this? It colours the heightmap based on the height of the vertex.


That came with AGK^^^

It only works with a detail texture instead of blending two/three textures but that is possible too with minor modding to the shader.

Personally i found even blending 3 textures a bit bleak plus it doesnt work with per pixel normals (normal map)....so moved onto a shader which could work with diffuse and normal maps on the terrain which looks way better and allows blending between 255 textures in an atlas but only uses 3 texture slots... It allows for adding roads, tarmac...etc... but with per pixel normals. Having seen the PBR rendering capabilities on here recently, im sure we might see some much better solutions too!!

I also think Janbo was working on a Terrain shader for his pack too which will be better then mine!
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 2nd Feb 2018 11:09
That's the very shader I started with, but then I replaced the vertex shading with the texture blending. It provided me a good starting point - like I said, no C experience so sharers were double Dutch to me to begin with.

My solution is in the landscape generator I have, but the scale is so much larger I immediately hit the same problem....3 textures doesn't hugely make an impact (though it is still better than 1!). I spent time trying to use a mix of the bump map demo from the community sharers, and a tutorial online to get normal mapping In, but to zero success. Think my AppGameKit install might be corrupted though- if it try compiling the shader demo it errors out saying it's made with a newer compiler (my AppGameKit auto updates via steam). The already compiled executable runs fine, but when put into a new program the shader fails to compile. I think maybe it was done before the sun commands came In? Dunno, it's still too complex for my understanding. Between the demo here and inline though, the only bit of code that looks the same is the normal map calc multiplying the image value...everything else seems totally different.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 3rd Feb 2018 20:37
Yay....

So big big thanks to Bengisimo for putting the thought there, and now the landscape works perfectly with atlas textures, so I can have far more variety with the landscape imagery. I now plan to do varying mixes of heights with varying atlas textures of different sizes to make the landscape much more varied at scale. I also plan to use the alpha channel to add detail overlaid on top of the ground to spruce it up. Screen shot coming soon.

Alas......still no-where on the normal mapping. :-(
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 4th Feb 2018 14:26
So the textures still need work, but getting there. This is a comparrison against 3 textures loaded seperately being blended together, now with an atlas texture routine capable of blending up to 16 (I could do more, but it looses detail).

Getting there slowly but surely...

Attachments

Login to view attachments
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 5th Feb 2018 18:07
Interesting, it works with mipmapping right !?
So are you creating the atlas textures with borders to work with mipmapping ?
How do you belnd more than 5 textures.
You are using vertex colors instead of a splatmap to blend the textures but you only have 4 color channels there too or do you split the 4 bytes into smaller pieces.
So I wonder how you get 16 different textures ? (although I cant see more than 5 textures used in the picture)
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 6th Feb 2018 02:54
Hey Janbo. First up - your shaders are AWESOME. You are literally part of the reason I even decided to start looking at them.

Yip, works fine with mipmapping, but no borders. There is a tiny glitch in that the textures inherit a grey line but it's so thin you can't see it at distance, nor when scaled to full size. I'll look at that though - I did come across a tutorial that said something about mipmapping correction.I think my issue is coords though - I've not done anything special though....don't know enough to yet! Lol. Those pictures didn't use all the available textures....I could in theory mix as many as I wanted, within file size limits of the single image. I've attached a new image that shows almost all of the layers (but some are designed to be subterranean right through to ice caps so it's difficult to get them all in with Google maps height maps - next up is height map generation in game to create seeded landscapes). I'm going to look to re-implement normal mapping so that grass textures don't grow up walls, but we'll see.

I'm not touching vertex colors now , I moved away from it. Now it is doing all the work in the fragment shader using a recursive method to start from black and then blend through the different textures based on vertex height. I'm still learning, but the method works for all kinds of things - I was playing with alpha blending tonight...I am going to use it to try and rust a car model in realtime (remember the nVidia demo?) when I get a spare coupe of hours...think I know how it's done easily using this technique now. I can now also use this to portray dirt/damage/age on objects, the level of which is variable depending on the setting...I aim to have derelict space craft to salvage where everything old and dirty, but that needs more experimenting.

I also found an awesome procedural grass shader which I hope to get working, but we'll see on that one too - I'm better with the fragment shader than I am the vertex shader (which I'm still not particularly good at yet).

Don't suppose you fancy helping me work out normal mapping do you?

Attachments

Login to view attachments
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 7th Feb 2018 02:37 Edited at: 7th Feb 2018 02:41
Thanks and exactly that gray line (it also prevented me from using atlas textures right away) is because of mipmappig.
For mipmappig it averages neighbouring pixel colors which obviously doesn't stop at the borders of subimages of atlastextures.
You can prevent this seam(the gray line) by adding borders around the subimages.
For normalmapping can use the getPSLighting function generated by AppGameKit, but you need to pass the tangent,bitangent and normal or directly the TBN matrix to the fragment shader.
Here is everything you need to know for normalmapping: tutorial-13-normal-mapping
You can get AGK's normalmapping shader code by setting up an object with a normal map and then reading the code with GetObjectMeshPS/VSSource
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Feb 2018 09:05
That's some good looking terrain!

Login to post a reply

Server time is: 2024-11-24 03:06:23
Your offset time is: 2024-11-24 03:06:23