SpiderPig Posted July 5, 2023 Posted July 5, 2023 I'm getting mixed and seemingly random results with the lighting of my grass. The line between light and dark moves with the camera. This is what I'm passing out of my geometry shader to the default PBR fragment shader. The grass is green as I'm setting the vertex color to green. The fragment shader is just doing the lighting. I've looked at the fragment shaders to see what it needed but might have missed something? layout(location = 25 ) out uint outEntityID; layout(location = 5 ) out flat uint outMaterialID; layout(location = 8 ) out vec4 outVertexPosition; layout(location = 1 ) out vec3 normal; layout(location = 7 ) out vec4 worldPosition; layout(location = 0 ) out vec4 vertexColor; First it was this; Now at random it is this; Quote
Josh Posted July 5, 2023 Posted July 5, 2023 Here are the inputs for the lighting function: RenderLighting(material, materialInfo, vertexWorldPosition.xyz, n, v, NdotV, f_diffuse, f_specular, renderprobes, ibldiffuse, iblspecular); 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
SpiderPig Posted July 5, 2023 Author Posted July 5, 2023 Oh, that reminds me. Inside that function in Lighting.glsl, RenderLight() was using the input vertexWorldPosition rather than the argument "position". RenderLight(lightIndex, material, materialInfo, vertexWorldPosition.xyz, normal, v, NdotV, f_diffuse, f_specular, renderprobes, ibldiffuse, iblspecular); I thought it should use the argument 'position' seeing as it is passed to it but not sure... I don't know if it's something the user could end up editing in the UserFunction? Quote
Josh Posted July 5, 2023 Posted July 5, 2023 You are correct, but since that was the variable being passed to the function anyways, it won't make any difference. Quote My job is to make tools you love, with the features you want, and performance you can't live without.
SpiderPig Posted July 5, 2023 Author Posted July 5, 2023 Just thought I'd check. If I turn off Image Based Lighting I get a darker grass but no more artifacts. Not sure if that's the cause or it's just hiding it. EDIT: I think IBL is the cause, though I have no idea why. Quote
SpiderPig Posted July 5, 2023 Author Posted July 5, 2023 Hmm, actually I don't think my normals are right... I'm multiplying the local vertex positions by a local matrix to rotate the blades but the normals are unchanged. Can I rotate normals by multiplying by the same matrix as I do the vertices? Quote
Solution Josh Posted July 5, 2023 Solution Posted July 5, 2023 You need to multiply normals by a 3x3 matrix, not a 4x4. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
SpiderPig Posted July 6, 2023 Author Posted July 6, 2023 It's a bit slow using the geometry shader. FPS drops from 800 to 300. I think compute shaders might help here. 1 Quote
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.