martyj Posted December 11, 2015 Share Posted December 11, 2015 I would like the ability to add my own geometry shaders. Similar to the fragment shaders that we can use. The biggest benifit would be the ability to add waves to the water. Quote Link to comment Share on other sites More sharing options...
shadmar Posted December 11, 2015 Share Posted December 11, 2015 That is already supported. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
macklebee Posted December 11, 2015 Share Posted December 11, 2015 That is already supported. yeppers Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
martyj Posted December 11, 2015 Author Share Posted December 11, 2015 Is there any example? I can see how to compile my own shaders. How do I use them though? The documentation on this is slim. I found this. Context::SetShader How do I know what the variables are that are passed to the geometry shader from the tesselation evaluation shader? I can see what I need to set as my output Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted December 12, 2015 Share Posted December 12, 2015 Lunarvich has a nice Blog about post processing (shaders). Also has some good links for more info. Well worth the read. http://www.leadwerks.com/werkspace/blog/166/entry-1591-intro-to-le-post-processing-effects/ Quote Link to comment Share on other sites More sharing options...
martyj Posted December 12, 2015 Author Share Posted December 12, 2015 That example is a fragment shader. Data in OpenGL passes through shaders in the following order: Vertex -> Tessellation Control -> Tessellation Evaluation -> Geometry -> Fragment The vertex shader manages vertex data, the tessellation control, controls how much tessellation is applied. The tessellation evaluation is what performs the tessellation The geometry shader allows modification of the geometry before it is projected to the screen for fragmentation The fragment shader deals with getting pixel colors on the screen. Quote Link to comment Share on other sites More sharing options...
shadmar Posted December 12, 2015 Share Posted December 12, 2015 Here is a simple copy and offset geoemtry shader: #version 400 #define MAX_INSTANCES 256 layout(triangles) in; layout (triangle_strip, max_vertices=6) out; //in a triangle are 3 verts, + 3 for the copy.. //all these are outs from the vertex shader: in vec4 g_ex_color[]; in vec2 g_ex_texcoords0[]; in float g_ex_selectionstate[]; in vec3 g_ex_VertexCameraPosition[]; in vec3 g_ex_normal[]; in vec3 g_ex_tangent[]; in vec3 g_ex_binormal[]; in float g_clipdistance0[]; in vec4 g_modelvertexposition[]; //these goes into the fragment shader: out vec4 ex_color; out vec2 ex_texcoords0; out float ex_selectionstate; out vec3 ex_VertexCameraPosition; out vec3 ex_normal; out vec3 ex_tangent; out vec3 ex_binormal; out float clipdistance0; uniform mat4 projectioncameramatrix; void main() { //Just pass everything as is.. draw the original: for(int i = 0; i < gl_in.length(); i++) { gl_Position = gl_in[i].gl_Position; ex_color=g_ex_color[i]; ex_texcoords0=g_ex_texcoords0[i]; ex_selectionstate=g_ex_selectionstate[i]; ex_VertexCameraPosition=g_ex_VertexCameraPosition[i]; ex_normal=g_ex_normal[i]; ex_tangent=g_ex_tangent[i]; ex_binormal=g_ex_binormal[i]; clipdistance0=g_clipdistance0[i]; // done with the vertex EmitVertex(); } EndPrimitive(); //And now, make a copy and offset it a bit : for(int i = 0; i < gl_in.length(); i++) { vec4 offset=vec4(3,3,3,0); gl_Position = projectioncameramatrix*(g_modelvertexposition[i]+offset); ex_color=g_ex_color[i]; ex_texcoords0=g_ex_texcoords0[i]; ex_selectionstate=g_ex_selectionstate[i]; ex_VertexCameraPosition=g_ex_VertexCameraPosition[i]; ex_normal=g_ex_normal[i]; ex_tangent=g_ex_tangent[i]; ex_binormal=g_ex_binormal[i]; clipdistance0=g_clipdistance0[i]; // done with the vertex EmitVertex(); } EndPrimitive(); } 1 Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted December 12, 2015 Share Posted December 12, 2015 This was just a modified diffuse.shader, paste this in the geometry tab, and you need to edit the vertex shader so the out variables are named g_... No control or evaluation shader are used. Just : Vertex->Geometry->Frag Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
shadmar Posted December 12, 2015 Share Posted December 12, 2015 Also geometry made by the gs won't cast shadows, and doesn't have an aabb of it's own, cant be picked or have any api back to you application since the geometry is all made after leadwerks has sendt everything to the render pipline. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Ma-Shell Posted December 12, 2015 Share Posted December 12, 2015 Thx, shadmar, for this example. For this to run, you will nevertheless have to modify some parts of your vertex-shader, so that the "in"s and "out"s match. Also geometry made by the gs won't cast shadows That's not true. You just have to set the same shader in the Material-Settings in the Shaders-tab as the Shadow-shader, then it will have a shadow. This is the advantage of shadow maps: The shadows are generated from the depth-buffers of the generated fragments, so that is after the fragment-shader (and since the fragment-shader is run for the newly generated gemoetry, as well, they can cast shadows as well). 1 Quote Link to comment Share on other sites More sharing options...
shadmar Posted December 12, 2015 Share Posted December 12, 2015 You just have to set the same shader in the Material-Settings in the Shaders-tab as the Shadow-shader, then it will have a shadow. Thanks! That is so true Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
martyj Posted December 13, 2015 Author Share Posted December 13, 2015 Thanks Shadmar. How did you find out this information btw? Quote 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.