public void Finish(GameSurfaceState localStateHandle) { PositionOffsetTexture.Apply(); _weights.Dispose(); Shader.SetGlobalFloat("_OneOverSurfaceSize", 1.0f / GameSurface.Size); Shader.SetGlobalTexture("_PositionOffsetTex", PositionOffsetTexture); }
protected override void Awake() { base.Awake(); _photonView = GetComponent <PhotonView>(); _renderer = GetComponentInChildren <Renderer>(); WorldSpaceGridNodeSize = (1f / Resolution) * Size; _localState = new GameSurfaceState(Resolution, Size, _gameSurfaceColorTexture, false); _syncronizedState = new GameSurfaceState(Resolution, Size, _gameSurfaceColorTexture, true); _rpcNumberPerNode = new NativeArray <int>(Resolution * Resolution, Allocator.Persistent); _combinedSurface = new NativeArray <SurfaceState>(Resolution * Resolution, Allocator.Persistent); Material material = gameObject.GetComponentInChildren <Renderer>().material; material.SetTexture("_Mask", _syncronizedState.GameSurfaceTex); material.SetTexture("_LocalMask", _localState.GameSurfaceTex); _localStateBackup = new NativeArray <SurfaceState>(Resolution * Resolution, Allocator.Persistent); _localState.CopySurfaceTo(_localStateBackup); }
public JobHandle ScheduleJobs(GameSurfaceState localGameState, JobHandle dependencies) { _weights = new NativeArray <float3>(GameManager.Instance.Players.Count, Allocator.TempJob); for (int i = 0; i < GameManager.Instance.Players.Count; i++) { Vector3 playerPosition = GameManager.Instance.Players[0].transform.position; _weights[0] = new float3(playerPosition.x, playerPosition.y, _playerWeight); } JGenerateOffsetTexture job = new JGenerateOffsetTexture { Time = Time.time, HeightScale = _heightScale, PositionTexture = PositionOffsetTexture.GetRawTextureData <half4>(), SinScale = _sinScale, WeightStrength = _weightStrength, Weights = _weights, DeltaTime = Time.deltaTime * _speed }; return(job.Schedule(dependencies)); }