| 870 | } |
| 871 | |
| 872 | void BindlessDeferred::InitializeScene() |
| 873 | { |
| 874 | currentModel = &sceneModels[uint64(AppSettings::CurrentScene)]; |
| 875 | meshRenderer.Shutdown(); |
| 876 | DX12::FlushGPU(); |
| 877 | meshRenderer.Initialize(currentModel); |
| 878 | |
| 879 | camera.SetPosition(SceneCameraPositions[uint64(AppSettings::CurrentScene)]); |
| 880 | camera.SetXRotation(SceneCameraRotations[uint64(AppSettings::CurrentScene)].x); |
| 881 | camera.SetYRotation(SceneCameraRotations[uint64(AppSettings::CurrentScene)].y); |
| 882 | |
| 883 | for(uint64 msaaMode = 0; msaaMode < uint64(MSAAModes::NumValues); ++msaaMode) |
| 884 | { |
| 885 | const uint32 msaa = msaaMode > 0; |
| 886 | const uint32 numMSAASamples = AppSettings::NumMSAASamples(MSAAModes(msaaMode)); |
| 887 | |
| 888 | for(uint32 computeUVGradients = 0; computeUVGradients < 2; ++computeUVGradients) |
| 889 | { |
| 890 | // Compile deferred shaders |
| 891 | CompileOptions opts; |
| 892 | opts.Add("MSAA_", msaa); |
| 893 | opts.Add("NumMSAASamples_", numMSAASamples); |
| 894 | opts.Add("ShadePerSample_", 0); |
| 895 | opts.Add("NumMaterialTextures_", uint32(currentModel->MaterialTextures().Count())); |
| 896 | opts.Add("ComputeUVGradients_", computeUVGradients); |
| 897 | deferredCS[msaaMode][computeUVGradients][0] = CompileFromFile(L"Deferred.hlsl", "DeferredCS", ShaderType::Compute, ShaderProfile::SM51, opts); |
| 898 | |
| 899 | if(msaa) |
| 900 | { |
| 901 | opts.Reset(); |
| 902 | opts.Add("MSAA_", msaa); |
| 903 | opts.Add("NumMSAASamples_", numMSAASamples); |
| 904 | opts.Add("ShadePerSample_", 1); |
| 905 | opts.Add("NumMaterialTextures_", uint32(currentModel->MaterialTextures().Count())); |
| 906 | opts.Add("ComputeUVGradients_", computeUVGradients); |
| 907 | deferredCS[msaaMode][computeUVGradients][1] = CompileFromFile(L"Deferred.hlsl", "DeferredCS", ShaderType::Compute, ShaderProfile::SM51, opts); |
| 908 | } |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | { |
| 913 | // Initialize the spotlight buffer |
| 914 | const uint64 numSpotLights = Min(currentModel->SpotLights().Size(), AppSettings::MaxSpotLights); |
| 915 | spotLights.Init(numSpotLights); |
| 916 | |
| 917 | for(uint64 i = 0; i < numSpotLights; ++i) |
| 918 | { |
| 919 | const ModelSpotLight& srcLight = currentModel->SpotLights()[i]; |
| 920 | |
| 921 | SpotLight& spotLight = spotLights[i]; |
| 922 | spotLight.Position = srcLight.Position; |
| 923 | spotLight.Direction = -srcLight.Direction; |
| 924 | spotLight.Intensity = srcLight.Intensity * 25.0f; |
| 925 | spotLight.AngularAttenuation = Float2(std::cos(srcLight.AngularAttenuation.x * 0.5f), std::cos(srcLight.AngularAttenuation.y * 0.5f)); |
| 926 | spotLight.Range = AppSettings::SpotLightRange; |
| 927 | } |
| 928 | |
| 929 | StructuredBufferInit sbInit; |
nothing calls this directly
no test coverage detected