public Renderable(GraphicsDevice graphicsDevice, Sdl2Window contextWindow) { _graphicsDevice = graphicsDevice; _contextWindow = contextWindow; _factory = new DisposeCollectorResourceFactory(_graphicsDevice.ResourceFactory); _commandList = _factory.CreateCommandList(); _sceneRuntimeState = new SceneRuntimeDescriptor(); _modelPNTTBDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionNormalTextureTangentBitangent> >(); _modelPNDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionNormal> >(); _modelPTDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionTexture> >(); _modelPCDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionColor> >(); _modelPDescriptorList = new List <ModelRuntimeDescriptor <VertexPosition> >(); PNTTBRuntimeGeometry = new GeometryDescriptor <VertexPositionNormalTextureTangentBitangent>(); PNRuntimeGeometry = new GeometryDescriptor <VertexPositionNormal>(); PTRuntimeGeometry = new GeometryDescriptor <VertexPositionTexture>(); PCRuntimeGeometry = new GeometryDescriptor <VertexPositionColor>(); PRuntimeGeometry = new GeometryDescriptor <VertexPosition>(); // Tick every millisecond _frameTimer = new FrameTimer(1.0); _running = false; }
/// <summary> /// Render Commands for Mesh of Type: /// <see cref="Henzai.Geometry.VertexPositionColor"/> /// Also used in ShadowMap PrePass ///</summary> private static void GenerateCommandsForMesh_Inline <T>( CommandList commandList, ModelRuntimeDescriptor <T> modelState, int meshIndex, SceneRuntimeDescriptor sceneRuntimeDescriptor, ResourceSet[] effectResourceSets, Mesh <T> mesh, uint modelInstanceCount) where T : struct, VertexLocateable { var effectIndex = 1; var vertexBuffer = modelState.VertexBuffers[meshIndex]; var indexBuffer = modelState.IndexBuffers[meshIndex]; var cameraProjViewBuffer = sceneRuntimeDescriptor.CameraProjViewBuffer; var cameraResourceSet = sceneRuntimeDescriptor.CameraResourceSet; commandList.SetVertexBuffer(0, vertexBuffer); commandList.SetIndexBuffer(indexBuffer, IndexFormat.UInt16); commandList.UpdateBuffer(cameraProjViewBuffer, 128, mesh.World); commandList.SetGraphicsResourceSet(0, cameraResourceSet); for (int i = 0; i < effectResourceSets.Length; i++) { var resourceSet = effectResourceSets[i]; var resourceSetIndex = effectIndex + i; commandList.SetGraphicsResourceSet((uint)resourceSetIndex, resourceSet); } commandList.DrawIndexed( indexCount: mesh.Indices.Length.ToUnsigned(), instanceCount: modelInstanceCount, indexStart: 0, vertexOffset: 0, instanceStart: 0 ); }
public SubRenderable(GraphicsDevice graphicsDevice, Resolution resolution) { _graphicsDevice = graphicsDevice; _resolution = resolution; _factory = new DisposeCollectorResourceFactory(_graphicsDevice.ResourceFactory); _sceneRuntimeDescriptor = new SceneRuntimeDescriptor(); _commandList = _factory.CreateCommandList(); GenerateFramebuffer(); }
//TODO: Data driven -> should refactor so that all GenerateRenderCommandsForModelDescriptor use this structure public static void GenerateRenderCommandsForModelDescriptor(CommandList commandList, ModelRuntimeDescriptor <VertexPositionNormalTextureTangentBitangent>[] descriptorArray, SceneRuntimeDescriptor sceneRuntimeDescriptor, MeshBVH <VertexPositionNormalTextureTangentBitangent>[] meshBVHArray, RenderDescription renderDescription) { var meshCount = meshBVHArray.Length; for (int j = 0; j < meshCount; j++) { var meshBVH = meshBVHArray[j]; if (!meshBVH.AABBIsValid) { continue; } var modelStateIndex = meshBVH.ModelRuntimeIndex; var meshIndex = meshBVH.MeshRuntimeIndex; var modelState = descriptorArray[modelStateIndex]; var model = modelState.Model; var modelRenderFlag = modelState.RenderDescription.RenderModeFlag; var currentRenderState = modelRenderFlag & renderDescription.RenderModeFlag; if (currentRenderState == RenderFlags.NONE) { continue; } var renderStateArrayIndex = RenderFlags.GetArrayIndexForFlag(currentRenderState); commandList.SetPipeline(modelState.Pipelines[renderStateArrayIndex]); var effectsInstanceBuffer = modelState.InstanceBuffers[renderStateArrayIndex]; // We assume one other vertex buffer has been bound or will be bound. for (int i = 0; i < effectsInstanceBuffer.Length; i++) { commandList.SetVertexBuffer(i.ToUnsigned() + 1, effectsInstanceBuffer[i]); } var effectSets = modelState.EffectResourceSets[renderStateArrayIndex]; var mesh = model.GetMesh(j); var material = model.GetMaterial(meshIndex); RenderCommandGenerator.GenerateCommandsForPNTTB_Inline( commandList, modelState, meshIndex, sceneRuntimeDescriptor, effectSets, material, mesh, modelState.TotalInstanceCount ); } }
/// <summary> /// Render Commands for Mesh of Type: /// <see cref="Henzai.Geometry.VertexPositionNormalTextureTangentBitangent"/> ///</summary> private static void GenerateCommandsForPNTTB_Inline( CommandList commandList, ModelRuntimeDescriptor <VertexPositionNormalTextureTangentBitangent> modelState, int meshIndex, SceneRuntimeDescriptor sceneRuntimeDescriptor, ResourceSet[] effectResourceSets, RealtimeMaterial material, Mesh <VertexPositionNormalTextureTangentBitangent> mesh, uint modelInstanceCount) { var effectIndex = 5; var vertexBuffer = modelState.VertexBuffers[meshIndex]; var indexBuffer = modelState.IndexBuffers[meshIndex]; var textureResourceSet = modelState.TextureResourceSets[meshIndex]; var cameraProjViewBuffer = sceneRuntimeDescriptor.CameraProjViewBuffer; var materialBuffer = sceneRuntimeDescriptor.MaterialBuffer; var cameraResourceSet = sceneRuntimeDescriptor.CameraResourceSet; var lightResourceSet = sceneRuntimeDescriptor.LightResourceSet; var pointlightResourceSet = sceneRuntimeDescriptor.SpotLightResourceSet; var materialResourceSet = sceneRuntimeDescriptor.MaterialResourceSet; commandList.SetVertexBuffer(0, vertexBuffer); commandList.SetIndexBuffer(indexBuffer, IndexFormat.UInt16); commandList.UpdateBuffer(cameraProjViewBuffer, 128, mesh.World); commandList.SetGraphicsResourceSet(0, cameraResourceSet); // Always after SetPipeline commandList.SetGraphicsResourceSet(1, lightResourceSet); commandList.SetGraphicsResourceSet(2, pointlightResourceSet); commandList.UpdateBuffer(materialBuffer, 0, material.diffuse); commandList.UpdateBuffer(materialBuffer, 16, material.specular); commandList.UpdateBuffer(materialBuffer, 32, material.ambient); commandList.UpdateBuffer(materialBuffer, 48, material.coefficients); commandList.SetGraphicsResourceSet(3, materialResourceSet); commandList.SetGraphicsResourceSet(4, textureResourceSet); for (int i = 0; i < effectResourceSets.Length; i++) { var resourceSet = effectResourceSets[i]; var resourceSetIndex = effectIndex + i; commandList.SetGraphicsResourceSet((uint)resourceSetIndex, resourceSet); } commandList.DrawIndexed( indexCount: mesh.Indices.Length.ToUnsigned(), instanceCount: modelInstanceCount, indexStart: 0, vertexOffset: 0, instanceStart: 0 ); }
public Renderable(string title, Resolution windowSize, GraphicsDeviceOptions graphicsDeviceOptions, RenderOptions renderOptions) { WindowCreateInfo windowCI = new WindowCreateInfo() { X = 100, Y = 100, WindowWidth = windowSize.Horizontal, WindowHeight = windowSize.Vertical, WindowTitle = title }; _contextWindow = VeldridStartup.CreateWindow(ref windowCI); if (renderOptions.UsePreferredGraphicsBackend) { _graphicsDevice = VeldridStartup.CreateGraphicsDevice(_contextWindow, graphicsDeviceOptions, renderOptions.PreferredGraphicsBackend); } else { _graphicsDevice = VeldridStartup.CreateGraphicsDevice(_contextWindow, graphicsDeviceOptions); } _renderOptions = renderOptions; _contextWindow.Title = $"{title} / {_graphicsDevice.BackendType.ToString()}"; _factory = new DisposeCollectorResourceFactory(_graphicsDevice.ResourceFactory); _commandList = _factory.CreateCommandList(); _sceneRuntimeState = new SceneRuntimeDescriptor(); _modelPNTTBDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionNormalTextureTangentBitangent> >(); _modelPNDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionNormal> >(); _modelPTDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionTexture> >(); _modelPCDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionColor> >(); _modelPDescriptorList = new List <ModelRuntimeDescriptor <VertexPosition> >(); PNTTBRuntimeGeometry = new GeometryDescriptor <VertexPositionNormalTextureTangentBitangent>(); PNRuntimeGeometry = new GeometryDescriptor <VertexPositionNormal>(); PTRuntimeGeometry = new GeometryDescriptor <VertexPositionTexture>(); PCRuntimeGeometry = new GeometryDescriptor <VertexPositionColor>(); PRuntimeGeometry = new GeometryDescriptor <VertexPosition>(); // Tick every millisecond _frameTimer = new FrameTimer(1.0); _running = false; }
public static void GenerateRenderCommandsForCubeMapModelDescriptor(CommandList commandList, ModelRuntimeDescriptor <VertexPosition> cubeMapRuntimeDescriptor, SceneRuntimeDescriptor sceneRuntimeDescriptor) { var model = cubeMapRuntimeDescriptor.Model; commandList.SetPipeline(cubeMapRuntimeDescriptor.Pipelines[RenderFlags.NORMAL_ARRAY_INDEX]); for (int i = 0; i < model.MeshCount; i++) { var mesh = model.GetMesh(i); RenderCommandGenerator.GenerateCommandsForP_Inline( commandList, cubeMapRuntimeDescriptor, i, sceneRuntimeDescriptor, cubeMapRuntimeDescriptor.EffectResourceSets[RenderFlags.NORMAL_ARRAY_INDEX], mesh, cubeMapRuntimeDescriptor.TotalInstanceCount ); } }
/// <summary> // Only used for cube maps for now! /// Render Commands for Mesh of Type: /// <see cref="Henzai.Geometry.VertexPosition"/> ///</summary> private static void GenerateCommandsForP_Inline( CommandList commandList, ModelRuntimeDescriptor <VertexPosition> modelState, int meshIndex, SceneRuntimeDescriptor sceneRuntimeDescriptor, ResourceSet[] effectResourceSets, Mesh <VertexPosition> mesh, uint modelInstanceCount) { var effectIndex = 2; var vertexBuffer = modelState.VertexBuffers[meshIndex]; var indexBuffer = modelState.IndexBuffers[meshIndex]; var textureResourceSet = modelState.TextureResourceSets[meshIndex]; var cameraProjViewBuffer = sceneRuntimeDescriptor.CameraProjViewBuffer; var cameraResourceSet = sceneRuntimeDescriptor.CameraResourceSet; commandList.SetVertexBuffer(0, vertexBuffer); commandList.SetIndexBuffer(indexBuffer, IndexFormat.UInt16); commandList.UpdateBuffer(cameraProjViewBuffer, 128, mesh.World); commandList.SetGraphicsResourceSet(0, cameraResourceSet); // Always after SetPipeline commandList.SetGraphicsResourceSet(1, textureResourceSet); for (int i = 0; i < effectResourceSets.Length; i++) { var resourceSet = effectResourceSets[i]; var resourceSetIndex = effectIndex + i; commandList.SetGraphicsResourceSet((uint)resourceSetIndex, resourceSet); } commandList.DrawIndexed( indexCount: mesh.Indices.Length.ToUnsigned(), instanceCount: modelInstanceCount, indexStart: 0, vertexOffset: 0, instanceStart: 0 ); }
public static void GenerateRenderCommandsForModelDescriptor <T>(CommandList commandList, ModelRuntimeDescriptor <T>[] descriptorArray, SceneRuntimeDescriptor sceneRuntimeDescriptor, RenderDescription renderDescription, VertexRuntimeTypes vertexRuntimeType) where T : struct, VertexLocateable { for (int j = 0; j < descriptorArray.Length; j++) { var modelState = descriptorArray[j]; var modelRenderFlag = modelState.RenderDescription.RenderModeFlag; var currentRenderState = modelRenderFlag & renderDescription.RenderModeFlag; if (currentRenderState == RenderFlags.NONE) { continue; } var renderStateArrayIndex = RenderFlags.GetArrayIndexForFlag(currentRenderState); commandList.SetPipeline(modelState.Pipelines[renderStateArrayIndex]); var effectsInstanceBuffer = modelState.InstanceBuffers[renderStateArrayIndex]; // We assume one other vertex buffer has been bound or will be bound. for (int i = 0; i < effectsInstanceBuffer.Length; i++) { commandList.SetVertexBuffer(i.ToUnsigned() + 1, effectsInstanceBuffer[i]); } var effectSets = modelState.EffectResourceSets[renderStateArrayIndex]; var model = modelState.Model; for (int i = 0; i < model.MeshCount; i++) { if (!model.GetMeshBVH(i).AABBIsValid) { continue; } var mesh = model.GetMesh(i); var material = model.GetMaterial(i); //TODO: @Investiagte this if ((renderDescription.RenderModeFlag & RenderFlags.SHADOW_MAP) == RenderFlags.SHADOW_MAP || (renderDescription.RenderModeFlag & RenderFlags.OMNI_SHADOW_MAPS) == RenderFlags.OMNI_SHADOW_MAPS || vertexRuntimeType == VertexRuntimeTypes.VertexPositionColor) { RenderCommandGenerator.GenerateCommandsForMesh_Inline( commandList, modelState, i, sceneRuntimeDescriptor, effectSets, mesh, modelState.TotalInstanceCount ); } else { switch (vertexRuntimeType) { case VertexRuntimeTypes.VertexPosition: RenderCommandGenerator.GenerateCommandsForP_Inline( commandList, modelState as ModelRuntimeDescriptor <VertexPosition>, i, sceneRuntimeDescriptor, effectSets, mesh as Mesh <VertexPosition>, modelState.TotalInstanceCount ); break; case VertexRuntimeTypes.VertexPositionTexture: RenderCommandGenerator.GenerateCommandsForPT_Inline( commandList, modelState as ModelRuntimeDescriptor <VertexPositionTexture>, i, sceneRuntimeDescriptor, effectSets, mesh as Mesh <VertexPositionTexture>, modelState.TotalInstanceCount ); break; case VertexRuntimeTypes.VertexPositionNormal: RenderCommandGenerator.GenerateCommandsForPN_Inline( commandList, modelState as ModelRuntimeDescriptor <VertexPositionNormal>, i, sceneRuntimeDescriptor, effectSets, material, mesh as Mesh <VertexPositionNormal>, modelState.TotalInstanceCount ); break; case VertexRuntimeTypes.VertexPositionNormalTextureTangentBitangent: RenderCommandGenerator.GenerateCommandsForPNTTB_Inline( commandList, modelState as ModelRuntimeDescriptor <VertexPositionNormalTextureTangentBitangent>, i, sceneRuntimeDescriptor, effectSets, material, mesh as Mesh <VertexPositionNormalTextureTangentBitangent>, modelState.TotalInstanceCount ); break; default: var errorStr = "Type: " + typeof(T).Name + " not implemented"; throw new System.NotImplementedException(errorStr); } } } } }
/// <summary> /// Sets delegates for runtime command generation. /// Also updates index and vertex buffers, sets pipeline /// </summary> /// <param name="modelDescriptor">Model descriptor.</param> /// <param name="sceneRuntimeDescriptor">Scene runtime descriptor.</param> /// <param name="instancingData">Instance data enumerable.</param> /// <typeparam name="T">The type of Vertex sent to the GPU</typeparam> protected void FillRuntimeDescriptor <T>(ModelRuntimeDescriptor <T> modelDescriptor, SceneRuntimeDescriptor sceneRuntimeDescriptor, IEnumerable <InstanceData> instancingData) where T : struct, VertexRuntime, VertexLocateable { var model = modelDescriptor.Model; modelDescriptor.TextureResourceLayout = modelDescriptor.InvokeTextureResourceLayoutGeneration(_factory); modelDescriptor.TextureSampler = modelDescriptor.InvokeSamplerGeneration(_factory); modelDescriptor.LoadShaders(_graphicsDevice); byte vertexSizeInBytes = model.GetMesh(0).Vertices[0].GetSizeInBytes(); var meshCount = model.MeshCount; for (int i = 0; i < meshCount; i++) { var mesh = model.GetMesh(i); var meshBVH = model.GetMeshBVH(i); DeviceBuffer vertexBuffer = _factory.CreateBuffer(new BufferDescription(mesh.Vertices.LengthUnsigned() * vertexSizeInBytes, BufferUsage.VertexBuffer)); DeviceBuffer indexBuffer = _factory.CreateBuffer(new BufferDescription(mesh.Indices.LengthUnsigned() * sizeof(ushort), BufferUsage.IndexBuffer)); modelDescriptor.VertexBufferList.Add(vertexBuffer); modelDescriptor.IndexBufferList.Add(indexBuffer); var allInstancePreEffects = RenderFlags.GetAllPreEffectFor(modelDescriptor.PreEffectsInstancingFlag); foreach (var instanceData in instancingData) { var instanceDataBuffer = ResourceGenerator.AllocateInstanceDataBuffer(instanceData, _graphicsDevice, _factory); if (instanceDataBuffer != null) { modelDescriptor.InstanceBufferLists[RenderFlags.NORMAL_ARRAY_INDEX].Add(instanceDataBuffer); foreach (var preEffect in allInstancePreEffects) { modelDescriptor.InstanceBufferLists[RenderFlags.GetArrayIndexForFlag(preEffect)].Add(instanceDataBuffer); } } } _graphicsDevice.UpdateBuffer <T>(vertexBuffer, 0, ref mesh.Vertices[0], (vertexSizeInBytes * mesh.VertexCount).ToUnsigned()); _graphicsDevice.UpdateBuffer <ushort>(indexBuffer, 0, ref mesh.Indices[0], (sizeof(ushort) * mesh.IndexCount).ToUnsigned()); var resourceSet = modelDescriptor.InvokeTextureResourceSetGeneration(i, _factory, _graphicsDevice); if (resourceSet != null) { modelDescriptor.TextureResourceSetsList.Add(resourceSet); } } var rasterizerStateCullBack = new RasterizerStateDescription( cullMode: FaceCullMode.Back, fillMode: PolygonFillMode.Solid, frontFace: FrontFace.Clockwise, depthClipEnabled: true, scissorTestEnabled: false ); var rasterizerStateCullFront = new RasterizerStateDescription( cullMode: FaceCullMode.Front, fillMode: PolygonFillMode.Solid, frontFace: FrontFace.Clockwise, depthClipEnabled: true, scissorTestEnabled: false ); var rasterizerStateCullNone = new RasterizerStateDescription( cullMode: FaceCullMode.None, fillMode: PolygonFillMode.Solid, frontFace: FrontFace.Clockwise, depthClipEnabled: true, scissorTestEnabled: false ); modelDescriptor.InvokeVertexLayoutGeneration(); var shadowMapIndex = RenderFlags.GetArrayIndexForFlag(RenderFlags.SHADOW_MAP); var omniShadowMapIndex = RenderFlags.GetArrayIndexForFlag(RenderFlags.OMNI_SHADOW_MAPS); modelDescriptor.Pipelines[shadowMapIndex] = modelDescriptor.ShadowMapEnabled ? _factory.CreateGraphicsPipeline(PipelineGenerator.GenerateShadowMappingPreEffectPipeline(modelDescriptor, _childrenPre[RenderFlags.GetPreEffectArrayIndexForFlag(RenderFlags.SHADOW_MAP)].SceneRuntimeDescriptor, rasterizerStateCullFront, RenderFlags.SHADOW_MAP, _childrenPre[RenderFlags.GetPreEffectArrayIndexForFlag(RenderFlags.SHADOW_MAP)].FrameBuffer)) : null; modelDescriptor.Pipelines[omniShadowMapIndex] = modelDescriptor.OmniShadowMapEnabled ? _factory.CreateGraphicsPipeline(PipelineGenerator.GenerateOmniShadowMappingPreEffectPipeline(modelDescriptor, _childrenPre[0].SceneRuntimeDescriptor, rasterizerStateCullNone, RenderFlags.OMNI_SHADOW_MAPS, _childrenPre[0].FrameBuffer)) : null; var effectLayoutArray = modelDescriptor.FillEffectsResourceSet(_factory, sceneRuntimeDescriptor, _childrenPre); var normalIndex = RenderFlags.GetArrayIndexForFlag(RenderFlags.NORMAL); switch (modelDescriptor.VertexRuntimeType) { // Only cube maps for now case VertexRuntimeTypes.VertexPosition: //TODO: Use proper constants from RenderFlags.cs modelDescriptor.Pipelines[normalIndex] = _factory.CreateGraphicsPipeline(PipelineGenerator.GeneratePipelineP(modelDescriptor, sceneRuntimeDescriptor, rasterizerStateCullFront, _graphicsDevice.SwapchainFramebuffer, effectLayoutArray)); break; case VertexRuntimeTypes.VertexPositionNormal: modelDescriptor.Pipelines[normalIndex] = _factory.CreateGraphicsPipeline(PipelineGenerator.GeneratePipelinePN(modelDescriptor, sceneRuntimeDescriptor, rasterizerStateCullBack, _graphicsDevice.SwapchainFramebuffer, effectLayoutArray)); break; case VertexRuntimeTypes.VertexPositionNormalTextureTangentBitangent: modelDescriptor.Pipelines[normalIndex] = _factory.CreateGraphicsPipeline(PipelineGenerator.GeneratePipelinePNTTB(modelDescriptor, sceneRuntimeDescriptor, rasterizerStateCullBack, _graphicsDevice.SwapchainFramebuffer, effectLayoutArray)); break; case VertexRuntimeTypes.VertexPositionColor: modelDescriptor.Pipelines[normalIndex] = _factory.CreateGraphicsPipeline(PipelineGenerator.GeneratePipelinePC(modelDescriptor, sceneRuntimeDescriptor, rasterizerStateCullBack, _graphicsDevice.SwapchainFramebuffer, effectLayoutArray)); break; case VertexRuntimeTypes.VertexPositionTexture: modelDescriptor.Pipelines[normalIndex] = _factory.CreateGraphicsPipeline(PipelineGenerator.GeneratePipelinePT(modelDescriptor, sceneRuntimeDescriptor, rasterizerStateCullBack, _graphicsDevice.SwapchainFramebuffer, effectLayoutArray)); break; default: throw new NotImplementedException($"{modelDescriptor.VertexRuntimeType.ToString("g")} not implemented"); } }
/// <summary> /// Creates resources used to render e.g. Buffers, Textures etc. /// </summary> abstract public void CreateResources(SceneRuntimeDescriptor SceneRuntimeDescriptor, ModelRuntimeDescriptor <VertexPositionNormalTextureTangentBitangent>[] modelPNTTBDescriptorArray, ModelRuntimeDescriptor <VertexPositionNormal>[] modelPNDescriptorArray, ModelRuntimeDescriptor <VertexPositionTexture>[] modelPTDescriptorArray, ModelRuntimeDescriptor <VertexPositionColor>[] modelPCDescriptorArray);
public ResourceLayout[] FillEffectsResourceSet(DisposeCollectorResourceFactory factory, SceneRuntimeDescriptor sceneRuntimeDescriptor, List <SubRenderable> childrenPre) { var effectLayoutList = new List <ResourceLayout>(); //TODO: just iterate over children and process them as Subrenderable !! if (ShadowMapEnabled) { var effectCount = RenderFlags.GetSizeOfPreEffectFlag(PreEffectsFlag) * 2; // 1 for Vertex Stage 1 for Fragment EffectResourceSets[RenderFlags.NORMAL_ARRAY_INDEX] = new ResourceSet[effectCount]; var shadowMapRenderable = childrenPre[0] as ShadowMap; var shadowMapResourceLayout = ResourceGenerator.GenerateTextureResourceLayoutForShadowMapping(factory); effectLayoutList.Add(sceneRuntimeDescriptor.LightProvViewResourceLayout); effectLayoutList.Add(shadowMapResourceLayout); EffectResourceSets[RenderFlags.NORMAL_ARRAY_INDEX][RenderFlags.GetPreEffectArrayIndexForFlag(RenderFlags.SHADOW_MAP)] = sceneRuntimeDescriptor.LightProjViewResourceSet; EffectResourceSets[RenderFlags.NORMAL_ARRAY_INDEX][RenderFlags.GetPreEffectArrayIndexForFlag(RenderFlags.SHADOW_MAP) + 1] = ResourceGenerator.GenerateResourceSetForShadowMapping(shadowMapResourceLayout, shadowMapRenderable.ShadowMapTexView, factory); } if (OmniShadowMapEnabled) { var effectCount = 2; EffectResourceSets[RenderFlags.NORMAL_ARRAY_INDEX] = new ResourceSet[effectCount]; EffectResourceSets[RenderFlags.OMNI_SHADOW_MAPS] = new ResourceSet[2]; //var omniShadowMapRenderable = childrenPre[RenderFlags.GetPreEffectArrayIndexForFlag(RenderFlags.OMNI_SHADOW_MAPS)] as OmniShadowMap; var omniShadowMapRenderable = childrenPre[0] as OmniShadowMap; var shadowMapResourceLayout = ResourceGenerator.GenerateTextureResourceLayoutForOmniShadowMapping(factory); //TODO: this has to be an array effectLayoutList.Add(sceneRuntimeDescriptor.CameraInfoResourceLayout); effectLayoutList.Add(shadowMapResourceLayout); EffectResourceSets[RenderFlags.NORMAL_ARRAY_INDEX][0] = sceneRuntimeDescriptor.CameraInfoResourceSet; EffectResourceSets[RenderFlags.NORMAL_ARRAY_INDEX][1] = ResourceGenerator.GenerateResourceSetForShadowMapping(shadowMapResourceLayout, omniShadowMapRenderable.ShadowMapTexView, factory); EffectResourceSets[RenderFlags.OMNI_SHADOW_MAPS][0] = omniShadowMapRenderable.ShadowMatrices; EffectResourceSets[RenderFlags.OMNI_SHADOW_MAPS][1] = omniShadowMapRenderable.CameraInfo; } return(effectLayoutList.ToArray()); }