frtps wrote in Thu Oct 17, 2019 9:50 am:I am interested in writing a geometry shader for cliffs. I'm pretty sure I could take an existing FG geometry shader and just tweak it to not use lat/long coords. However, I'm a bit vague as to how a geometry shader works, perhaps one of you could point me at an appropriate geometry shader in FG that I could use as a starting point and study guide? A bit of an explanation wouldn't hurt either.
So what I have in mind is a shader that would give the illusion of an uneven vertical surface, that is, the impression of a ragged rectangular pattern of rock jutting out by varying amounts
However, I'm a bit vague as to how a geometry shader works, perhaps one of you could point me at an appropriate geometry shader in FG that I could use as a starting point and study guide?
Thorsten wrote in Thu Oct 17, 2019 12:53 pm:Well, yeah - I'd second that - I'd try a heightmap or so in the fragment shader.
1. I am perturbed by a comment in the urban-ALS.vert shader that world scenery 2.0 generates incorrect binormals, normals and tangents. Is this still the case?
If, say, I calculate the binormal and tangent directions in the vertex shader, is it true that these will be averaged for each vertex across *all* triangles having that vertex, or only those triangles that the shader is called with?
3. Is there a way to get the plain old normal for the triangle that a fragment is part of rather than some interpolated normal?
Thorsten wrote in Sun Mar 29, 2020 7:37 am:1. I am perturbed by a comment in the urban-ALS.vert shader that world scenery 2.0 generates incorrect binormals, normals and tangents. Is this still the case?
Since the scenery hasn't changed, I believe yes, but that's hardly relevant for you since I understand the cliffs are in custom scenery rather than WS II urban areas, no?
If, say, I calculate the binormal and tangent directions in the vertex shader, is it true that these will be averaged for each vertex across *all* triangles having that vertex, or only those triangles that the shader is called with?
They're computed for all vertices that shader is run for, but they're not interpolated/used if no fragment shader needs them. But when interpolated the normals always 'leak' into the surrounding terrain (we use the fact to make the sea wavy next to cliffs for instance...) - so you can not exclude edge vertices from the normal computation somehow, all vertices of a triangle contribute, regardless of whether part of them also belongs to triangles that get a different effect.
Thorsten wrote in Sun Mar 29, 2020 9:41 am:The triangle strip would do the trick, yes. If you're willing to do that, I'd try to make the cliffs a bit more random in the mesh - they look very cool in the images, but kind of too regular for my taste.
frtps wrote in Sun Mar 29, 2020 7:16 am:
1. I am perturbed by a comment in the urban-ALS.vert shader that world scenery 2.0 generates incorrect binormals, normals and tangents. Is this still the case?
2. If, say, I calculate the binormal and tangent directions in the vertex shader, is it true that these will be averaged for each vertex across *all* triangles having that vertex, or only those triangles that the shader is called with? Obviously I don't want the flat areas at the top of a cliff to influence the normal that is then interpolated across the cliff face.
3. Is there a way to get the plain old normal for the triangle that a fragment is part of rather than some interpolated normal?
Don't forget (like I did) to actually provide the generated values to the shader by adding <attribute> tags to the <program> section.
Users browsing this forum: No registered users and 10 guests