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.

Author
Message
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 8th Nov 2015 15:32

Android:
http://www.plemsoft.com/agk2015-3ddemo.apk
Windows:
http://www.plemsoft.com/agk2015-3ddemo.zip

AGK 2015 3D Demo,
Running 60 FPS on ipad2,iPhone,samsung s2…
Features:
Tile based unlimited terrain system.
Random placement/generation of vegetation/palms.
Culling system that allow thousand of trees/objects, still with 60 fps on most mobiles.
3D Animations.
Coconuts 3D physics.
Good water shader ( fading on ugly low poly edges ).
Moving skybox.
Fog shading on all objects to allow more objects in the world.
Some HQ objects.


At anytime you can start playing , and explorer the world. or just let the auto camera run.

The palm is using a blur on the edge to make it look round, even if it only has 2 planes. a special collision mesh is used, so when colliding it also fells round.

I was surprised that it was possible to get so many objects at 60 fps on mobiles, gives possibilities to make great looking 3d games using AGK.







Sorry Low Q video:




If you try the Android demo please post your fps, thanks
best regards Preben Eriksen,
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 9th Nov 2015 11:57
Ooh! Nice fog Why isn't this built into AppGameKit yet? You don't want to post a tutorial on how you did this do you?
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 10th Nov 2015 23:54
>Ooh! Nice fog Why isn't this built into AppGameKit yet? You don't want to post a tutorial on how you did this do you?

Adding fog is pretty easy and I’m sure Paul could do it in ten minutes, but shaders is a crucial thing for AppGameKit and need to be perfect, first Paul did some amazing stuff with dynamic generated shaders in 2015 ( and they are really fast ), but shaders is not just shaders i think its part of a plan to make AppGameKit really fast, the next step will properly be to bake meshes after what shaders and textures are used, so just putting in fog in some shaders would kill the overall speed increase you get when baking meshes. This is not just for fog it could be point lights, shadows , normal maps , light maps … whatever you can think of, the more different shaders you use the slower the overall product (AGK) will be at the end, (not quite so, perhaps saving 3 light calculations in a shader would be faster then baking the meshed).

Its all about testing testing and testing, what would be fastest to specify fog on one object, or use a function to set fog on ALL objects, i would say setting fog on all objects would be faster. ( then you would be able to bake more meshes and gain more speed at the end. ) ?

But sure we need fog and all the other goodies, but putting it in AppGameKit the proper way takes a lot more time then just doing it in a demo

Anyway i can do better then a tutorial here is the shader code if you like fog on your objects:

Vertex shader (fog.vs):




Fragment shader (fog.ps):



This shader is simple and only have one texture and the fog. You can always expand it to use SetShaderConstantByName so you can set the fogcolor and distance directly in AGK.
vec3(0.21,0.41,0.67) = The fog end color , RGB color range goes from 0.00 to 1.00. ( instead of 0 - 255 )
distToCamera/1500.0 = 1500.0 is the camera range where the final fog color is reached.

If you have any questions just let me know, if you tried the demo on Android please post your fps

best regards Preben Eriksen,
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 13th Nov 2015 13:33
Quote: "Anyway i can do better then a tutorial here is the shader code if you like fog on your objects:"

Fantastic! This should go in the community shaders thread. I'll post a link. Thanks!
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Tobias_Ripper
11
Years of Service
User Offline
Joined: 24th Mar 2013
Location: REPCONN inc.
Posted: 14th Nov 2015 06:21 Edited at: 14th Nov 2015 06:23
Quote: "Anyway i can do better then a tutorial here is the shader code if you like fog on your objects:

Vertex shader (fog.vs):

+ Code Snippet



Fragment shader (fog.ps):

+ Code Snippet
"


Hey. It's been several years since I've visited the GTC forum but with new need to explore AppGameKit for my own project, I came across your fog shader. I have absolutely no experience with shaders and frankly the last time I've touched the TGC product was back in Dark Basic Pro. I really want to get this fog shader to run though. I ran it before the main loop with:



and I am getting


I am unable to troubleshoot the issue due to my inexperience with the shaders.
Isenstadt Studio: http://isenstadtstudio.com/
Composers Page: Milesthatch.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 14th Nov 2015 12:38
Hi Tobias_Ripper,

Zip your project and email it to me and i will fix it for you

plemsoft@plemsoft.com

And welcome back to the forum , i know your really going to like the new AppGameKit, so mush great stuff has been put into it.

best regards Preben Eriksen,
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 14th Nov 2015 14:39
Hi
It's a very interesting demo !
Your shader example is great, but if we use it, we lost all the lighting (made by the light) in our scene ^^.
Do you know if it's possible to mix the fog with the lighting ?

Some other questions about your scene:
- what is the tool you use to create your level ?
- do you use some lightmap ? If yes, what is the tool you use to have your lightmap ?
- is your skybox a cube or a sphere ?

- what is your culling system ?
I use blender (for my models, texture and lightmap (baked), but for the placement (tile/ground, object), I don't know if I have to create my own level editor ^^.

Thank you a lot for your example .

http://www.dracaena-studio.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 15th Nov 2015 14:09 Edited at: 15th Nov 2015 23:54
Tobias_Ripper:
Fixed your code and sent a zip back to you. Hope you can use if

Blendman:
Sure you can use light you just add these 2 lines to any fragment shader your want ( as the last 2 lines ):

vec3 fogColor = vec3(0.21,0.41,0.67);
gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w), clamp(distToCamera/1500.0,0.00,1.00) );

Then you have fog on that shader.

I know that in the latest agk versions the names has changed , but the old light with fog look like this:
vertex:

fragment:


That will give you one directional light and one point light. and sure with fog. if it dont work you must use SetShaderConstantByName to set the variables to match the old agk shaders names

My windows box cpu burned , so i decided to use only my mac for some month to learn it better , so currently i use daz studio 4.8 , verto studio , blender ...
In this demo , most objects are auto placed , and the other i just walked around the terrain and wrote down the x,y,z for the objects.
culling is special for this demo , as it has many tile based terrains , so i have divided them into sections , so i hole section behind you is disabled and all object is not checked.
for the rest of the objects , it use a angle based culling to see if a object is visible , also it has a next check count , so objects that cant get visible within 10 sync dont get checked for the next 10 sync.
And it will add a random skip to objects that need to be checked, so they dont get checked in the same sync (even out the culling calculations ) , this way no more then around 40-50 objects is checked each sync , even if there are thousand of objects.
best regards Preben Eriksen,
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 23rd Nov 2015 13:48 Edited at: 23rd Nov 2015 14:43
Hi Preben
Thank you for your explications.

I have tried to change the fog shader, to use an ambient occlusion map.
It works, but I have a little error with the shader : for the ground (the object with this shader), the clamp use the "black" color, and not the fog color.
I think it's because I multiply the texture0 by the texture1, but I don't know how to fixe that.

Here the fragment shader :


And the vertex :


if you have an idea,
thank you
http://www.dracaena-studio.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 23rd Nov 2015 15:41
The clamp just return a value between 0.00 and 1.00 , and you do use the fogcolor , but the distance is set to 45.0 , thats pretty near try to set that to 450.00 and see what happens, else sent me a screenshot here so i can see what the problem is

best regards Preben Eriksen,
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 23rd Nov 2015 17:42
Hi Preben, thank you for your answer .

Here a screenshot to see the bug :

As you can see, the multiply mode for the shader works, but I don't have the fog no more on the ground with this shader, and I don't know why.


I have another question about culling ^^' :
Quote: "so i hole section behind you is disabled and all object is not checked.
for the rest of the objects , it use a angle based culling to see if a object is visible "

how do you do to desabled the object behind us ?
Do you set them with SetObjectVisible(obj, 0) for example ?

In one of my test, I have 13000 polygons drawn and sometimes, my fps decrease under 40fps, and I don't know why.
Do you think it's better to have an object created with several little object or a bigger object in one "block".
For example for a house, I can do :
- base.obj + roof.obj + window.obj + door.obj and assemble those .obj to create several diffents
- or I can create a unique house.obj with all the part assembled.

For the moment, I use several little objects, but I don't know if it's better than middle object with several part.

Thank you for all the informations you provide with us .
http://www.dracaena-studio.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 23rd Nov 2015 22:29
Actually there is fog on the ground you can see the blue ( even if its really block ), but its not fading out , so you just need to decrease the distance it takes to fade out to only fog.
currently you have distToCamera/45.0 , so try to decrease that to 20.0

( thats already really low , are you sure your using 45.0 ? )

Currently AppGameKit dont bake the meshes ( if they are in different objects ) , so the best thing you can do is make as few objects as possible, so combine as mush as possible. perfect would be that all you see in the screenshot is one object, and what is behind you is another object, that way all you see , would only use one draw call , and you could cull what is behind you. But nothing is as perfect as that, so just try to combine as mush as possible.

baxslash made a function for that:


I normally dont do it like this ( only xz ) , but i can see your up flying in your screenshot , so this function might be better

best regards Preben Eriksen,
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 24th Nov 2015 08:42 Edited at: 24th Nov 2015 09:17
Hi Preben, thank you for your information.

Sorry, for the fog, the bug was me ^^. I have set a different fog color for the gournd and for the other object ^^. Now it's perfect ! It's great, thank you a lot .

I have seen that if you want ot have a "start" for the fog, you have to do :


Specialy :

You can change the -0.4 to have a near or far fog start .


For the cull, I understand the technic, but so I should made one object for what I see in front of the player (ahead). I will try to do that, but I use a lot of little objects so I have to see what is the best for my scene ^^.
What do you mean by "you can cull what is behind you" ?
I have to use "setObjectVisibleobj,0) or another technic ?


Thank you again for your answer.
http://www.dracaena-studio.com
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 24th Nov 2015 10:00
Hi Blendman,

I dont think that would work ?, it would not end the fog where you want it to end , to use a startfog and endfog you should do it like this:
clamp((endfog - distToCamera)/(endfog - startfog),0.00,1.00)

So in your case:



20.0 is start fog. If you going to use this on mobile you should move this calculation to the vertex shader, to mush calculation in the fragment shader drains a mobile gpu

Yes just use setobjectvisible(obj,0) to disable the objects behind you.

best regards Preben Eriksen,

Login to post a reply

Server time is: 2024-11-22 06:29:00
Your offset time is: 2024-11-22 06:29:00