|
|
@@ -572,82 +572,84 @@ namespace BansheeEngine
|
|
|
camData.target->bindSceneColor(true);
|
|
|
|
|
|
// Render light pass
|
|
|
- SPtr<GpuParamBlockBufferCore> perCameraBuffer = mStaticHandler->getPerCameraParams().getBuffer();
|
|
|
+ {
|
|
|
+ SPtr<GpuParamBlockBufferCore> perCameraBuffer = mStaticHandler->getPerCameraParams().getBuffer();
|
|
|
|
|
|
- SPtr<MaterialCore> dirMaterial = mDirLightMat->getMaterial();
|
|
|
- SPtr<PassCore> dirPass = dirMaterial->getPass(0);
|
|
|
+ SPtr<MaterialCore> dirMaterial = mDirLightMat->getMaterial();
|
|
|
+ SPtr<PassCore> dirPass = dirMaterial->getPass(0);
|
|
|
|
|
|
- setPass(dirPass);
|
|
|
- mDirLightMat->setStaticParameters(camData.target, perCameraBuffer);
|
|
|
+ setPass(dirPass);
|
|
|
+ mDirLightMat->setStaticParameters(camData.target, perCameraBuffer);
|
|
|
|
|
|
- for (auto& light : mDirectionalLights)
|
|
|
- {
|
|
|
- if (!light.internal->getIsActive())
|
|
|
- continue;
|
|
|
+ for (auto& light : mDirectionalLights)
|
|
|
+ {
|
|
|
+ if (!light.internal->getIsActive())
|
|
|
+ continue;
|
|
|
|
|
|
- mDirLightMat->setParameters(light.internal);
|
|
|
+ mDirLightMat->setParameters(light.internal);
|
|
|
|
|
|
- // TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
|
|
|
- // - I can't think of a good way to do this automatically. Probably best to do it in setParameters()
|
|
|
- setPassParams(dirMaterial->getPassParameters(0), nullptr);
|
|
|
- gRendererUtility().drawScreenQuad();
|
|
|
- }
|
|
|
+ // TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
|
|
|
+ // - I can't think of a good way to do this automatically. Probably best to do it in setParameters()
|
|
|
+ setPassParams(dirMaterial->getPassParameters(0), nullptr);
|
|
|
+ gRendererUtility().drawScreenQuad();
|
|
|
+ }
|
|
|
|
|
|
- // Draw point lights which our camera is within
|
|
|
- SPtr<MaterialCore> pointInsideMaterial = mPointLightInMat->getMaterial();
|
|
|
- SPtr<PassCore> pointInsidePass = pointInsideMaterial->getPass(0);
|
|
|
+ // Draw point lights which our camera is within
|
|
|
+ SPtr<MaterialCore> pointInsideMaterial = mPointLightInMat->getMaterial();
|
|
|
+ SPtr<PassCore> pointInsidePass = pointInsideMaterial->getPass(0);
|
|
|
|
|
|
- // TODO - Possibly use instanced drawing here as only two meshes are drawn with various properties
|
|
|
- setPass(pointInsidePass);
|
|
|
- mPointLightInMat->setStaticParameters(camData.target, perCameraBuffer);
|
|
|
+ // TODO - Possibly use instanced drawing here as only two meshes are drawn with various properties
|
|
|
+ setPass(pointInsidePass);
|
|
|
+ mPointLightInMat->setStaticParameters(camData.target, perCameraBuffer);
|
|
|
|
|
|
- // TODO - Cull lights based on visibility, right now I just iterate over all of them.
|
|
|
- for (auto& light : mPointLights)
|
|
|
- {
|
|
|
- if (!light.internal->getIsActive())
|
|
|
- continue;
|
|
|
+ // TODO - Cull lights based on visibility, right now I just iterate over all of them.
|
|
|
+ for (auto& light : mPointLights)
|
|
|
+ {
|
|
|
+ if (!light.internal->getIsActive())
|
|
|
+ continue;
|
|
|
|
|
|
- float distToLight = (light.internal->getBounds().getCenter() - camera->getPosition()).squaredLength();
|
|
|
- float boundRadius = light.internal->getBounds().getRadius() * 1.05f + camera->getNearClipDistance() * 2.0f;
|
|
|
+ float distToLight = (light.internal->getBounds().getCenter() - camera->getPosition()).squaredLength();
|
|
|
+ float boundRadius = light.internal->getBounds().getRadius() * 1.05f + camera->getNearClipDistance() * 2.0f;
|
|
|
|
|
|
- bool cameraInLightGeometry = distToLight < boundRadius * boundRadius;
|
|
|
- if (!cameraInLightGeometry)
|
|
|
- continue;
|
|
|
+ bool cameraInLightGeometry = distToLight < boundRadius * boundRadius;
|
|
|
+ if (!cameraInLightGeometry)
|
|
|
+ continue;
|
|
|
|
|
|
- mPointLightInMat->setParameters(light.internal);
|
|
|
+ mPointLightInMat->setParameters(light.internal);
|
|
|
|
|
|
- // TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
|
|
|
- // - I can't think of a good way to do this automatically. Probably best to do it in setParameters()
|
|
|
- setPassParams(pointInsideMaterial->getPassParameters(0), nullptr);
|
|
|
- SPtr<MeshCore> mesh = light.internal->getMesh();
|
|
|
- gRendererUtility().draw(mesh, mesh->getProperties().getSubMesh(0));
|
|
|
- }
|
|
|
+ // TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
|
|
|
+ // - I can't think of a good way to do this automatically. Probably best to do it in setParameters()
|
|
|
+ setPassParams(pointInsideMaterial->getPassParameters(0), nullptr);
|
|
|
+ SPtr<MeshCore> mesh = light.internal->getMesh();
|
|
|
+ gRendererUtility().draw(mesh, mesh->getProperties().getSubMesh(0));
|
|
|
+ }
|
|
|
|
|
|
- // Draw other point lights
|
|
|
- SPtr<MaterialCore> pointOutsideMaterial = mPointLightOutMat->getMaterial();
|
|
|
- SPtr<PassCore> pointOutsidePass = pointOutsideMaterial->getPass(0);
|
|
|
+ // Draw other point lights
|
|
|
+ SPtr<MaterialCore> pointOutsideMaterial = mPointLightOutMat->getMaterial();
|
|
|
+ SPtr<PassCore> pointOutsidePass = pointOutsideMaterial->getPass(0);
|
|
|
|
|
|
- setPass(pointOutsidePass);
|
|
|
- mPointLightOutMat->setStaticParameters(camData.target, perCameraBuffer);
|
|
|
+ setPass(pointOutsidePass);
|
|
|
+ mPointLightOutMat->setStaticParameters(camData.target, perCameraBuffer);
|
|
|
|
|
|
- for (auto& light : mPointLights)
|
|
|
- {
|
|
|
- if (!light.internal->getIsActive())
|
|
|
- continue;
|
|
|
+ for (auto& light : mPointLights)
|
|
|
+ {
|
|
|
+ if (!light.internal->getIsActive())
|
|
|
+ continue;
|
|
|
|
|
|
- float distToLight = (light.internal->getBounds().getCenter() - camera->getPosition()).squaredLength();
|
|
|
- float boundRadius = light.internal->getBounds().getRadius() * 1.05f + camera->getNearClipDistance() * 2.0f;
|
|
|
+ float distToLight = (light.internal->getBounds().getCenter() - camera->getPosition()).squaredLength();
|
|
|
+ float boundRadius = light.internal->getBounds().getRadius() * 1.05f + camera->getNearClipDistance() * 2.0f;
|
|
|
|
|
|
- bool cameraInLightGeometry = distToLight < boundRadius * boundRadius;
|
|
|
- if (cameraInLightGeometry)
|
|
|
- continue;
|
|
|
+ bool cameraInLightGeometry = distToLight < boundRadius * boundRadius;
|
|
|
+ if (cameraInLightGeometry)
|
|
|
+ continue;
|
|
|
|
|
|
- mPointLightOutMat->setParameters(light.internal);
|
|
|
+ mPointLightOutMat->setParameters(light.internal);
|
|
|
|
|
|
- // TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
|
|
|
- setPassParams(pointOutsideMaterial->getPassParameters(0), nullptr);
|
|
|
- SPtr<MeshCore> mesh = light.internal->getMesh();
|
|
|
- gRendererUtility().draw(mesh, mesh->getProperties().getSubMesh(0));
|
|
|
+ // TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
|
|
|
+ setPassParams(pointOutsideMaterial->getPassParameters(0), nullptr);
|
|
|
+ SPtr<MeshCore> mesh = light.internal->getMesh();
|
|
|
+ gRendererUtility().draw(mesh, mesh->getProperties().getSubMesh(0));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
camData.target->bindSceneColor(false);
|