public void RenderBoundGeom(DeviceContext context, RenderableBoundGeometryInst inst) { VSEntityVars.Vars.CamRel = new Vector4(inst.Inst.CamRel, 0.0f); VSEntityVars.Vars.Orientation = inst.Inst.Orientation; VSEntityVars.Vars.Scale = inst.Inst.Scale; VSEntityVars.Vars.HasSkeleton = 0; VSEntityVars.Vars.HasTransforms = 0; //todo! bounds transforms..? VSEntityVars.Vars.TintPaletteIndex = 0; VSEntityVars.Vars.IsInstanced = 0; VSEntityVars.Update(context); VSEntityVars.SetVSCBuffer(context, 2); PSGeomVars.Vars.EnableTexture = 0; PSGeomVars.Vars.EnableTint = 0; PSGeomVars.Vars.EnableNormalMap = 0; PSGeomVars.Vars.EnableSpecMap = 0; PSGeomVars.Vars.EnableDetailMap = 0; PSGeomVars.Vars.IsDecal = 0; PSGeomVars.Vars.IsEmissive = 0; PSGeomVars.Vars.IsDistMap = 0; PSGeomVars.Vars.bumpiness = 0; PSGeomVars.Vars.AlphaScale = 1; PSGeomVars.Vars.HardAlphaBlend = 0; PSGeomVars.Vars.useTessellation = 0; PSGeomVars.Vars.detailSettings = Vector4.Zero; PSGeomVars.Vars.specMapIntMask = Vector3.Zero; PSGeomVars.Vars.specularIntensityMult = 1.0f; PSGeomVars.Vars.specularFalloffMult = 1.0f; PSGeomVars.Vars.specularFresnel = 1.0f; PSGeomVars.Vars.wetnessMultiplier = 0.0f; PSGeomVars.Vars.SpecOnly = 0; PSGeomVars.Vars.TextureAlphaMask = Vector4.Zero; PSGeomVars.Update(context); PSGeomVars.SetPSCBuffer(context, 2); VSGeomVars.Vars.EnableTint = 0; VSGeomVars.Vars.TintYVal = 0.0f; VSGeomVars.Vars.IsDecal = 0; VSGeomVars.Vars.EnableWind = 0; VSGeomVars.Vars.WindOverrideParams = Vector4.Zero; VSGeomVars.Update(context); VSGeomVars.SetVSCBuffer(context, 4); if (inst.Geom.VertexBuffer != null) //render the triangles { SetVertexShader(context, VertexType.Default); SetInputLayout(context, VertexType.Default); inst.Geom.RenderTriangles(context); } //render the boxes if (inst.Geom.BoxBuffer != null) { context.VertexShader.Set(basicvsbox); context.VertexShader.SetShaderResource(1, inst.Geom.BoxBuffer.SRV); cube.DrawInstanced(context, inst.Geom.BoxBuffer.StructCount); } //render the spheres if (inst.Geom.SphereBuffer != null) { context.VertexShader.Set(basicvssphere); context.VertexShader.SetShaderResource(1, inst.Geom.SphereBuffer.SRV); sphere.DrawInstanced(context, inst.Geom.SphereBuffer.StructCount); } //render the capsules if (inst.Geom.CapsuleBuffer != null) { context.VertexShader.Set(basicvscapsule); context.VertexShader.SetShaderResource(1, inst.Geom.CapsuleBuffer.SRV); capsule.DrawInstanced(context, inst.Geom.CapsuleBuffer.StructCount); } //render the cylinders if (inst.Geom.CylinderBuffer != null) { context.VertexShader.Set(basicvscylinder); context.VertexShader.SetShaderResource(1, inst.Geom.CylinderBuffer.SRV); cylinder.DrawInstanced(context, inst.Geom.CylinderBuffer.StructCount); } }
public void RenderLights(DeviceContext context, Camera camera, List <RenderableLODLights> lodlights) { //instanced rendering of all other lights, using appropriate shapes //blend mode: additive var ps = (MSAASampleCount > 1) ? LodLightMSPS : LodLightPS; context.VertexShader.Set(LodLightVS); context.PixelShader.Set(ps); LightVSVars.Vars.ViewProj = Matrix.Transpose(camera.ViewProjMatrix); LightVSVars.Vars.CameraPos = new Vector4(camera.Position, 0.0f); LightVSVars.Vars.LightType = 0; LightVSVars.Vars.IsLOD = 0; LightVSVars.Vars.Pad0 = 0; LightVSVars.Vars.Pad1 = 0; LightPSVars.Vars.ViewProjInv = Matrix.Transpose(camera.ViewProjInvMatrix); LightPSVars.Vars.CameraPos = new Vector4(camera.Position, 0.0f); LightPSVars.Vars.EnableShadows = 0; LightPSVars.Vars.RenderMode = 0; LightPSVars.Vars.RenderModeIndex = 1; LightPSVars.Vars.RenderSamplerCoord = 0; LightPSVars.Vars.LightType = 0; LightPSVars.Vars.IsLOD = 0; LightPSVars.Vars.SampleCount = (uint)MSAASampleCount; LightPSVars.Vars.SampleMult = 1.0f / MSAASampleCount; context.PixelShader.SetShaderResources(0, GBuffers.DepthSRV); context.PixelShader.SetShaderResources(2, GBuffers.SRVs); foreach (var rll in lodlights) { if (rll.PointsBuffer != null) { context.VertexShader.SetShaderResources(0, rll.PointsBuffer.SRV); context.PixelShader.SetShaderResources(6, rll.PointsBuffer.SRV); LightVSVars.Vars.LightType = 1; LightVSVars.Update(context); LightVSVars.SetVSCBuffer(context, 0); LightPSVars.Vars.LightType = 1; LightPSVars.Update(context); LightPSVars.SetPSCBuffer(context, 0); LightSphere.DrawInstanced(context, rll.PointsBuffer.StructCount); } if (rll.SpotsBuffer != null) { context.VertexShader.SetShaderResources(0, rll.SpotsBuffer.SRV); context.PixelShader.SetShaderResources(6, rll.SpotsBuffer.SRV); LightVSVars.Vars.LightType = 2; LightVSVars.Update(context); LightVSVars.SetVSCBuffer(context, 0); LightPSVars.Vars.LightType = 2; LightPSVars.Update(context); LightPSVars.SetPSCBuffer(context, 0); LightCone.DrawInstanced(context, rll.SpotsBuffer.StructCount); } if (rll.CapsBuffer != null) { context.VertexShader.SetShaderResources(0, rll.CapsBuffer.SRV); context.PixelShader.SetShaderResources(6, rll.CapsBuffer.SRV); LightVSVars.Vars.LightType = 4; LightVSVars.Update(context); LightVSVars.SetVSCBuffer(context, 0); LightPSVars.Vars.LightType = 4; LightPSVars.Update(context); LightPSVars.SetPSCBuffer(context, 0); LightCapsule.DrawInstanced(context, rll.CapsBuffer.StructCount); } } context.VertexShader.Set(null); context.PixelShader.Set(null); context.PixelShader.SetShaderResources(0, null, null, null); context.PixelShader.SetSamplers(0, null, null); }