private void buttonCompute_Click(object sender, EventArgs e) { m_Probe.ComputeKMeans( integerTrackbarControlK.Value, floatTrackbarControlPosition.Value, floatTrackbarControlNormal.Value, floatTrackbarControlAlbedo.Value, floatTrackbarControlLambda.Value); ////////////////////////////////////////////////////////////////////////// // Refresh UI textBoxResults.Text = m_Probe.m_Sets.Length + " sets generated:\r\n\r\n"; for (int SetIndex = 0; SetIndex < m_Probe.m_Sets.Length; SetIndex++) { Probe.Set S = m_Probe.m_Sets[SetIndex]; textBoxResults.Text += SetIndex + ") " + S.SetPixels.Count + " pixels (" + (100.0f * S.SetPixels.Count / m_Probe.m_ScenePixels.Count).ToString("G4") + "%)\r\n" + "Albedo = (" + S.Albedo.x.ToString("G4") + ", " + S.Albedo.y.ToString("G4") + ", " + S.Albedo.z.ToString("G4") + ")\r\n\r\n"; } integerTrackbarControlSetIsolation.RangeMax = m_Probe.m_Sets.Length - 1; integerTrackbarControlSetIsolation.VisibleRangeMax = integerTrackbarControlSetIsolation.RangeMax; saveResultsToolStripMenuItem.Enabled = m_Probe.m_Sets.Length > 0; outputPanel1.UpdateBitmap(); }
private void CubeMapSamplerSetIndex(Probe.Pixel _Pixel, out byte _R, out byte _G, out byte _B) { Probe.Set S = _Pixel.ParentSet; byte C = 0; if (S != null && S.SetIndex != -1 && (!m_IsolateSet || S.SetIndex == m_IsolatedSetIndex)) { C = m_IsolateSet ? (byte)255 : (byte)(255 * (1 + S.SetIndex) / m_Probe.m_Sets.Length); } _R = _G = _B = C; }
private void CubeMapSamplerSetAlbedo(Probe.Pixel _Pixel, out byte _R, out byte _G, out byte _B) { Probe.Set S = _Pixel.ParentSet; if (S == null || S.SetIndex == -1 || (m_IsolateSet && S.SetIndex != m_IsolatedSetIndex)) { _R = _G = _B = 0; return; } _R = (byte)Math.Min(255, 255 * S.Albedo.x); _G = (byte)Math.Min(255, 255 * S.Albedo.y); _B = (byte)Math.Min(255, 255 * S.Albedo.z); }
private void CubeMapSamplerSetDistance(Probe.Pixel _Pixel, out byte _R, out byte _G, out byte _B) { Probe.Set S = _Pixel.ParentSet; if (S == null || S.SetIndex == -1 || (m_IsolateSet && S.SetIndex != m_IsolatedSetIndex)) { _R = 63; _G = 0; _B = 63; return; } float Distance2SetCenter = 0.2f * (_Pixel.Position - S.Position).Length; byte C = (byte)Math.Min(255, 255 * Distance2SetCenter); _R = _G = _B = C; }
private void buttonComputeFilling_Click(object sender, EventArgs e) { try { m_Probe.ComputeFloodFill( integerTrackbarControlK.Value, integerTrackbarControlLightSamples.Value, floatTrackbarControlPosition.Value, floatTrackbarControlNormal.Value, floatTrackbarControlAlbedo.Value, floatTrackbarControlLambda.Value); } catch (Exception _e) { MessageBox("An error occurred while encoding probe: " + _e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ////////////////////////////////////////////////////////////////////////// // Refresh UI // textBoxResults.Text = m_Probe.m_EmissiveSets.Length + " emissive sets generated\r\n"; textBoxResults.Text += m_Probe.m_Sets.Length + " sets generated:\r\n\r\n"; for (int SetIndex = 0; SetIndex < m_Probe.m_Sets.Length; SetIndex++) { Probe.Set S = m_Probe.m_Sets[SetIndex]; textBoxResults.Text += SetIndex + ") " + S.SetPixels.Count + " pixels (" + (100.0f * S.SetPixels.Count / m_Probe.m_ScenePixels.Count).ToString("G4") + "%)\r\n" + "Albedo = (" + S.Albedo.x.ToString("G4") + ", " + S.Albedo.y.ToString("G4") + ", " + S.Albedo.z.ToString("G4") + ")\r\n\r\n"; } integerTrackbarControlSetIsolation.RangeMax = m_Probe.m_Sets.Length - 1; integerTrackbarControlSetIsolation.VisibleRangeMax = integerTrackbarControlSetIsolation.RangeMax; // Send to output panel for visual debugging outputPanel1.SHStatic = m_Probe.m_StaticSH; outputPanel1.SHOcclusion = m_Probe.m_OcclusionSH; outputPanel1.SHDynamic = m_Probe.m_SHSumDynamic; outputPanel1.SHEmissive = m_Probe.m_SHSumEmissive; // radioButtonSetIndex.Checked = true; outputPanel1.UpdateBitmap(); // We can now save the results saveResultsToolStripMenuItem.Enabled = true; }
private void CubeMapSamplerSetSamples(Probe.Pixel _Pixel, out byte _R, out byte _G, out byte _B) { Probe.Set S = _Pixel.ParentSet; if (S == null || S.SetIndex == -1 || S.EmissiveMatID != -1 || (m_IsolateSet && S.SetIndex != m_IsolatedSetIndex)) { _R = 0; _G = 0; _B = 0; return; } // float Distance2SetCenter = 0.2f * (_Pixel.Position - S.Position).Length; // byte C = (byte) Math.Min( 255, 255 * Distance2SetCenter ); byte C = (byte)(255 * (1 + _Pixel.ParentSetSampleIndex) / S.Samples.Length); _R = _G = _B = C; }
private void CubeMapSamplerSetNormal(Probe.Pixel _Pixel, out byte _R, out byte _G, out byte _B) { Probe.Set S = _Pixel.ParentSet; if (S == null || S.SetIndex == -1 || (m_IsolateSet && S.SetIndex != m_IsolatedSetIndex)) { _R = _G = _B = 0; return; } #if ABS_NORMAL _R = (byte)Math.Min(255, 255 * Math.Abs(S.Normal.x)); _G = (byte)Math.Min(255, 255 * Math.Abs(S.Normal.y)); _B = (byte)Math.Min(255, 255 * Math.Abs(S.Normal.z)); #else _R = (byte)Math.Min(255, 127 * (1.0f + S.Normal.x)); _G = (byte)Math.Min(255, 127 * (1.0f + S.Normal.y)); _B = (byte)Math.Min(255, 127 * (1.0f + S.Normal.z)); #endif }