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 / [Q] projection matrix clipping plane.

Author
Message
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 16th Oct 2016 15:57
Is there any way to control the clipping plane of the projection matrix from Tier 1 ?

What im trying to do is setup a oblique near clipping plane, to let the gpu clip everything below a water line.

I already done it using discard but it slow everything down as the gpu cant optimize anything when a discard is used.
Also made a transparent sample where all pixels below waterline gets transparent , but this make depth problems in the reflection.

I read that using a clipping plane should be the best/fastest way to do it and the only way to get it working properly on moblies.

Tried the attached scene using discard and got 30 fps , if i remove the discard and just render everything (2 times) i get 60 fps , i expect that if i use a clipping plane i will get "nearly" the same as just rendering everything 2 times ?.

Help please, and thanks


best regards Preben Eriksen,

Attachments

Login to view attachments
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 16th Oct 2016 23:42 Edited at: 1st Dec 2017 09:16
If you find a way to Clip everything under/above the water let me know
I did my water shader with discard also.
But beware that you will get Strange results if you dont hide the Parts above the water for the refraction render ...
Point me to the Website where you found the near clippig Plane Trick ?!
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 18th Oct 2016 13:11
Perhaps only Paul can answer this, it is for tier 1 so...

https://web.archive.org/web/20160318114033/http://www.terathon.com/code/oblique.html
http://www.nvidia.com/object/oblique_frustum_clipping.html
or search "near plane clipping opengl projection matrix water"

BTW: This should be for SetRenderToImage(ReflectionRI,-1)
best regards Preben Eriksen,
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 18th Oct 2016 23:20 Edited at: 1st Dec 2017 09:16
Quote: "BTW: This should be for SetRenderToImage(ReflectionRI,-1)"
you should Clip it for refraction and reflexion anyway

You can make your own Projection Matrix like i did for my Shadow shader ...Just give the shader an Array of 16 Elements
And Convert it to a 4x4Matrix in the shader.
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 20th Oct 2016 12:40
Yes but the gpu will clip it without executing the shaders, thats why its mush faster

http://cdn.imgtec.com/sdk-documentation/Shader+Based+Water+Effects.Whitepaper.pdf
chapter: 3.1. User Defined Clip Planes in OpenGL ES 2.0

best regards Preben Eriksen,
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 21st Oct 2016 00:25 Edited at: 1st Dec 2017 09:16
Nice Link
Looks like everything is written there
Should be possible in Tier 1 too

Quote: "Yes but the gpu will clip it without executing the shaders, thats why its mush faster"

Is it even possible to render something in OpenGL without processing the minimum of a Vertex/Fragment shader ...
I think not
Preben
AGK Studio Developer
20
Years of Service
User Offline
Joined: 30th Jun 2004
Location:
Posted: 21st Oct 2016 08:54
Clipping is done just after the vertex shader , so the fragment shader is never executed , its the same that happen when you use SetCameraRange , only the vertex is executed the fragment is never executed if clipped.

But to make this work i think you need to set glEnable(GL_CLIP_PLANE0) and a way to define gl_ClipDistance[0] . and assign it to the projection matrix, so tier1 .... ?
best regards Preben Eriksen,
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 21st Oct 2016 17:59 Edited at: 1st Dec 2017 09:16
Right !
I had the same problem/asked for it earlier somewhere ... Here
But what is described there in your link should work right now ..not ?

Login to post a reply

Server time is: 2024-11-25 01:32:55
Your offset time is: 2024-11-25 01:32:55