Ejemplo n.º 1
0
    void SetupWaveShaderParams(S_WaveEmitter emitter)
    {
        //
        // paramsSet0.xy	- wave center (normalized coords)
        // paramsSet0.z		- wave amplitude
        // paramsSet0.w		- wave frequency
        //
        // paramsSet1.x		- wave distance attenuation
        // paramsSet1.y		- wave speed
        // paramsSet1.z		- wave start time
        //

        //		const float MIN_ATT = 0.001f;

        Vector4 paramSet0 = Vector4.zero;
        Vector4 paramSet1 = Vector4.zero;

        paramSet0.x = emitter.m_Center.x;
        paramSet0.y = emitter.m_Center.y;
        paramSet0.z = emitter.m_Amplitude;
        paramSet0.w = emitter.m_Frequency;

        paramSet1.x = emitter.m_DistAtt;
        paramSet1.y = emitter.m_Speed;
        paramSet1.z = emitter.m_StartTime;
        paramSet1.w = 1;         // (1 - MIN_ATT) / (MIN_ATT * emitter.m_Duration * emitter.m_Duration);

        SetWaveShaderParams(emitter.m_SlotIdx, paramSet0, paramSet1);
    }
Ejemplo n.º 2
0
    public void EmitGrenadeExplosionWave(Vector2 normScreenPos, S_WaveParams waveParams)
    {
        if (m_FreeWaveEmitterSlots.Count == 0)
        {
            Debug.LogWarning("Out of free wave-emitter slots");
            return;
        }

        int slotIdx = m_FreeWaveEmitterSlots.Pop();

        S_WaveEmitter emitter = new S_WaveEmitter();

        emitter.m_Center    = normScreenPos;
        emitter.m_Amplitude = waveParams.m_Amplitude;
        emitter.m_Frequency = waveParams.m_Freq;
        emitter.m_Speed     = waveParams.m_Speed;
        emitter.m_StartTime = Time.time + waveParams.m_Delay;
        emitter.m_Duration  = waveParams.m_Duration + waveParams.m_Delay;
        emitter.m_DistAtt   = 1.0f / waveParams.m_Radius;
        emitter.m_SlotIdx   = slotIdx;

        //Debug.Log("Amp = " + emitter.m_Amplitude + " R = " + waveParams.m_Radius);

        m_ActiveWaves.Add(emitter);
    }