Hi All, I spent a little time this weekend looking through the Rembrandt shader code to gain some familiarity and (naively) see if I could find any obvious performance improvement, in particular by unwrapping loops/if tests, as Rembrandt is just a little too slow on my machine to be usable.
Unfortunately most of my efforts actually made things worse, often by a factor of 2. Evidently modern GPU GLSL compilers are more advanced than I had thought, and I should be a little more humble in the future! However, I did notice a couple of things I'd like to get comments on, mainly from Fred I suspect. 1) Shaders/ssao.frag: This is the fragment shader for Ambient Occlusion. Line 54 starts a FOR loop that only executes once. I don't know enough about the shader to say whether it's a straight bug and should execute 4 times, or whether it's correct and the FOR loop can be removed. Can anyone confirm? 2) Shaders/sunlight.frag: I think I can remove the if() tests at the end of the shader (around line 95), so float cosAngIncidence = clamp(dot(normal, lightDir), 0.0, 1.0); float blinnTerm = clamp( dot( halfDir, normal ), 0.0, 1.0 ); if (cosAngIncidence > 0.0) Ispec = pow( blinnTerm, spec_emis.y * 128.0 ) * spec_emis.x * fg_SunSpecularColor.rgb; float matID = texture2D( color_tex, coords ).a * 255.0; if (matID >= 254.0) Idiff += Ispec * spec_emis.x; can be replaced with the following code: float blinnTerm = clamp( dot( halfDir, normal ), 0.0, 1.0 ); Ispec = step(0.0, dot(normal, lightDir)) * pow( blinnTerm, spec_emis.y * 128.0 ) * spec_emis.x * fg_SunSpecularColor.rgb; Idiff += step(0.996, texture2D( color_tex, coords ).a) * Ispec * spec_emis.x; // 254: Water, 255: Ubershader This doesn't improve the performance on my machine by a significant amount, but it would seem worth doing. 3) From reading Effects/sunlight.eff, I don't think sunlight.frag is ever executed with filtering == 1, (that's what sunlight-nofiltering.frag is for), so the if() test on line 70 can be removed. -Stuart ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel