   Deferred rendering camera close to point light fps drop
  Hello everyone,In my game I use deferred rendering. I create bounding box for each point light and then use that box by projecting in 2D and then use scissor test to draw the required area affected by the point lights. Here is the test bench:--------------------------------------------------------------------------No.Of.PointLights | FPS.When.Camera.Far | FPS.When.Camera.Close.To.Light-------------------------------------------------------------------------- 085 85 14    84 281200   81 26---------------------------------------------------------------------------As you can see  when the camera is near to the point light position the frame rate is too low even if their are less number of lights. What could be the problem?Thanks.   
  Closer camera, more pixels to light, so most likely it's your algorithm for lighting that needs some optimizing.Try using a profiler to find your bottle neck, PIX and AMD CodeAnalyst are 2 very good profilers.   ;  Thanks for the reply.I have used PIX before but now whenever I profile my game using PIX the frame rate drops to 6-9 and when  press the frame capture key it goes out of memory and as a reusult it fails to capture all the frames. Regarding the lighting code there is nothing much. Here it is:float4 deferredLightingPointLights(float2 tex0:TEXCOORD0):COLOR{float3 position;position = tex2D(positionXYSampler, tex0).xyz;float lightRadius = 5.0f;float3 lightPositionInViewSpace = lightProperty.xyz;float invRadius = 1.0f / lightProperty.w;float3 lVec = (lightPositionInViewSpace - position);float4 output;if(length(lightPositionInViewSpace - position) > lightRadius*2)discard;float3 diffuseMaterial = tex2D(textureSampler, tex0);float3 worldNormal = 2*tex2D(normalSampler, tex0) - 1;//float3 reflectionVector = normalize(reflect(-lVec, worldNormal));float3 lightVec = normalize(lVec);float atten = saturate(1.0f - length(lVec)/lightRadius); float diffuse = max(0, dot(lightVec, worldNormal));/*if(diffuse < 0.01f)discard;*/output =  float4(atten * diffuse * diffuseMaterial, 1.0f);return output;//return float4(atten * diffuse, atten * diffuse, atten * diffuse, 1.0f);}technique LightPass{pass P0{VertexShader = NULL;PixelShader = compile ps_3_0 deferredLightingPointLights();CullMode = CCW;Zenable = false;ZWriteEnable = false;AlphaBlendEnable = true;Srcblend = One;Destblend = One;}}What could be wrong??   ;  It's normal.The more the camera is near a point light, the bigger the shaded volume is, the more are the pixels to shade, the more the computations.So when the lights are far, they are small and few pixels need to be computed => fasterI don't see anything wrong in your situation.   ;  Do you make sure that only lights that are inside of or intersecting the camera frustum get drawn?I'm wondering if for example lights behind the camera are getting drawn when they don't need to be.   ;  Thanks for the replies.No, I am currently drawing all the lights whether visible to the camera or not. But what if 14-20 lights are all visible? They are still causing a lot of frame rate drop. What should I do iluminate an apartment hallway where many lights are present and all are visible. I was thinking to extend this approach for indirect illumination by reflective shadow maps. But what if my frame rate drops like this??   ;  For lights that are behind the camera if you're not careful when projecting them to 2D you'll end up with them covering the whole screen, where you should be drawing nothing at all. That would obviously make it run much more slowly than it should.You can also increase performance (for non-full screen lights) by about 25% by using circular / spherical geometry instead of a square / cube.   ;  Using backface culling (set to only render the backfacing faces) and rendering boxes completely eliminates the overdraw problems of light behind the camera.In your shader the following are computed multiple times:lightPositionInViewSpace - positionlength(lVec)You might reuse the results.However for 1200 "fullscreen" lights, 26 FPS is _very_ good, way better than my deferred renderer. I don't think any forward renderer could beat that.   ;Original post by ayush3017No, I am currently drawing all the lights whether visible to the camera or not. quote]Start testing with point lights. Use a sphere mesh to render them. There are plenty of documentation about how to do it. If you can't obtain a sphere via code, make a unit sphere with something like 3D Studio and then import it.;  Thanks for the replies. I'll try it by drawing boxes and spheres.   