Exemplo n.º 1
0
    void Update()
    {
        if (!EffectMaterial || Application.isPlaying && !UpdateField)
        {
            return;
        }

        if (Tree == null)
        {
            return;
        }
        mFigures      = Tree.GetComponentsInChildren <Figure>();
        mFiguresCount = mFigures.Length;

        EffectMaterial.SetInt("_Size", mFiguresCount);

        var numbers    = new float[64];
        var parameters = new Matrix4x4[64];
        var transforms = new Matrix4x4[64];

        for (int i = 0; i < mFiguresCount; i++)
        {
            numbers[i]    = (float)mFigures[i].Type;
            parameters[i] = mFigures[i].Params;
            transforms[i] = mFigures[i].transform.worldToLocalMatrix;
        }

        EffectMaterial.SetFloatArray("_Numbers", numbers);
        EffectMaterial.SetMatrixArray("_Transforms", transforms);
        EffectMaterial.SetMatrixArray("_Params", parameters);
    }
Exemplo n.º 2
0
 public RenderItem(
     EffectMaterial material,
     Buffer vertexBuffer0,
     Buffer vertexBuffer1,
     CullFlags cullFlags,
     ICullable cullable,
     in Matrix4x4 world,
Exemplo n.º 3
0
        private void SetDefaultConstantBuffers(EffectMaterial material)
        {
            void setDefaultConstantBuffer(string name, DeviceBuffer buffer)
            {
                var parameter = material.Effect.GetParameter(name, throwIfMissing: false);

                if (parameter != null)
                {
                    material.SetProperty(name, buffer);
                }
            }

            setDefaultConstantBuffer("GlobalConstantsShared", _globalConstantBufferShared.Buffer);
            setDefaultConstantBuffer("GlobalConstantsVS", _globalConstantBufferVS.Buffer);
            setDefaultConstantBuffer("GlobalConstantsPS", _globalConstantBufferPS.Buffer);

            switch (material.LightingType)
            {
            case LightingType.Terrain:
                setDefaultConstantBuffer("Global_LightingConstantsVS", _globalLightingVSTerrainBuffer.Buffer);
                setDefaultConstantBuffer("Global_LightingConstantsPS", _globalLightingPSTerrainBuffer.Buffer);
                break;

            case LightingType.Object:
                setDefaultConstantBuffer("Global_LightingConstantsVS", _globalLightingVSObjectBuffer.Buffer);
                setDefaultConstantBuffer("Global_LightingConstantsPS", _globalLightingPSObjectBuffer.Buffer);
                break;
            }
        }
Exemplo n.º 4
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        // pass frustum rays to shader
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);
        EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.forward : Vector3.down);
        EffectMaterial.SetTexture("_ColorRamp", _ColorRamp);

        // Construct a Model Matrix for the Torus
        Matrix4x4 MatTorus = Matrix4x4.TRS(
            Vector3.right * Mathf.Sin(Time.time) * 5,
            Quaternion.identity,
            Vector3.one);

        MatTorus *= Matrix4x4.TRS(
            Vector3.zero,
            Quaternion.Euler(new Vector3(0, 0, (Time.time * 200) % 360)),
            Vector3.one);
        // Send the torus matrix to our shader
        EffectMaterial.SetMatrix("_MatTorus_InvModel", MatTorus.inverse);


        CustomGraphicsBlit(source, destination, EffectMaterial, 0); // Replace Graphics.Blit with CustomGraphicsBlit
    }
Exemplo n.º 5
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        // Set any custom shader variables here.  For example, you could do:
        // EffectMaterial.SetFloat("_MyVariable", 13.37f);
        // This would set the shader uniform _MyVariable to value 13.37

        EffectMaterial.SetVector("_LightDir", lightTransform ? lightTransform.forward : Vector3.down);

        //// Construct a Model Matrix for the Torus
        //Matrix4x4 MatTorus = Matrix4x4.TRS(
        //    Vector3.right * Mathf.Sin(Time.time) * 5,
        //    Quaternion.identity,
        //    Vector3.one);
        //MatTorus *= Matrix4x4.TRS(
        //    Vector3.zero,
        //    Quaternion.Euler(new Vector3(0, 0, (Time.time * 200) % 360)),
        //    Vector3.one);
        //// Send the torus matrix to our shader
        //EffectMaterial.SetMatrix("_MatTorus_InvModel", MatTorus.inverse);

        EffectMaterial.SetColor("_Color", mainColor);
        if (matColorRamp)
        {
            EffectMaterial.SetTexture("_ColorRamp_Material", matColorRamp);
        }
        if (perfColorRamp)
        {
            EffectMaterial.SetTexture("_ColorRamp_PerfMap", perfColorRamp);
        }
        if (densColorRamp)
        {
            EffectMaterial.SetTexture("_ColorRamp_Density", densColorRamp);
        }

        EffectMaterial.SetFloat("_DrawDistance", rayMarchMaxDist);

        if (EffectMaterial.IsKeywordEnabled("DEBUG_PERFORMANCE") != debugPerformance)
        {
            if (debugPerformance)
            {
                EffectMaterial.EnableKeyword("DEBUG_PERFORMANCE");
            }
            else
            {
                EffectMaterial.DisableKeyword("DEBUG_PERFORMANCE");
            }
        }

        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);
    }
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination);             // do nothing
            return;
        }

        Matrix4x4 MatTorus = Matrix4x4.TRS(
            Vector3.right * Mathf.Sin(Time.time) * 5,
            Quaternion.identity,
            Vector3.one);

        MatTorus *= Matrix4x4.TRS(
            Vector3.zero,
            Quaternion.Euler(new Vector3(0, 0, (Time.time * 200) % 360)),
            Vector3.one);

        // pass frustum rays to shader
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.forward : Vector3.down);
        EffectMaterial.SetFloat("move", move);
        EffectMaterial.SetFloat("eegData", gameObject.GetComponent <Muse>().eeg_data[0]);
        EffectMaterial.SetFloat("time", Time.time);
        EffectMaterial.SetTexture("_ColorRamp", _ColorRamp);

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);
    }
Exemplo n.º 7
0
    private void Update()
    {
        if (!rgb_Tex || !z_Tex)
        {
            RefreshTextures();
        }

        if (frustum.IsPointInsideFrustum(Camera.main.transform.position, 0.1f))
        {
            EffectMaterial.EnableKeyword("CAMERA_INSIDE");
            EffectMaterial.DisableKeyword("CAMERA_OUTSIDE");

            EffectMaterial.SetFloat("_Cull", 1);
        }
        else
        {
            EffectMaterial.EnableKeyword("CAMERA_OUTSIDE");
            EffectMaterial.DisableKeyword("CAMERA_INSIDE");

            EffectMaterial.SetFloat("_Cull", 2);
        }

        EffectMaterial.SetFloat("_farClip", frustum.farClip);
        EffectMaterial.SetFloat("_nearClip", frustum.nearClip);
        EffectMaterial.SetTexture("_MainTex", rgb_Tex);
        EffectMaterial.SetTexture("_zTex", z_Tex);
        EffectMaterial.SetVector("_eyeFwd", transform.forward);
    }
Exemplo n.º 8
0
        protected void ClientTriggerEffect(int id)
        {
            Effect effect = DataReader <Effect> .Get(id);

            if (effect == null)
            {
                return;
            }
            EffectMaterial effectMaterial = (!this.effectMessageCache.ContainsKey(id)) ? null : this.effectMessageCache.get_Item(id);
            EffectMessage  effectMessage  = new EffectMessage();

            effectMessage.casterActor = this;
            effectMessage.effectData  = effect;
            if (effect.type2 == 4 || effect.type2 == 3)
            {
                effectMessage.basePoint = this.GetEffectBasePoint((EffectBasePointType)effect.@base, (float)effect.tremble, (effectMaterial != null) ? effectMaterial.skillTargetID : 0L, effect.summonId, effect.coord, effect.orientation);
            }
            else
            {
                effectMessage.basePoint = ((effectMaterial != null) ? effectMaterial.basePoint : null);
            }
            this.TriggerEffect(effect.delay, effectMessage);
            if (effectMessage.basePoint != null && effect.fx != 0)
            {
                CommandCenter.ExecuteCommand(base.get_transform(), new BulletFXCmd
                {
                    fxID  = effect.fx,
                    point = effectMessage.basePoint,
                    useY  = true
                });
            }
        }
Exemplo n.º 9
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        // pass frustum rays to shader
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);

        // pass textures to shader
        EffectMaterial.SetTexture("_rgbTex", rgb_tex);
        EffectMaterial.SetTexture("_zTex", z_tex);



        // pass eye intrinsics & extrinsics to shader
        EffectMaterial.SetMatrix("_eyeExtrinsics", EyeDataCollection.eyes[0].Extrinsics);
        EffectMaterial.SetMatrix("_eyeIntrinsics", EyeDataCollection.eyes[0].Intrinsics);
        EffectMaterial.SetVector("_eyeUV", EyeDataCollection.eyes[0].UV);

        CustomGraphicsBlit(source, destination, EffectMaterial, 0); // use given effect shader as image effec
    }
Exemplo n.º 10
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination);
            return;
        }

        EffectMaterial.SetColor("_Color1", color1);
        EffectMaterial.SetColor("_Color2", color2);
        EffectMaterial.SetColor("_Color3", color3);
        EffectMaterial.SetColor("_Color4", color4);
        EffectMaterial.SetColor("_Color5", color5);
        EffectMaterial.SetVector("_LightPos", SunLight.position);
        EffectMaterial.SetFloat("_DrawDistance", _RaymarchDrawDistance);
        EffectMaterial.SetVector("_CameraWP", CurrentCamera.transform.position);
        EffectMaterial.SetFloat("_FovX", CurrentCamera.fieldOfView * Mathf.Deg2Rad);
        EffectMaterial.SetVector("_CamForward", CurrentCamera.transform.forward.normalized);
        EffectMaterial.SetVector("_CamUp", CurrentCamera.transform.up.normalized);
        EffectMaterial.SetVector("_CamRight", CurrentCamera.transform.right.normalized);
        EffectMaterial.SetFloat("_AspectRatio", CurrentCamera.aspect);
        EffectMaterial.SetFloat("_LightStrength", lightStrength);


        Graphics.Blit(source, destination, EffectMaterial);
    }
Exemplo n.º 11
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        //Construct a Model Matrix for this Torus
        Matrix4x4 MatTorus = Matrix4x4.TRS(Vector3.right * Mathf.Sin(Time.time) * 5, Quaternion.identity, Vector3.one);

        MatTorus *= Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(new Vector3(0, 0, (Time.time * 200.0f) % 360)), Vector3.one);
        EffectMaterial.SetMatrix("_MatTorus_InvModel", MatTorus.inverse);

        EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.transform.forward : Vector3.down);
        EffectMaterial.SetVector("_LightColor", SunLight ? SunLight.color : Color.white);
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);

        //To add my stuff here later
        //If youre seeing this, im gonna alter this code to my benefit. thank you.
    }
Exemplo n.º 12
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            //位块传输,简单的赋值
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        // Set any custom shader variables here.  For example, you could do:
        // EffectMaterial.SetFloat("_MyVariable", 13.37f);
        // This would set the shader uniform _MyVariable to value 13.37
        //设置着色器参数
        //光线方向,世界坐标系
        EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.forward : Vector3.down);

        // Construct a Model Matrix for the Torus
        Matrix4x4 MatTorus = Matrix4x4.TRS(
            Vector3.right * Mathf.Sin(Time.time) * 5,
            Quaternion.identity,
            Vector3.one);

        MatTorus *= Matrix4x4.TRS(
            Vector3.zero,
            Quaternion.Euler(new Vector3(0, 0, (Time.time * 200) % 360)),
            Vector3.one);
        // Send the torus matrix to our shader
        //圆环的模型转世界矩阵,定义了圆环的运动
        EffectMaterial.SetMatrix("_MatTorus_InvModel", MatTorus.inverse);

        EffectMaterial.SetTexture("_ColorRamp_Material", _MaterialColorRamp);
        EffectMaterial.SetTexture("_ColorRamp_PerfMap", _PerfColorRamp);
        //rayMarch算法最大前进距离
        EffectMaterial.SetFloat("_DrawDistance", _RaymarchDrawDistance);
        //性能调试开关
        if (EffectMaterial.IsKeywordEnabled("DEBUG_PERFORMANCE") != _DebugPerformance)
        {
            if (_DebugPerformance)
            {
                EffectMaterial.EnableKeyword("DEBUG_PERFORMANCE");
            }
            else
            {
                EffectMaterial.DisableKeyword("DEBUG_PERFORMANCE");
            }
        }
        //视椎体顶点向量矩阵,摄像机坐标系
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        //摄像机转世界矩阵
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        //摄像机位置,世界坐标系
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);
    }
Exemplo n.º 13
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }
        //if (!RenderMaterial)
        //{
        //    Graphics.Blit(source, destination); // do nothing
        //    return;
        //}

        // pass frustum rays to shader
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_cameraWS", CurrentCamera.transform.position);
        EffectMaterial.SetTexture("_cloudNoise3D", CloudTex3D);
        EffectMaterial.SetFloat("_cutoff", CutOff);
        EffectMaterial.SetFloat("_cloudScale", CloudScale);
        EffectMaterial.SetTexture("_heightTex", HeightTex);
        EffectMaterial.SetFloat("_cloudBase", CloudBase);
        EffectMaterial.SetFloat("_layerHeight", LayerHeight);
        EffectMaterial.SetTexture("_randomNoiseTex", BlueNoise);
        //EffectMaterial.SetVector("_lightDir", SkyLight.transform.forward);
        EffectMaterial.SetTexture("_detailTex", DetailTex);
        EffectMaterial.SetFloat("_edgeScale", EdgeScale);
        EffectMaterial.SetFloat("_erodeDepth", ErodeDepth);
        EffectMaterial.SetFloat("_coverage", Coverage);
        EffectMaterial.SetFloat("_BeerLaw", BeerLaw);
        EffectMaterial.SetFloat("_SilverIntensity", SilverIntensity);
        EffectMaterial.SetFloat("_SilverSpread", SilverSpread);
        EffectMaterial.SetTexture("_CurlNoise", CurlNoise);
        EffectMaterial.SetFloat("_CurlTile", CurlTile);
        EffectMaterial.SetFloat("_CurlStrength", CurlStrength);
        EffectMaterial.SetFloat("_CloudTopOffset", TopOffset);
        EffectMaterial.SetFloat("_MaxDistance", MaxDistance);

        EffectMaterial.SetTexture("_WeatherTex", WeatherTex);
        EffectMaterial.SetFloat("_WeatherTexSize", WeatherTexSize);
        EffectMaterial.SetFloat("_nearestRenderDistance", nearestRenderDistance);
        Matrix4x4 projectionMatrix = GL.GetGPUProjectionMatrix(_CurrentCamera.projectionMatrix, false);

        projectionMatrix = GL.GetGPUProjectionMatrix(_ShadowCamera.projectionMatrix, false);
        EffectMaterial.SetMatrix("_inverseVP", Matrix4x4.Inverse(projectionMatrix * _CurrentCamera.worldToCameraMatrix));
        EffectMaterial.SetMatrix("_WorldToShadow", projectionMatrix * _ShadowCamera.worldToCameraMatrix);
        EffectMaterial.SetFloat("_WindSpeed", WindSpeed);
        EffectMaterial.SetFloat("_cloudDensity", CloudDensity);


        CustomGraphicsBlit(null, cloud, EffectMaterial, 0);
        RenderMaterial.SetTexture("cloudTexture", cloud);
        Graphics.Blit(source, destination, RenderMaterial);
    }
Exemplo n.º 14
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination);
            return;
        }

        EffectMaterial.SetTexture("_Mask", mask);

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);
    }
Exemplo n.º 15
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        // pass frustum rays to shader
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetVector("_CameraDir", CurrentCamera.transform.forward);
        EffectMaterial.SetVector("_ScreenResolution", new Vector2(Screen.width, Screen.height));


        CustomGraphicsBlit(source, destination, EffectMaterial, 0); // Replace Graphics.Blit with CustomGraphicsBlit
    }
Exemplo n.º 16
0
        protected void ServerTriggerEffect(int effectID, int skillID)
        {
            Effect effect = DataReader <Effect> .Get(effectID);

            if (effect == null)
            {
                return;
            }
            SkillManager.effectPoolID++;
            EffectMaterial effectMaterial = (!this.effectMessageCache.ContainsKey(effectID)) ? null : this.effectMessageCache.get_Item(effectID);
            EffectMessage  effectMessage  = new EffectMessage();

            effectMessage.caster      = this.owner;
            effectMessage.casterActor = this.ownerActor;
            effectMessage.skillData   = DataReader <Skill> .Get(skillID);

            effectMessage.effectData = effect;
            if (effect.type2 == 4 || effect.type2 == 3)
            {
                effectMessage.basePoint = this.GetEffectBasePoint((EffectBasePointType)effect.@base, (float)effect.tremble, (effectMaterial != null) ? effectMaterial.skillTargetID : 0L, effect.summonId, effect.coord, effect.orientation);
            }
            else
            {
                effectMessage.basePoint = ((effectMaterial != null) ? effectMaterial.basePoint : null);
            }
            effectMessage.UID            = SkillManager.effectPoolID;
            effectMessage.isClientHandle = (effectMaterial == null || effectMaterial.isClientHandle);
            if (effect.aiEffectMove == 1 && effectMessage.basePoint != null)
            {
                EffectWarningMessage effectWarningMessage = new EffectWarningMessage();
                effectWarningMessage.caster    = this.owner;
                effectWarningMessage.effectID  = effectID;
                effectWarningMessage.basePoint = effectMessage.basePoint.ApplyOffset(effect.offset);
                EventDispatcher.Broadcast <EffectWarningMessage>(WarningManagerEvent.AddEffectWarningMessage, effectWarningMessage);
            }
            ClientEffectHandler.Instance.TriggerEffect(effect.delay, effectMessage);
            if (effectMessage.basePoint != null && effect.fx != 0)
            {
                CommandCenter.ExecuteCommand(this.ownerActor.FixTransform, new BulletFXCmd
                {
                    fxID  = effect.fx,
                    point = effectMessage.basePoint,
                    scale = DataReader <AvatarModel> .Get(this.ownerActor.GetEntity().FixModelID).scale
                });
            }
        }
Exemplo n.º 17
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);
        EffectMaterial.SetVector("_LightDir", mSunLight ? mSunLight.forward : Vector3.down);
        EffectMaterial.SetInt("_MaxStep", Application.isPlaying ? MaxSteps : 256);
        EffectMaterial.SetFloat("_MaxDist", Application.isPlaying ? MaxDistance : 10);

        Extensions.CustomGraphicsBlit(source, destination, EffectMaterial, 0); // use given effect shader as image effect
    }
Exemplo n.º 18
0
        private void Dispose()
        {
            DisposePointDataObjects();

            if (_effectMaterial != null)
            {
                _effectMaterial.Dispose();
                _effectMaterial = null;
            }

            if (_shadedPointCloudEffect != null)
            {
                _shadedPointCloudEffect.Dispose();
                _shadedPointCloudEffect = null;
            }

            MainDXViewportView.Dispose();
        }
Exemplo n.º 19
0
    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination);
            return;
        }

        EffectMaterial.SetColor("_ringColor", ringColor);
        EffectMaterial.SetFloat("radius", radius);
        EffectMaterial.SetFloat("thickness", thickness);
        EffectMaterial.SetVector("ringCenter", sourceTransform.position);
        EffectMaterial.SetVector("cameraPositionWS", MainCamera.transform.position);
        EffectMaterial.SetMatrix("cameraToWorldMatrix", MainCamera.cameraToWorldMatrix);
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(MainCamera));

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);
    }
Exemplo n.º 20
0
 public void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     EffectMaterial.SetFloat("_1", arg1);
     EffectMaterial.SetFloat("_2", arg2);
     EffectMaterial.SetFloat("_3", arg3);
     EffectMaterial.SetFloat("_4", arg4);
     EffectMaterial.SetFloat("_5", arg5);
     EffectMaterial.SetFloat("_6", arg6);
     EffectMaterial.SetFloat("_7", arg7);
     EffectMaterial.SetFloat("_8", arg8);
     EffectMaterial.SetFloat("_9", arg9);
     EffectMaterial.SetFloat("_10", arg10);
     EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);
     EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
     EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
     EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.forward : Vector3.down);
     CustomGraphicsBlit(source, destination, EffectMaterial, 0);
 }
Exemplo n.º 21
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        // pass frustum rays to shader
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);
        EffectMaterial.SetFloat("_Interpolator", t);
        EffectMaterial.SetMatrixArray("_Points", points.Select(x => Matrix4x4.TRS(x.position, x.rotation, x.localScale).inverse).ToArray());
        EffectMaterial.SetInt("_Points_size", points.Count);
        EffectMaterial.SetColor("_LightColor", lightColor);
        EffectMaterial.SetColor("_ShadowColor", shadowColor);
        CustomGraphicsBlit(source, destination, EffectMaterial, 0); // use given effect shader as image effect
    }
Exemplo n.º 22
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        // Set any custom shader variables here.  For example, you could do:
        // EffectMaterial.SetFloat("_MyVariable", 13.37f);
        // This would set the shader uniform _MyVariable to value 13.37

        EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.forward : Vector3.down);

        // Construct a Model Matrix for the Torus

        /*Matrix4x4 ObjMatrix = Matrix4x4.TRS(
         *  //Vector3.right * Mathf.Sin(Time.time) * 5,
         *  Vector3.forward * 3,
         *  Quaternion.identity,
         *  Vector3.one);
         * ObjMatrix *= Matrix4x4.TRS(
         *  Vector3.zero,
         *  Quaternion.Euler(new Vector3(0, 0, (Time.time * 20) % 360)),
         *  Vector3.one);*/

        // Testing a custom model matrix
        Matrix4x4 ObjMatrix = Matrix4x4.TRS(
            Vector3.zero,
            Quaternion.Euler(new Vector3(0, 0, (Time.time * 30) % 360)),
            Vector3.one);

        // Send the torus matrix to our shader
        EffectMaterial.SetMatrix("_ObjMatrix_InvModel", ObjMatrix.inverse);

        EffectMaterial.SetFloat("_DrawDistance", _RaymarchDrawDistance);

        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);
    }
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        // Set any custom shader variables here.  For example, you could do:
        // EffectMaterial.SetFloat("_MyVariable", 13.37f);
        // This would set the shader uniform _MyVariable to value 13.37

        conductor?.PopulateUniforms(EffectMaterial);

        EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.forward : Vector3.down);


        EffectMaterial.SetTexture("_ColorRamp_Material", _MaterialColorRamp);
        EffectMaterial.SetTexture("_ColorRamp_PerfMap", _PerfColorRamp);

        EffectMaterial.SetFloat("_DrawDistance", _RaymarchDrawDistance);

        if (EffectMaterial.IsKeywordEnabled("DEBUG_PERFORMANCE") != _DebugPerformance)
        {
            if (_DebugPerformance)
            {
                EffectMaterial.EnableKeyword("DEBUG_PERFORMANCE");
            }
            else
            {
                EffectMaterial.DisableKeyword("DEBUG_PERFORMANCE");
            }
        }

        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);

        EffectMaterial.SetVector("_Resolution", new Vector2((float)Camera.main.pixelWidth, (float)Camera.main.pixelHeight));

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);
    }
Exemplo n.º 24
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        // pass frustum rays to shader
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.forward : Vector3.down);
        EffectMaterial.SetTexture("_ColorRamp", _ColorRamp);
        EffectMaterial.SetTexture("_ColorSky", _ColorSky);

        // Graphics.Blit(source, destination, EffectMaterial, 0); // use given effect shader as image effect
        CustomGraphicsBlit(source, destination, EffectMaterial, 0); // Replace Graphics.Blit with CustomGraphicsBlit
    }
Exemplo n.º 25
0
        protected void MarkStaticEffectMessage(int effectID)
        {
            Effect effect = DataReader <Effect> .Get(effectID);

            if (effect == null)
            {
                return;
            }
            EffectMaterial effectMaterial = new EffectMaterial();

            effectMaterial.basePoint = ((effect.type2 != 3 && effect.type2 != 4) ? this.GetEffectBasePoint((EffectBasePointType)effect.@base, (float)effect.tremble, 0L, effect.summonId, effect.coord, effect.orientation) : null);
            if (!this.effectMessageCache.ContainsKey(effectID))
            {
                this.effectMessageCache.Add(effectID, effectMaterial);
            }
            else
            {
                this.effectMessageCache.set_Item(effectID, effectMaterial);
            }
        }
Exemplo n.º 26
0
        public BeamStarRenderer(ITagContainer diContainer, DeviceBufferRange locationRange, BeamStar data)
        {
            this.data = data;
            var textureLoader = diContainer.GetTag <IAssetLoader <Texture> >();
            var camera        = diContainer.GetTag <Camera>();

            quadMeshBuffer = diContainer.GetTag <IQuadMeshBuffer <EffectVertex> >();
            material       = EffectMaterial.CreateFor(data.renderMode, diContainer);
            material.LinkTransformsTo(camera);
            material.World.BufferRange        = locationRange;
            material.Uniforms.Value           = EffectMaterialUniforms.Default;
            material.Uniforms.Ref.isBillboard = false;
            material.MainTexture.Texture      = textureLoader.LoadTexture(
                IEffectPartRenderer.TexturePath, data.texName);
            material.Sampler.Value = IEffectPartRenderer.SamplerDescription;
            AddDisposable(material);

            quadRange = quadMeshBuffer.Reserve(data.complexity.GetPlaneCount() * 2);

            Reset();
        }
Exemplo n.º 27
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination);
            return;
        }

        var shapesData0Arr = new Vector4[_shapes.Count];
        var shapesData1Arr = new Vector4[_shapes.Count];

        for (int i = 0; i < _shapes.Count; i++)
        {
            var shape    = _shapes[i];
            var shapePos = shape.transform.position;
            shapesData0Arr[i] = new Vector4((float)shape.Type, (float)shape.Operator);
            if (shape.Type == RayMarchingShapeType.Sphere)
            {
                shapesData1Arr[i] = new Vector4(shapePos.x, shapePos.y, shapePos.z, shape.transform.localScale.x);
            }
            else if (shape.Type == RayMarchingShapeType.Box)
            {
                shapesData1Arr[i] = new Vector4(shapePos.x, shapePos.y, shapePos.z, shape.transform.localScale.x);
            }
        }

        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);
        EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.forward : Vector3.down);
        if (_shapes.Count > 0)
        {
            EffectMaterial.SetInt("_ShapesCount", _shapes.Count);
            EffectMaterial.SetVectorArray("_ShapesData0Arr", shapesData0Arr);
            EffectMaterial.SetVectorArray("_ShapesData1Arr", shapesData1Arr);
        }

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);
    }
Exemplo n.º 28
0
        public MovingPlanesRenderer(ITagContainer diContainer, DeviceBufferRange locationRange, MovingPlanes data)
        {
            this.data = data;
            var textureLoader = diContainer.GetTag <IAssetLoader <Texture> >();
            var camera        = diContainer.GetTag <Camera>();

            quadMeshBuffer = diContainer.GetTag <IQuadMeshBuffer <EffectVertex> >();
            material       = EffectMaterial.CreateFor(data.renderMode, diContainer);
            material.LinkTransformsTo(camera);
            material.World.BufferRange        = locationRange;
            material.Uniforms.Value           = EffectMaterialUniforms.Default;
            material.Uniforms.Ref.isBillboard = !data.circlesAround && !data.useDirection;
            material.MainTexture.Texture      = textureLoader.LoadTexture(
                IEffectPartRenderer.TexturePath, data.texName);
            material.Sampler.Value = IEffectPartRenderer.SamplerDescription;
            AddDisposable(material);

            quadRange = quadMeshBuffer.Reserve(data.disableSecondPlane ? 1 : 2);
            texCoords = EffectPartUtility.GetTileUV(data.tileW, data.tileH, data.tileId);

            Reset();
        }
Exemplo n.º 29
0
        protected void MarkStaticEffectMessage(int effectID, bool isClientHandle = true)
        {
            Effect effect = DataReader <Effect> .Get(effectID);

            if (effect == null)
            {
                return;
            }
            EffectMaterial effectMaterial = new EffectMaterial();

            effectMaterial.isClientHandle = isClientHandle;
            effectMaterial.skillTargetID  = ((this.owner.AITarget != null) ? this.owner.AITarget.ID : 0L);
            effectMaterial.basePoint      = ((effect.type2 != 3 && effect.type2 != 4) ? this.GetEffectBasePoint((EffectBasePointType)effect.@base, (float)effect.tremble, (this.owner.AITarget != null) ? this.owner.AITarget.ID : 0L, effect.summonId, effect.coord, effect.orientation) : null);
            if (!this.effectMessageCache.ContainsKey(effectID))
            {
                this.effectMessageCache.Add(effectID, effectMaterial);
            }
            else
            {
                this.effectMessageCache.set_Item(effectID, effectMaterial);
            }
        }
Exemplo n.º 30
0
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (!EffectMaterial)
        {
            Graphics.Blit(source, destination); // do nothing
            return;
        }

        //Construct a Model Matrix for this Torus
        Matrix4x4 MatTorus = Matrix4x4.TRS(Vector3.right * 5, Quaternion.identity, Vector3.one);

        MatTorus *= Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(new Vector3(0, 0, 90)), Vector3.one);
        EffectMaterial.SetMatrix("_MatTorus_InvModel", MatTorus.inverse);

        EffectMaterial.SetVector("_LightDir", SunLight ? SunLight.transform.forward : Vector3.down);
        EffectMaterial.SetVector("_LightColor", SunLight ? SunLight.color : Color.white);
        EffectMaterial.SetMatrix("_FrustumCornersES", GetFrustumCorners(CurrentCamera));
        EffectMaterial.SetMatrix("_CameraInvViewMatrix", CurrentCamera.cameraToWorldMatrix);
        EffectMaterial.SetVector("_CameraWS", CurrentCamera.transform.position);

        CustomGraphicsBlit(source, destination, EffectMaterial, 0);
    }