Shadoh Posted June 23, 2014 Share Posted June 23, 2014 I've scoured the site, and can't find how to implement Plane Clipping, I need this to create water reflections. It's simple to implement via OpenGL, infact the commands are below, can it please be wrapped in Leadwerks? A quick side-question, can we actually call OpenGL commands ourself? double plane[4] = {0.0, 1.0, 0.0, 0.0}; //water at y=0 glEnable(GL_CLIP_PLANE0); glClipPlane(GL_CLIP_PLANE0, plane); RenderScene(); glDisable(GL_CLIP_PLANE0); Quote Link to comment Share on other sites More sharing options...
Shadoh Posted June 24, 2014 Author Share Posted June 24, 2014 I just had a stroke of genius What I'll do as a temporary solution is render the scene ONLY with the water plane, then when I render the reflection camera I'll remove any pixels with less depth than the plane. Pretty crappy work-around, but at-least it'll let me get a screenshot up Quote Link to comment Share on other sites More sharing options...
shadmar Posted June 24, 2014 Share Posted June 24, 2014 Yes you can use discard like that, but then you need to change all object shader in use (the ones that are supposed to be clipped), which makes water making with plane reflection difficult for general easy usage. 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Shadoh Posted June 24, 2014 Author Share Posted June 24, 2014 gah, Yes, just found that out the hard way lol, after several hours getting my shader right, I realised that I can't get the pixel behind the bit that gets masked out lol... back to the drawing-board. Quote Link to comment Share on other sites More sharing options...
Shadoh Posted June 27, 2014 Author Share Posted June 27, 2014 Just FYI here's what I have so far, the map is LakeTumbleson. And has over 200,000 trees. I can't easily remove the glitchy spots in the water where the sky is cutting out the reflection, that is until PlaneClipping is added. As you can see it's very much a W.I.P and me and my team-mate are keeping the game quiet until we're sure we're going to finish it, this is mainly just a test to see what we can do at this stage. EDIT: Yes, there are trees in the water, the tree generation system still needs some fine tuning lol 2 Quote Link to comment Share on other sites More sharing options...
Josh Posted June 28, 2014 Share Posted June 28, 2014 Plane clipping is part of the fixed-function pipeline that was removed in OpenGL 4. It can be done in a shader, though, as discussed. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Shadoh Posted June 29, 2014 Author Share Posted June 29, 2014 Thanks for the reply, I know you must be a busy guy. I found it, now just to figure out how to access the terrain shader. Here's the post on OpenGL.org that helped me for anyone else out there needing to find out how to do this. Quote Link to comment Share on other sites More sharing options...
shadmar Posted June 29, 2014 Share Posted June 29, 2014 I did something like this in 3.0 for the model shaders vertex: out vec3 clip_pos; .. clip_pos = (entitymatrix*vec4(vertex_position, 1.0)).xyz; frag: in vec3 clip_pos; uniform float water_height; .. if (clip_pos.y < water_height) discard; The thing is that you have to change all shaders that are in play or has the chance of being clipped, so making clipped workshop items etc will be a nightmare. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.