6

The input primitive, aka. the mesh fed into the shader, has a MeshTopology setting which can be adjusted in code. The accepted answer works because the default input primitive for a mesh(including imported meshes) is triangle/MeshTopology.Triangles. But if you use MeshTopology.Triangles, you will be creating more geometry than you need for the shader. ...


4

This is actually an illusion. The vertices are not lifted: There aren't enough vertices in the model to create the pinata effect. Here are the tricks: The normal map has squares in it to create the illusion of bumps The diffuse map as ambient occlusion baked-in to create the illusion of high-detail self-shadows or an ambient occlusion map is used. The ...


4

The bound textures in a single draw call cannot be changed. This means that your geometry shader cannot select arbitrarily between different textures. The solution is to use either texture atlasing or array textures. In either case, for each cube face you generate both new positions and new texture coordinates. The C++ code must still bind the correct ...


4

The fact that something is rendered when you use your "simple method" and the geometry can be seen in Nsight led me to guess that the triangles were being back-faced culled. This is because the winding order of the vertices you create disagrees with the culling mode you are using (to put it another way, all your triangles are now facing away from the camera)....


3

Your code looks like it wants to output 9 triangles each consisting of a discreet three vertex triangle strip, not 27 triangles. However you have set max_vertices to 3 in the layout statement at the top of the shader so it only emits one triangle before it hits that limit. (The limit is for the whole shader, not per-primitive, otherwise 3 would have been ...


3

You don't need to perform backface culling manually in the geometry shader. (It's possible it could be an optimization to do so, if culling allows you to skip some expensive work in the rest of the geometry shader. But that seems unlikely to be the case.) Triangles can't have incomplete adjacency information. The vertex buffer for GL_TRIANGLE_ADJACENCY ...


3

Your geometry shader should take a single point (center of the cube) with a front vector and an up vector. You can then output 12 triangles (6 faces x 2 tri for a quad) using the single point as the center of the cube and the cross-product of front & up for the right vector. // table of all triangle vertices to make the cube const vec3 face_table[12*3] ...


3

From the OpenGL wiki: The input_primitive​ type must match the primitive type used with the drawing command that renders with this shader program. Given, Unity is probably using DirectX on Windows, but the same thing should hold true. Because your shader is asking for a point, it is only taking the first point from each primitive and ignoring the rest. ...


3

Probably the simplest way to modify your code to get rotation (roll) is to modify the calculation of upVector. Specifically, upVector should be rotated around the planeNormal axis by the desired roll angle; then the calculation of rightVector and all the vertex positions will incorporate the rotation, too. A convenient formula for this is Rodrigues' ...


3

Surface RT is indeed FEATURE_LEVEL_9_1, so hardware geometry shaders are unsupported. The Windows software rasterizer, WARP, does support it though. This could be what Morten is referring to. To create a WARP device, use D3D_DRIVER_TYPE_WARP in your call to D3D11CreateDevice. Note that on Surface RT, the performance of geometry shaders on WARP will not ...


3

The problem is that this code needs to run as many times as the depth of the tree, and not all of it can run in parallel. ...which is the prime indicator NOT to process this as such on the GPU. GPU architecture suits problems where the individually-processed elements are independent of one another. If I were to use Vulkan instead, would that broaden my ...


2

Modern OpenGL defines only points, lines or triangles; there are no 4-vertex primitive types, so you can't draw a quad without triangles. Using a Geometry Shader won't even allow this as the only valid outputs are points, line-strip or triangle-strip; there's no quad output. You can emulate a quad with a triangle strip (using the 4th vertex to complete the ...


2

It's all just perspective. The hardware only operates on triangles. It renders what you give it to render: If you want to create quads, you simply need to make sure that all four vertices shared by each such pair of triangles, are co-planar. Then any normals-based lighting algorithm running on the hardware is going to render them as a single, uniformly-...


2

This blog post describes an effect where the intersection between two object is highlighted. However, both object are rendered. I'm guessing in your case, you don't want the plane to be rendered. You could set the alpha for the plane's color to be 0. I think that will put the plane in the depth buffer, but not color it. But still, your object might intersect ...


2

Instead of building the cube in geometry shader from a point, its better to do an instanced render of a simple cube VBO, and forego a geometry shader entirely. The only time you wouldn't want to do that is if each cube has rapidly changing orientation and you need to recalculate its modelview every pass. In which case, have position and orientation as ...


2

One way would be to draw the object or character you wish to outline by itself into a depth-only buffer. Then you could run an edge detector on the depth buffer to find the edges of the object. Finally, take the resulting edge image and overlay it on the scene.


2

It looks like the problem is that you're using a TriangleStream. You've marked it as maxvertexcount(1) which means that you can't actually draw anything, because a triangle with one vertex isn't a triangle. Try using a PointStream as your output type. A GeometryShader with a TriangleStream can be used to output two triangles that are facing the screen in ...


2

You can't do this if you want smooth shading. Calculating per-vertex normals involves calculating per-triangle normals, then averaging those normals (optionally giving each a weight) for each triangle that shares a given vertex. So you need additional information that you just don't have: which triangles share each vertex. As you will see from a diagram ...


2

This is less a specific answer to the question, but a general hint on how to set up an OpenGL context because I feel it will answer the question automatically. The same procedure is used for instance by 'learnopengl.com' and possibly others I don't know. My system is a Debian 10, but it should work on Windows as well. We'll setup an OpenGL context and enable ...


1

If, in your case, you want to treat all even numbered vertices different from all odd numbered vertices, then you could use gl_VertexID built in GLSL variable. You could pass in two modelviewprojection matrices, one for type A and one for type B, and apply the one based on the least significant bit of gl_VertexID. if ( gl_VertexID & 1 ) ... If there ...


1

I am the world's biggest moron. My window is 800x600. That means that the X-axis from -1 to 1 is 800 pixels and the Y-axis from -1 to 1 is 600 pixels. If I use a square window, everything is... square.


1

You are applying transformation to the point and not to the vertices of the triangle. Transformation should be applied to EACH vertex of the output triangle if you want the triangle to rotate. Vertex shader #version 400 core void main() { gl_Position = vec4(0,0,0, 1.0); } Geometry Shader #version 400 core layout(points) in; layout(triangle_strip,...


1

Although according to the OpenGL standard you should be allowed to specify whichever location you want, some drivers have specific locations for legacy uses. Specifying locations may cause conflicts with those. For example: https://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/attributes.php NVidia hardware indices are reserved for built-in attributes: ...


1

Ok so I've discovered that if I remove the layout qualifiers from the input/output blocks, like this out VS_OUT_GS_IN { vec3 pos; vec3 normal; vec2 texc; } vs_out; and like this in the geometry shader in VS_OUT_GS_IN { vec3 pos; vec3 normal; vec2 texc; } gs_in[]; it produces the expected results. But why does it not work ...


1

The looks like a compiler bug. But in any case: You don't need the copy into a const array, just use the non-const one. You don't need those large arrays, from what I see everything in the shader can be done in a single for (i = 0; i < TAM; i += 3) loop with small arrays of 3. That should work around the compiler bug and probably make the shader faster....


1

It worked. My Code: Mesh mesh = new Mesh(); mesh.vertices = newVertices; mesh.uv = newUV; GetComponent<MeshFilter>().mesh = mesh; mesh.SetIndices(new int[] { 0 }, MeshTopology.Points, 0); The last line creates was very important to create a trinagle. For saving the Mesh: AssetDatabase.CreateAsset(m1, "Assets/" + "oneVertexMesh" + ...


1

The whole way I was going about it is wrong. I'll answer my own question in case anybody else comes here from google. Instead of generating a whole tonne of points and appending them in one geometry shader to create lightning, the answer is to only generate each iteration of the lightning per geometry shader invocation to remove the need for having a ...


1

The Direct3D 11 Tessellation stage is designed to be a bit generic so that applications can implement different approaches. There have been a number of presentations on this topic over the years at various conferences. I have links to them at this blog post. This topic is covered in a number of Direct3D 11 books. See this blog post for a list of ...


Only top voted, non community-wiki answers of a minimum length are eligible