private TextureHelper CreateInfo(int slice) { TextureHelper info = new TextureHelper(); info.Slice = slice; if (FInput[slice] != null) { info.ResolutionX = FInput[slice].ResolutionX; info.ResolutionY = FInput[slice].ResolutionY; } return info; }
Texture CreateTex(TextureHelper info, Device device) { var pool = Pool.Managed; var usage = Usage.None; if (device is DeviceEx) { pool = Pool.Default; usage = Usage.Dynamic; } return new Texture(device, info.ResolutionX, info.ResolutionY, 1, usage, Format.A32B32G32R32F, pool); }
TextureResource<TextureHelper> CreateNormResource(TextureHelper info) { return TextureResource.Create(info, CreateTex, UpdateNorm); }
unsafe void UpdateNorm(TextureHelper info, Texture tex) { if (FInput[info.Slice] != null) { var rect = tex.LockRectangle(0, LockFlags.None); rect.Data.Position = 0; int i=0; int pitch = 0; var enumerator = FInput[info.Slice].Normals.GetEnumerator(); while (enumerator.MoveNext()) { var norm = enumerator.Current; rect.Data.Write((float)norm.x); rect.Data.Write((float)norm.y); rect.Data.Write((float)norm.z); rect.Data.Write((float)1.0); i++; if (i>=info.ResolutionX) { i=0; pitch += rect.Pitch; rect.Data.Position = pitch; } } tex.UnlockRectangle(0); } }