public PlayerFallsEvent(uint session_id, uint player_id, DateTime time, Vector3 pos, SURFACE_TYPE surface_name) : base(session_id, player_id, time) { x = pos.x; y = pos.y; z = pos.z; surface = (int)surface_name; }
/// <summary> /// Called by the automation form to change the surface type /// </summary> /// <param name="_type"></param> public void SetSurfaceType( SURFACE_TYPE _type ) { switch ( _type ) { case SURFACE_TYPE.CONDUCTOR: radioButtonConductor.Checked = true; break; case SURFACE_TYPE.DIELECTRIC: radioButtonDielectric.Checked = true; break; case SURFACE_TYPE.DIFFUSE: radioButtonDiffuse.Checked = true; break; } }
public void AddPlayerFallEvent(SURFACE_TYPE type) { SendEventData(new PlayerFallsEvent(SessionID, PlayerID, System.DateTime.Now, ellen.transform.position, type)); }
/// <summary> /// Performs a ray-tracing of the surface /// Outputs resulting directions into a texture then performs a histogram /// /// The surface is assigned a beam of photons, one for each texel of the heightfield texture /// At each iteration, the whole beam is offset a little using a Hammersley sequence that guarantees /// we end up ray-tracing the entire surface finely (hopefully, the full surface can be traced using enough terationsi) /// </summary> /// <param name="_roughness">Surface roughness</param> /// <param name="_albedo">Surface albedo for diffuse or F0 for dielectrics</param> /// <param name="_surfaceType">Type of surface we're simulating</param> /// <param name="_theta">Vertical angle of incidence</param> /// <param name="_phi">Azimuthal angle of incidence</param> /// <param name="_iterationsCount">Amount of iterations of beam tracing</param> public void RayTraceSurface( float _roughness, float _albedoF0, SURFACE_TYPE _surfaceType, float _theta, float _phi, int _iterationsCount ) { float sinTheta = (float) Math.Sin( _theta ); float cosTheta = (float) Math.Cos( _theta ); float sinPhi = (float) Math.Sin( _phi ); float cosPhi = (float) Math.Cos( _phi ); m_lastComputedDirection.Set( -sinTheta * cosPhi, -sinTheta * sinPhi, -cosTheta ); // Minus sign because we need the direction pointing TOWARD the surface (i.e. z < 0) m_lastComputedRoughness = _roughness; m_lastComputedAlbedo = _albedoF0; m_lastComputedIOR = Fresnel_IORFromF0( _albedoF0 ); m_lastComputedSurfaceType = _surfaceType; m_lastComputedHistogramIterationsCount = _iterationsCount; m_CB_RayTrace.m._Direction = m_lastComputedDirection; m_CB_RayTrace.m._Roughness = m_lastComputedRoughness; m_CB_RayTrace.m._Albedo = m_lastComputedAlbedo; m_CB_RayTrace.m._IOR = m_lastComputedIOR; m_Tex_OutgoingDirections_Reflected.RemoveFromLastAssignedSlots(); m_Tex_OutgoingDirections_Transmitted.RemoveFromLastAssignedSlots(); m_Tex_LobeHistogram_Reflected.RemoveFromLastAssignedSlots(); m_Tex_LobeHistogram_Transmitted.RemoveFromLastAssignedSlots(); m_Device.Clear( m_Tex_LobeHistogram_Reflected_Decimal, float4.Zero ); // Clear counters m_Device.Clear( m_Tex_LobeHistogram_Reflected_Integer, float4.Zero ); m_Device.Clear( m_Tex_LobeHistogram_Transmitted_Decimal, float4.Zero ); // Clear counters m_Device.Clear( m_Tex_LobeHistogram_Transmitted_Integer, float4.Zero ); WMath.Hammersley pRNG = new WMath.Hammersley(); double[,] sequence = pRNG.BuildSequence( _iterationsCount, 2 ); for ( int iterationIndex=0; iterationIndex < _iterationsCount; iterationIndex++ ) { // 1] Ray-trace surface switch ( m_lastComputedSurfaceType ) { case SURFACE_TYPE.CONDUCTOR: if ( m_Shader_RayTraceSurface_Conductor.Use() ) { // Update trace offset m_CB_RayTrace.m._Offset.Set( (float) sequence[iterationIndex,0], (float) sequence[iterationIndex,1] ); m_CB_RayTrace.UpdateData(); m_Device.Clear( m_Tex_OutgoingDirections_Reflected, float4.Zero ); // Clear target directions and weights m_Tex_Heightfield.SetCS( 0 ); m_Tex_Random.SetCS( 1 ); m_Tex_OutgoingDirections_Reflected.SetCSUAV( 0 ); // New target buffer where to accumulate m_Shader_RayTraceSurface_Conductor.Dispatch( HEIGHTFIELD_SIZE >> 4, HEIGHTFIELD_SIZE >> 4, 1 ); m_Tex_OutgoingDirections_Reflected.RemoveFromLastAssignedSlotUAV(); } // 2] Accumulate into target histogram if ( m_Shader_AccumulateOutgoingDirections.Use() ) { m_Tex_OutgoingDirections_Reflected.SetCS( 0 ); m_Tex_LobeHistogram_Reflected_Decimal.SetCSUAV( 0 ); m_Tex_LobeHistogram_Reflected_Integer.SetCSUAV( 1 ); m_Shader_AccumulateOutgoingDirections.Dispatch( HEIGHTFIELD_SIZE >> 4, HEIGHTFIELD_SIZE >> 4, MAX_SCATTERING_ORDER ); m_Tex_LobeHistogram_Reflected_Decimal.RemoveFromLastAssignedSlotUAV(); m_Tex_LobeHistogram_Reflected_Integer.RemoveFromLastAssignedSlotUAV(); m_Tex_OutgoingDirections_Reflected.RemoveFromLastAssignedSlots(); } break; case SURFACE_TYPE.DIELECTRIC: if ( m_Shader_RayTraceSurface_Dielectric.Use() ) { // Update trace offset m_CB_RayTrace.m._Offset.Set( (float) sequence[iterationIndex,0], (float) sequence[iterationIndex,1] ); m_CB_RayTrace.UpdateData(); m_Device.Clear( m_Tex_OutgoingDirections_Reflected, float4.Zero ); // Clear target directions and weights m_Device.Clear( m_Tex_OutgoingDirections_Transmitted, float4.Zero ); // Clear target directions and weights m_Tex_Heightfield.SetCS( 0 ); m_Tex_Random.SetCS( 1 ); m_Tex_OutgoingDirections_Reflected.SetCSUAV( 0 ); // New target buffer where to accumulate m_Tex_OutgoingDirections_Transmitted.SetCSUAV( 1 ); // New target buffer where to accumulate m_Shader_RayTraceSurface_Dielectric.Dispatch( HEIGHTFIELD_SIZE >> 4, HEIGHTFIELD_SIZE >> 4, 1 ); m_Tex_OutgoingDirections_Reflected.RemoveFromLastAssignedSlotUAV(); m_Tex_OutgoingDirections_Transmitted.RemoveFromLastAssignedSlotUAV(); } // 2] Accumulate into target histogram if ( m_Shader_AccumulateOutgoingDirections.Use() ) { // Accumulated reflections m_Tex_OutgoingDirections_Reflected.SetCS( 0 ); m_Tex_LobeHistogram_Reflected_Decimal.SetCSUAV( 0 ); m_Tex_LobeHistogram_Reflected_Integer.SetCSUAV( 1 ); m_Shader_AccumulateOutgoingDirections.Dispatch( HEIGHTFIELD_SIZE >> 4, HEIGHTFIELD_SIZE >> 4, MAX_SCATTERING_ORDER ); m_Tex_LobeHistogram_Reflected_Decimal.RemoveFromLastAssignedSlotUAV(); m_Tex_LobeHistogram_Reflected_Integer.RemoveFromLastAssignedSlotUAV(); m_Tex_OutgoingDirections_Reflected.RemoveFromLastAssignedSlots(); // Accumulated transmissions m_Tex_OutgoingDirections_Transmitted.SetCS( 0 ); m_Tex_LobeHistogram_Transmitted_Decimal.SetCSUAV( 0 ); m_Tex_LobeHistogram_Transmitted_Integer.SetCSUAV( 1 ); m_Shader_AccumulateOutgoingDirections.Dispatch( HEIGHTFIELD_SIZE >> 4, HEIGHTFIELD_SIZE >> 4, MAX_SCATTERING_ORDER ); m_Tex_LobeHistogram_Transmitted_Decimal.RemoveFromLastAssignedSlotUAV(); m_Tex_LobeHistogram_Transmitted_Integer.RemoveFromLastAssignedSlotUAV(); m_Tex_OutgoingDirections_Transmitted.RemoveFromLastAssignedSlots(); } break; case SURFACE_TYPE.DIFFUSE: if ( m_Shader_RayTraceSurface_Diffuse.Use() ) { // Update trace offset m_CB_RayTrace.m._Offset.Set( (float) sequence[iterationIndex,0], (float) sequence[iterationIndex,1] ); m_CB_RayTrace.UpdateData(); m_Device.Clear( m_Tex_OutgoingDirections_Reflected, float4.Zero ); // Clear target directions and weights m_Tex_Heightfield.SetCS( 0 ); m_Tex_Random.SetCS( 1 ); m_Tex_OutgoingDirections_Reflected.SetCSUAV( 0 ); // New target buffer where to accumulate m_Shader_RayTraceSurface_Diffuse.Dispatch( HEIGHTFIELD_SIZE >> 4, HEIGHTFIELD_SIZE >> 4, 1 ); m_Tex_OutgoingDirections_Reflected.RemoveFromLastAssignedSlotUAV(); } // 2] Accumulate into target histogram if ( m_Shader_AccumulateOutgoingDirections.Use() ) { m_Tex_OutgoingDirections_Reflected.SetCS( 0 ); m_Tex_LobeHistogram_Reflected_Decimal.SetCSUAV( 0 ); m_Tex_LobeHistogram_Reflected_Integer.SetCSUAV( 1 ); m_Shader_AccumulateOutgoingDirections.Dispatch( HEIGHTFIELD_SIZE >> 4, HEIGHTFIELD_SIZE >> 4, MAX_SCATTERING_ORDER ); m_Tex_LobeHistogram_Reflected_Decimal.RemoveFromLastAssignedSlotUAV(); m_Tex_LobeHistogram_Reflected_Integer.RemoveFromLastAssignedSlotUAV(); m_Tex_OutgoingDirections_Reflected.RemoveFromLastAssignedSlots(); } break; default: throw new Exception( "Not implemented!" ); } } // 3] Finalize if ( m_Shader_FinalizeOutgoingDirections.Use() ) { m_Tex_LobeHistogram_Reflected_Decimal.SetCSUAV( 0 ); m_Tex_LobeHistogram_Reflected_Integer.SetCSUAV( 1 ); m_Tex_LobeHistogram_Reflected.SetCSUAV( 2 ); m_CB_Finalize.m._IterationsCount = (uint) _iterationsCount; m_CB_Finalize.UpdateData(); m_Shader_FinalizeOutgoingDirections.Dispatch( (LOBES_COUNT_PHI + 15) >> 4, (LOBES_COUNT_THETA + 15) >> 4, MAX_SCATTERING_ORDER ); m_Tex_LobeHistogram_Reflected_Decimal.RemoveFromLastAssignedSlotUAV(); m_Tex_LobeHistogram_Reflected_Integer.RemoveFromLastAssignedSlotUAV(); m_Tex_LobeHistogram_Reflected.RemoveFromLastAssignedSlotUAV(); if ( m_lastComputedSurfaceType == SURFACE_TYPE.DIELECTRIC ) { // Finalize transmitted m_Tex_LobeHistogram_Transmitted_Decimal.SetCSUAV( 0 ); m_Tex_LobeHistogram_Transmitted_Integer.SetCSUAV( 1 ); m_Tex_LobeHistogram_Transmitted.SetCSUAV( 2 ); m_Shader_FinalizeOutgoingDirections.Dispatch( (LOBES_COUNT_PHI + 15) >> 4, (LOBES_COUNT_THETA + 15) >> 4, MAX_SCATTERING_ORDER ); m_Tex_LobeHistogram_Transmitted_Decimal.RemoveFromLastAssignedSlotUAV(); m_Tex_LobeHistogram_Transmitted_Integer.RemoveFromLastAssignedSlotUAV(); m_Tex_LobeHistogram_Transmitted.RemoveFromLastAssignedSlotUAV(); } else { m_Device.Clear( m_Tex_LobeHistogram_Transmitted, float4.Zero ); } } }