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 / prevent non visible polygon from being drawn automatically!

Author
Message
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 10:10
Does this engine has this function?
It is rendering all 700k+++ polygon faces despite only a few thousands being visible.
Turning object visible did not help much as even the back face of every small object is being drawn but not viewable by the player.

This scene is pretty small too...

Any help appreciated!
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Dec 2018 10:21
How do you know they are being drawn?
Green Gandalf of the TGC forums aka Scorpius of the Malevolence:Sword of Ahkranox forums.
Shader developer for Evochron Legacy produced by StarWraith 3D Games.
puzzler2018
User Banned
Posted: 31st Dec 2018 11:58
AGK has automatic object culling with non visible polygons not been shown and then its double made sure this happens automatically by the GPU

and then you can trebly make sure it doesnt show the polygons by using SetObjectCullMode command
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 12:31 Edited at: 31st Dec 2018 12:38
I tried that, SetObjectScreenCulling.

Basically I need this but for object hiding behind another object within the screen space.
Not just outside of screen space.

A function like: SetObjectObjectCulling

work with camerarange function?

Also, is there a way to show the wiremesh of polygon?
puzzler2018
User Banned
Posted: 31st Dec 2018 12:37 Edited at: 31st Dec 2018 12:38
As green gandalf suggests - how do you know culling is not working properly. do you have a small snippet example showing the fault

So you wish to have objects not to be visible of they are outside the screen?

I have some code somewhere to do that - bear with me

I need to check the minecraft thread to find it
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 12:43 Edited at: 31st Dec 2018 12:46
I create a layer of 16 by 16 cube and I get 768 polygons viewing from above.
I create a layer under it, and it render twice the amount viewing from above.
The same for more layers.
I want object not to render if they are behind another object and has no value in showing the player because the player could not see it anyway.
collision is still active, but that did not seem to drop much frame when disabled?

There is actually a plugin for unity3d that actually solve this and I am just asking if there is object culling in agk.
puzzler2018
User Banned
Posted: 31st Dec 2018 12:53
I see where and what you like to achieve here - we need to create our own culling mechanism for this.

If your working with cubes. Do you know how to construct a cube by means of constructing its faces - cause we can code it to say

- if there is a cube to the left, then dont draw the left face.
- if there is a cube to the right then dont draw the right face.
same with all the other sides of the cube.


Ill put something together a bit later to help you

This is the code to not view any objects thats behind the camera



Be back soon with the cube creation with individual faces.
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 13:00 Edited at: 31st Dec 2018 13:11
I mean I have a manual culling protocol.
However, it still render any block that is visible such as the surface inside of a cave from above with block blocking.

Perhaps it would turn into a features called: Cave finder! If it lag, its a cave~!

I do not have access to tier 1 source code, so rendering face that is less than 45 degree towards the player is impossible.

I have change the code to show what I mean, please try it.


puzzler2018
User Banned
Posted: 31st Dec 2018 13:09
Yes it will need to be manual culling - are you using AGKs culling method. cause what you need to acheive is block faces frustrum

I did a small 16x16 layer of cubes and yes are polygons are drawn even though they shouldnt be - added more layer - the polygons increased the same.

Are you happy for me to put something together to stop this occuring... Its mesh memblock work im afraid
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 13:12 Edited at: 31st Dec 2018 13:19
errr

This is the issue I am having:




my frame rate drop by half when I do this.
Rendered but not visible.
Could there be a way to fix it with agk without serious check code?

change for y = 1 to 10 and that is the issue I am having.

Edit: Sorry, wrong Y coord fixed
puzzler2018
User Banned
Posted: 31st Dec 2018 13:19 Edited at: 31st Dec 2018 13:20
Whats the issue?

All the block faces that are next to each other are been drawn when they shouldnt be ?

FPS will drop cause your using AGKs cube - which automatically renders all the faces.

Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 13:20 Edited at: 31st Dec 2018 13:21
Block under the top block is being render which drop the frame rate from over 500 to under 20.
Block that are not visible.
puzzler2018
User Banned
Posted: 31st Dec 2018 13:22
Thats correct..

I shall now work on fixing this for you and make your frame rate go up to 500
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 13:25 Edited at: 31st Dec 2018 13:27
Ok, there is really no school or tutorial for this.
I was just testing it, but if I use an actual 3d model, would it fix this issue?
The final goal is custom 3d cube model that is external.

Since not all cube is cube but actual shape that fit into a cube.
puzzler2018
User Banned
Posted: 31st Dec 2018 13:29 Edited at: 31st Dec 2018 13:29
The idea of the reducing faces / polygons if objects are joined together was not developed into AppGameKit thats why arent any tutorials - its all manmade with MeshMemblock works - i aim to fix that one day..
puzzler2018
User Banned
Posted: 31st Dec 2018 13:31 Edited at: 31st Dec 2018 13:33
a 3D model of a cube will still have its 6 faces rendered - we need something to signify if there is another block next to it and dont display it.

How big is your cube layers intend to be for your app.

16x16x16 perhaps? or larger like Minecraft all over again
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 13:39 Edited at: 31st Dec 2018 13:39
I just tried loading actual 3d model, same result.

Was just trying to figure if agk could be use as a base for a game like a survival world with story.
Or just to try a story with minor gameplay.

Could also go for a engine that could wrap vector to simulate mining and such.
Also wanted the html5 possibility.
And the license...?
puzzler2018
User Banned
Posted: 31st Dec 2018 13:50
That sounds good to me.

AGK can be used for any sort of game - just knowing how thats the key

It should also work in HTML5 although i havent worked with html5 so dont know what the performance would be like

License shouldnt be an issue as long as got the latest version

puzzler2018
User Banned
Posted: 31st Dec 2018 13:54
If you dont like to head toward mesh memblocks - cause they are difficult then how about creating a cube by using Planes.
but AppGameKit CreateObjectPlane - is double sided - so we can use Mesh Memblocks just to create a single sided plane.

and then attach up to 6 single sided planes together and miss any that if any cubes are touching.

At least then be able to use AGKs collisioning system
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 14:05 Edited at: 31st Dec 2018 14:05
I could learn, so it is not an issue.
But it does not seems like I could use it with custom block type model?
puzzler2018
User Banned
Posted: 31st Dec 2018 14:11
You could - but very long winded - cause you would have to create 6 3D models

1 with 1 face,
1 with 2 faces,
1 with 3 faces,
1 with 4 faces,
1 with 5 faces and
1 with all 6 faces.

The result of time and hard work will be the same
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 14:12
Does agk have something like depthmask?

http://wiki.unity3d.com/index.php?title=DepthMask
puzzler2018
User Banned
Posted: 31st Dec 2018 14:16 Edited at: 31st Dec 2018 14:23
Not really sure f it does automatically behind the scenes- but a very interesting topic --- good find...

EDIT - Maybe this

SetObjectDepthWrite

But havent tested
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 14:24
html5 does not have the ability to grab a var or run a function in browser nor store data in user web storage, so html5 version of agk is kind of useless as a engine to make webgl games.
Having user login on every page refresh on a website is kind of stupid, so is logging in every time the game is played too.
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 14:53 Edited at: 31st Dec 2018 15:01
So I was looking at this post...

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

Is there a way to do a simple raycast instead?

like a getspritehittest for 3d?
puzzler2018
User Banned
Posted: 31st Dec 2018 15:00
Yeah - this is a nice effect isnt it
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 15:01
...But the model is recreated every frame...?
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 31st Dec 2018 15:11
Addressing the original question...

Yes its possible create large cube based scenes but to be able to render it quickly, its more complex than just creating a cube for each block. The number of objects becomes huge if you just create cubes and so your framerates will drop and you will struggle to render even a small landscape at a decent fps. I (and others) have used methods of grouping cubes into chunk objects and automatically not even creating interior cube faces that could never be seen so that it all renders quickly.





That way you can render large areas with custom blocks types etc... but with a framerate >100. Plus its still possible to remove cubes or add them...its just a fair bit more complex to do so.
puzzler2018
User Banned
Posted: 31st Dec 2018 15:47 Edited at: 31st Dec 2018 15:52
Here is a snippet of my previous works to try and help guide you along the memblock arena



Attach the two files into the Media Folder

Attachments

Login to view attachments
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 15:58 Edited at: 31st Dec 2018 16:08
Thank You!

over 1k fps.

I'll go over it tomorrow when I woke up.

Edit: Well, I change for y#=-512 to 512 and it kind of crash
puzzler2018
User Banned
Posted: 31st Dec 2018 16:04
No problem

It doesnt end here though, to get this kind of FPS with this kind of programming, there will be a lot of hard work and knowledge gaining to be able to do anything with it -

Like collisions, vertex removes

To help further - if you like you could take a browse through a Minecraft thread

https://forum.thegamecreators.com/thread/221407?page=17

or my Memblock thread

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

and indeed there maybe lots of other threads around with this work too.

A huge challenge awaits anyone who likes to try and tackle this kind of programming.

Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 31st Dec 2018 16:09
Well, I change for y#=-512 to 512 and it kind of crash

32 x 32 x 32 seems to take forever to generate too.

Guess I will try it out in the next 24 hours.
puzzler2018
User Banned
Posted: 31st Dec 2018 16:12
a mesh memblock can only go up to 1,000,000 bytes - so -512 to 512 will overtake that barrier

What you probably need to do is create multiple of smaller mesh memblocks and join those together

Ill quickly put something up soon to show this example.

Ill let you get some rest now and catch up tomorrow

Have a nice new year night
puzzler2018
User Banned
Posted: 31st Dec 2018 16:34
With this code - still creates a full object cube, so no object culling, so i will work on "culling" a cubes faces if they are joined together - otherwise FPS will dramatcially fall if creating so huge worlds

and we will have to use some kind of distance checking from the camera to the cubes in front and above. any thats further away or underneath then dont render that chunk ( smaller chunks will be faster to manipulate / change vertexes etc)

I can really sense a vortex world generator all over again
puzzler2018
User Banned
Posted: 31st Dec 2018 16:56
OK cool

Here is a version that just creates the top plane to start with


Stiil require to add the other planes that not joined

Number of potential cubes - 4,096,000
Chunk size 32x32s32
world size 2x2x2
number of chunks 125
FPS runs at 150ish

Attachments

Login to view attachments
puzzler2018
User Banned
Posted: 31st Dec 2018 18:46 Edited at: 31st Dec 2018 18:55
Ok cool, I think we have face resolvements now



WASD or cursors to move about and change line

Uncomment liine 138 to see a differently
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 31st Dec 2018 21:55
Hi there .

What about the trick of hiding objects "setobjectvisible(0)" something like this :

I'm not a grumpy grandpa
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 1st Jan 2019 03:22 Edited at: 1st Jan 2019 03:23
"setobjectvisible(0)" was the default use, but object is still being render despite hiding behind the first layer.
Like an underground cave or something.

Also, the main use was something like a GTA like game where most of the city is set on screen without a way to set its visible without some kind of ray casting check.
Agk does not seem to do individual polygon culling either.

Also Happy New Year!
puzzler2018
User Banned
Posted: 1st Jan 2019 14:58 Edited at: 1st Jan 2019 15:08
Let me have a think and a closer read up of Occlusion Culling which is different to Frustrum , Backface and behind the camera culling

Occlusion is what your after here

https://docs.unity3d.com/Manual/OcclusionCulling.html

Unity... I know I know, but sometimes it has some useful information
puzzler2018
User Banned
Posted: 1st Jan 2019 15:18 Edited at: 1st Jan 2019 15:21
Ok cool

With this, can we conclude that when objects are invisible that they are not rendered. Polygon count changes



press left mouse button
puzzler2018
User Banned
Posted: 1st Jan 2019 15:52 Edited at: 1st Jan 2019 16:13
ok cool

Try this, an adaption of what chafari did



ok its not flamboyant as unity but still..

I just thought to share this with you.

puzzler2018
User Banned
Posted: 1st Jan 2019 18:12 Edited at: 1st Jan 2019 18:15
Ive added code to also occlude the inners of a a cube mesh



Just need to now work out the geomerty distance if rotate the camera in all diirections with the mouse to also occlude
puzzler2018
User Banned
Posted: 1st Jan 2019 18:30
Probably bad practice but here is a version to dynamically build cubes as they come into view



Its not finished yet cause got lots of other things to think about
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 4th Jan 2019 04:58 Edited at: 4th Jan 2019 08:12
not exactly it?
If you set camerarange, it will do the same?

Anyway, I end up checking if there is open faces.
However, I am still unable to check if object is in view of the player.
In 2d, using a bunch of getspritehittest actually work, more cpu resources, less gpu.
using getobjectonscreen with getscreenxfrom3d and trying raycast hit, will try it out after I recover from my cold.

If only there is a simple raycast from camera to object and how many was hit inbetween... instead of having to key in the camera x y and z

EDIT: why does GetObjectRayCastNumHits() always return a 1?

EDIT: a loop of 65536 per cycle... even an i7 could not handle it. will try tier 2 and threads.

EDIT: After some trick in tier 1, it look like how minecraft would actually process it... will experiment a bit more!

Login to post a reply

Server time is: 2024-11-23 08:54:01
Your offset time is: 2024-11-23 08:54:01