internal unsafe static void Init() { m_cbCustomProjections = MyHwBuffers.CreateConstantsBuffer(sizeof(Matrix) * MAX_CUSTOM_PROJECTIONS_SIZE, "BilloardCustomProjections"); m_vs = MyShaders.CreateVs("Transparent/Billboards.hlsl"); m_vsDepthOnly = MyShaders.CreateVs("Transparent/BillboardsDepthOnly.hlsl"); m_ps = MyShaders.CreatePs("Transparent/Billboards.hlsl"); m_psDepthOnly = MyShaders.CreatePs("Transparent/BillboardsDepthOnly.hlsl"); m_psOIT = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("OIT", null) }); m_vsLit = MyShaders.CreateVs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) }); m_psLit = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) }); m_psLitOIT = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) }); m_psAlphaCutout = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null) }); m_psAlphaCutoutAndLit = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("LIT_PARTICLE", null) }); m_psAlphaCutoutOIT = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("OIT", null) }); m_psAlphaCutoutAndLitOIT = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) }); m_psDebugUniformAccum = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("DEBUG_UNIFORM_ACCUM", null) }); m_psDebugUniformAccumOIT = MyShaders.CreatePs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("DEBUG_UNIFORM_ACCUM", null), new ShaderMacro("OIT", null) }); m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.TEXCOORD0_H)); InitBillboardsIndexBuffer(); m_VB = MyHwBuffers.CreateVertexBuffer(MAX_BILLBOARDS_SIZE * 4, sizeof(MyVertexFormatPositionTextureH), BindFlags.VertexBuffer, ResourceUsage.Dynamic, null, "MyBillboardRenderer"); var stride = sizeof(MyBillboardData); m_SB = MyHwBuffers.CreateStructuredBuffer(MAX_BILLBOARDS_SIZE, stride, true, null, "MyBillboardRenderer"); m_atlas = new MyTextureAtlas("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai"); }
internal unsafe static void Init() { m_vs = MyShaders.CreateVs("billboard.hlsl", "vs"); m_ps = MyShaders.CreatePs("billboard.hlsl", "ps"); m_vsLit = MyShaders.CreateVs("billboard.hlsl", "vs", MyShaderHelpers.FormatMacros("LIT_PARTICLE")); m_psLit = MyShaders.CreatePs("billboard.hlsl", "ps", MyShaderHelpers.FormatMacros("LIT_PARTICLE")); m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.TEXCOORD0_H)); //MyCallbacks.RegisterDeviceResetListener(new OnDeviceResetDelegate(OnDeviceRestart)); InitBillboardsIndexBuffer(MaxBillboards); m_VB = MyHwBuffers.CreateVertexBuffer(MaxBillboards * 4, sizeof(MyVertexFormatPositionTextureH), BindFlags.VertexBuffer, ResourceUsage.Dynamic); var stride = sizeof(MyBillboardData); m_SB = MyHwBuffers.CreateStructuredBuffer(MaxBillboards, stride, true); MyTextureAtlas.ParseAtlasDescription("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai", m_atlasedTextures); }
internal static unsafe void Init() { m_cbCustomProjections = MyManagers.Buffers.CreateConstantBuffer("BilloardCustomProjections", sizeof(Matrix) * MAX_CUSTOM_PROJECTIONS_SIZE, usage: ResourceUsage.Dynamic); GeneratePS(); m_vs = MyShaders.CreateVs("Transparent/Billboards.hlsl"); m_vsLit = MyShaders.CreateVs("Transparent/Billboards.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) }); m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.TEXCOORD0_H)); InitBillboardsIndexBuffer(); m_VB = MyManagers.Buffers.CreateVertexBuffer("MyBillboardRenderer", MAX_BILLBOARDS_SIZE * 4, sizeof(MyVertexFormatPositionTextureH), usage: ResourceUsage.Dynamic); var stride = sizeof(MyBillboardData); m_SB = MyManagers.Buffers.CreateSrv( "MyBillboardRenderer", MAX_BILLBOARDS_SIZE, stride, usage: ResourceUsage.Dynamic); m_atlas = new MyTextureAtlas("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai"); }
internal unsafe static void Init() { m_vs = MyShaders.CreateVs("billboard.hlsl"); m_ps = MyShaders.CreatePs("billboard.hlsl"); m_vsLit = MyShaders.CreateVs("billboard.hlsl", new [] { new ShaderMacro("LIT_PARTICLE", null) }); m_psLit = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) }); m_psAlphaCutout = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null) }); m_psAlphaCutoutAndLit = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("LIT_PARTICLE", null) }); m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.TEXCOORD0_H)); //MyCallbacks.RegisterDeviceResetListener(new OnDeviceResetDelegate(OnDeviceRestart)); InitBillboardsIndexBuffer(MaxBillboards); m_VB = MyHwBuffers.CreateVertexBuffer(MaxBillboards * 4, sizeof(MyVertexFormatPositionTextureH), BindFlags.VertexBuffer, ResourceUsage.Dynamic, null, "MyBillboardRenderer"); var stride = sizeof(MyBillboardData); m_SB = MyHwBuffers.CreateStructuredBuffer(MaxBillboards, stride, true, null, "MyBillboardRenderer"); m_atlas = new MyTextureAtlas("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai"); }
private static MyTextureAtlas LoadTextureAtlas(string textureDir, string atlasFile) { var atlas = new MyTextureAtlas(64); var fsPath = Path.Combine(MyFileSystem.ContentPath, atlasFile); using (var stream = MyFileSystem.OpenRead(fsPath)) using (StreamReader sr = new StreamReader(stream)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.StartsWith("#")) continue; if (line.Trim(' ').Length == 0) continue; string[] parts = line.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries); string name = parts[0]; string atlasName = parts[1]; Vector4 uv = new Vector4( Convert.ToSingle(parts[4], System.Globalization.CultureInfo.InvariantCulture), Convert.ToSingle(parts[5], System.Globalization.CultureInfo.InvariantCulture), Convert.ToSingle(parts[7], System.Globalization.CultureInfo.InvariantCulture), Convert.ToSingle(parts[8], System.Globalization.CultureInfo.InvariantCulture)); string atlasTexture = textureDir + atlasName; MyTextureAtlasItem item = new MyTextureAtlasItem(atlasTexture, uv); atlas.Add(name, item); } } return atlas; }
private static MyTextureAtlas LoadTextureAtlas(string textureDir, string atlasFile) { var fsPath = Path.Combine(MyFileSystem.ContentPath, atlasFile); if (!File.Exists(fsPath)) { MyLog.Default.WriteLine("Warning: " + atlasFile + " not found."); return null; } try { var atlas = new MyTextureAtlas(64); using (var file = MyFileSystem.OpenRead(fsPath)) using (StreamReader sr = new StreamReader(file)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.StartsWith("#")) continue; if (line.Trim(' ').Length == 0) continue; string[] parts = line.Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries); string name = parts[0]; string atlasName = parts[1]; Vector4 uv = new Vector4( Convert.ToSingle(parts[4], System.Globalization.CultureInfo.InvariantCulture), Convert.ToSingle(parts[5], System.Globalization.CultureInfo.InvariantCulture), Convert.ToSingle(parts[7], System.Globalization.CultureInfo.InvariantCulture), Convert.ToSingle(parts[8], System.Globalization.CultureInfo.InvariantCulture)); MyTexture2D atlasTexture = MyTextureManager.GetTexture<MyTexture2D>(textureDir + atlasName); MyTextureAtlasItem item = new MyTextureAtlasItem(atlasTexture, uv); atlas.Add(name, item); } } return atlas; } catch (Exception e) { MyLog.Default.WriteLine("Warning: " + e.ToString()); } return null; }
internal unsafe static void Init() { m_cbCustomProjections = MyHwBuffers.CreateConstantsBuffer(sizeof(Matrix) * MAX_CUSTOM_PROJECTIONS_SIZE, "BilloardCustomProjections"); m_vs = MyShaders.CreateVs("billboard.hlsl"); m_vsDepthOnly = MyShaders.CreateVs("billboard_depth_only.hlsl"); m_ps = MyShaders.CreatePs("billboard.hlsl"); m_psDepthOnly = MyShaders.CreatePs("billboard_depth_only.hlsl"); m_psOIT = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("OIT", null) }); m_vsLit = MyShaders.CreateVs("billboard.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) }); m_psLit = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) }); m_psLitOIT = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) }); m_psAlphaCutout = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null) }); m_psAlphaCutoutAndLit = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("LIT_PARTICLE", null) }); m_psAlphaCutoutOIT = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("OIT", null) }); m_psAlphaCutoutAndLitOIT = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("LIT_PARTICLE", null), new ShaderMacro("OIT", null) }); m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.TEXCOORD0_H)); InitBillboardsIndexBuffer(); m_VB = MyHwBuffers.CreateVertexBuffer(MAX_BILLBOARDS_SIZE * 4, sizeof(MyVertexFormatPositionTextureH), BindFlags.VertexBuffer, ResourceUsage.Dynamic, null, "MyBillboardRenderer"); var stride = sizeof(MyBillboardData); m_SB = MyHwBuffers.CreateStructuredBuffer(MAX_BILLBOARDS_SIZE, stride, true, null, "MyBillboardRenderer"); m_atlas = new MyTextureAtlas("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai"); }
internal unsafe static void Init() { m_vs = MyShaders.CreateVs("billboard.hlsl"); m_ps = MyShaders.CreatePs("billboard.hlsl"); m_vsLit = MyShaders.CreateVs("billboard.hlsl", new [] {new ShaderMacro("LIT_PARTICLE", null)}); m_psLit = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("LIT_PARTICLE", null) }); m_psAlphaCutout = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null) }); m_psAlphaCutoutAndLit = MyShaders.CreatePs("billboard.hlsl", new[] { new ShaderMacro("ALPHA_CUTOUT", null), new ShaderMacro("LIT_PARTICLE", null) }); m_inputLayout = MyShaders.CreateIL(m_vs.BytecodeId, MyVertexLayouts.GetLayout(MyVertexInputComponentType.POSITION3, MyVertexInputComponentType.TEXCOORD0_H)); //MyCallbacks.RegisterDeviceResetListener(new OnDeviceResetDelegate(OnDeviceRestart)); InitBillboardsIndexBuffer(MaxBillboards); m_VB = MyHwBuffers.CreateVertexBuffer(MaxBillboards * 4, sizeof(MyVertexFormatPositionTextureH), BindFlags.VertexBuffer, ResourceUsage.Dynamic, null, "MyBillboardRenderer"); var stride = sizeof(MyBillboardData); m_SB = MyHwBuffers.CreateStructuredBuffer(MaxBillboards, stride, true, null, "MyBillboardRenderer"); m_atlas = new MyTextureAtlas("Textures\\Particles\\", "Textures\\Particles\\ParticlesAtlas.tai"); }