当前位置: 首页>>代码示例>>C#>>正文


C# Material.SetMatrix方法代码示例

本文整理汇总了C#中UnityEngine.Material.SetMatrix方法的典型用法代码示例。如果您正苦于以下问题:C# Material.SetMatrix方法的具体用法?C# Material.SetMatrix怎么用?C# Material.SetMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Material的用法示例。


在下文中一共展示了Material.SetMatrix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenderDistortion

 public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius)
 {
     bool flag = source.texelSize.y < 0f;
     if (flag)
     {
         center.y = 1f - center.y;
         angle = -angle;
     }
     Matrix4x4 matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0f, 0f, angle), Vector3.one);
     material.SetMatrix("_RotationMatrix", matrix);
     material.SetVector("_CenterRadius", new Vector4(center.x, center.y, radius.x, radius.y));
     material.SetFloat("_Angle", angle * 0.0174532924f);
     Graphics.Blit(source, destination, material);
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:14,代码来源:ImageEffects.cs

示例2: RenderDistortion

    public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector2 center, Vector2 radius)
    {
        bool invertY = source.texelSize.y < 0.0f;
        if (invertY)
        {
            center.y = 1.0f - center.y;
            angle = -angle;
        }

        Matrix4x4 rotationMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one);

        material.SetMatrix("_RotationMatrix", rotationMatrix);
        material.SetVector("_CenterRadius", new Vector4(center.x, center.y, radius.x, radius.y));
        material.SetFloat("_Angle", angle * Mathf.Deg2Rad);

        Graphics.Blit(source, destination, material);
    }
开发者ID:mmnaviwala,项目名称:cosc-4372-6370-kinect-medical-imaging,代码行数:17,代码来源:ImageEffects.cs

示例3: UpdateMaterial

    public void UpdateMaterial(RaycastHit hit)
    {
        var hitGO = hit.transform;
        if (hitGO!=null) {
          if (!RemoveWhenDisable) Destroy(gameObject, RemoveAfterTime);
          fadeInOutShaderColor = GetComponents<FadeInOutShaderColor>();
          fadeInOutShaderFloat = GetComponents<FadeInOutShaderFloat>();
          uvTextureAnimator = GetComponent<UVTextureAnimator>();
          renderParent = transform.parent.GetComponent<Renderer>();

          var materials = renderParent.sharedMaterials;
          var length = materials.Length + 1;
          var newMaterials = new Material[length];

          materials.CopyTo(newMaterials, 0);
          renderParent.material = Material;
          instanceMat = renderParent.material;
          newMaterials[length - 1] = instanceMat;
          renderParent.sharedMaterials = newMaterials;

          if (UsePointMatrixTransform) {
        var m = Matrix4x4.TRS(hit.transform.InverseTransformPoint(hit.point), Quaternion.Euler(180, 180, 0f), TransformScale);
        //m *= transform.localToWorldMatrix;
        instanceMat.SetMatrix("_DecalMatr", m);
          }
          if (materialQueue!=-1)
        instanceMat.renderQueue = materialQueue;

          if (fadeInOutShaderColor!=null) {
        foreach (var inOutShaderColor in fadeInOutShaderColor) {
          inOutShaderColor.UpdateMaterial(instanceMat);
        }
          }

          if (fadeInOutShaderFloat!=null) {
        foreach (var inOutShaderFloat in fadeInOutShaderFloat) {
          inOutShaderFloat.UpdateMaterial(instanceMat);
        }
          }

          if (uvTextureAnimator!=null)
        uvTextureAnimator.SetInstanceMaterial(instanceMat, hit.textureCoord);
        }
    }
开发者ID:naskew100,项目名称:Fired-Up,代码行数:44,代码来源:AddMaterialOnHit.cs

示例4: Apply

        public void Apply(CloudsMaterial material, float radius, Transform parent)
        {
            Remove();
            particleMaterial.MaxScale = size.y;
            particleMaterial.MaxTrans = maxTranslation;
            particleMaterial.NoiseScale =  new Vector3(noiseScale.x, noiseScale.y, noiseScale.z / radius);
            ParticleMaterial = new Material(ParticleCloudShader);
            particleMaterial.ApplyMaterialProperties(ParticleMaterial);
            material.ApplyMaterialProperties(ParticleMaterial);
            ParticleMaterial.EnableKeyword("SOFT_DEPTH_ON");

            volumeHolder = new GameObject();
            //Add the renderer here so othe rentities (shadows)
            //can easily access it.
            Renderer r = volumeHolder.AddComponent<MeshRenderer>();
            r.material = ParticleMaterial;
            ParticleMaterial.SetMatrix(ShaderProperties._ShadowBodies_PROPERTY, Matrix4x4.zero);
            ParticleMaterial.renderQueue = (int)Tools.Queue.Transparent + 2;

            r.enabled = false;
            volumeHolder.transform.parent = parent;
            volumeHolder.transform.localPosition = Vector3.zero;
            volumeHolder.transform.localScale = Vector3.one;
            volumeHolder.transform.localRotation = Quaternion.identity;
            volumeHolder.layer = (int)Tools.Layer.Local;
            volumeManager = new VolumeManager(radius, size, ParticleMaterial, volumeHolder.transform, area.x, (int)area.y);
            
        }
开发者ID:Kerbas-ad-astra,项目名称:EnvironmentalVisualEnhancements,代码行数:28,代码来源:CloudsVolume.cs

示例5: SetUniforms

        /**
        * Sets the shader uniforms that are necessary to project on screen the
        * TerrainQuad of the given TerrainNode. This method can set the uniforms
        * that are common to all the quads of the given terrain.
        */
        public virtual void SetUniforms(TerrainNode node, Material mat)
        {
            if(mat == null || node == null) return;

            float d1 = node.GetSplitDist() + 1.0f;
            float d2 = 2.0f * node.GetSplitDist();
            mat.SetVector(m_uniforms.blending, new Vector2(d1, d2 - d1));

            m_localToCamera = node.GetView().GetWorldToCamera() * node.GetLocalToWorld();
            m_localToScreen = node.GetView().GetCameraToScreen() * m_localToCamera;

            Vector3d2 localCameraPos = node.GetLocalCameraPos();
            Vector3d2 worldCamera = node.GetView().GetWorldCameraPos();

            Matrix4x4d A = LocalToDeformedDifferential(localCameraPos);
            Matrix4x4d B = DeformedToTangentFrame(worldCamera);

            Matrix4x4d ltot = B * node.GetLocalToWorld() * A;

            m_localToTangent = new Matrix3x3d(	ltot.m[0,0], ltot.m[0,1], ltot.m[0,3],
                                              ltot.m[1,0], ltot.m[1,1], ltot.m[1,3],
                                              ltot.m[3,0], ltot.m[3,1], ltot.m[3,3]);

            mat.SetMatrix(m_uniforms.localToScreen, m_localToScreen.ToMatrix4x4());
            mat.SetMatrix(m_uniforms.localToWorld, node.GetLocalToWorld().ToMatrix4x4());
        }
开发者ID:Climberfx,项目名称:Scatterer,代码行数:31,代码来源:Deformation.cs

示例6: SetUniforms

        public void SetUniforms(Material mat)
        {
            //Sets uniforms that this or other gameobjects may need
            if (mat == null) return;

            mat.SetFloat("_Extinction_Cutoff", ExtinctionCutoff);
            if (!MapView.MapIsEnabled) {
            mat.SetFloat("_Alpha_Global", alphaGlobal);
            mat.SetFloat("_Extinction_Tint", extinctionTint);
            mat.SetFloat("extinctionMultiplier", extinctionMultiplier);
            } else {
            mat.SetFloat("_Alpha_Global", mapAlphaGlobal);
            mat.SetFloat("_Extinction_Tint", mapExtinctionTint);
            mat.SetFloat("extinctionMultiplier", mapExtinctionMultiplier);
            }

            mat.SetFloat("scale", atmosphereGlobalScale);
            mat.SetFloat("Rg", Rg * atmosphereGlobalScale);
            mat.SetFloat("Rt", Rt * atmosphereGlobalScale);
            mat.SetFloat("RL", RL * atmosphereGlobalScale);

            //						if (debugSettings [5])
            if (!MapView.MapIsEnabled) {
            mat.SetFloat("_Globals_ApparentDistance", 1f);
            } else {
            mat.SetFloat("_Globals_ApparentDistance", (float)((parentCelestialBody.Radius / 100.2f) / MapViewScale));
            //				mat.SetFloat ("_Globals_ApparentDistance", MapViewScale);
            }

            //						if (debugSettings[1])
            if (!MapView.MapIsEnabled) {

            mat.SetMatrix("_Globals_WorldToCamera", farCamera.worldToCameraMatrix);
            mat.SetMatrix("_Globals_CameraToWorld", farCamera.worldToCameraMatrix.inverse);
            } else {
            mat.SetMatrix("_Globals_WorldToCamera", scaledSpaceCamera.worldToCameraMatrix);
            mat.SetMatrix("_Globals_CameraToWorld", scaledSpaceCamera.worldToCameraMatrix.inverse);
            }

            mat.SetVector("betaR", m_betaR / 1000.0f);
            mat.SetFloat("mieG", Mathf.Clamp(m_mieG, 0.0f, 0.99f));
            mat.SetTexture("_Sky_Transmittance", m_transmit);
            mat.SetTexture("_Sky_Inscatter", m_inscatter);
            mat.SetTexture("_Sky_Irradiance", m_irradiance);
            mat.SetFloat("_Sun_Intensity", 100f);
            mat.SetVector("_Sun_WorldSunDir", m_manager.getDirectionToSun().normalized);
            //			mat.SetVector("_Sun_WorldSunDir", m_manager.getDirectionToSun());

            //			//copied from m_manager's set uniforms

            //Matrix4x4 p;
            //						if (debugSettings [2])
            if (!MapView.MapIsEnabled) {
            p = farCamera.projectionMatrix;
            } else {
            p = scaledSpaceCamera.projectionMatrix;
            }

            m_cameraToScreenMatrix = new Matrix4x4d(p);
            mat.SetMatrix("_Globals_CameraToScreen", m_cameraToScreenMatrix.ToMatrix4x4());
            mat.SetMatrix("_Globals_ScreenToCamera", m_cameraToScreenMatrix.Inverse().ToMatrix4x4());

            //						if (debugSettings [3])
            if (!MapView.MapIsEnabled) {
            mat.SetVector("_Globals_WorldCameraPos", farCamera.transform.position);
            } else {
            mat.SetVector("_Globals_WorldCameraPos", scaledSpaceCamera.transform.position);
            }
            //			else
            //			{
            //				Vector3 newpos= ScaledSpace.ScaledToLocalSpace(scaledSpaceCamera.transform.position);
            //				//				m_skyMaterial.SetVector ("_Globals_WorldCameraPos", scaledSpaceCamera.transform.position);
            //				mat.SetVector ("_Globals_WorldCameraPos", newpos);
            //			}
            //
            //						if (debugSettings [4])
            if (!MapView.MapIsEnabled) {
            mat.SetVector("_Globals_Origin", parentCelestialBody.transform.position);

            } else {

            //				celestialTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == parentCelestialBody.name);
            celestialTransform = ParentPlanetTransform;
            //				idek =celestialTransform.position;
            idek = celestialTransform.position - scaledSpaceCamera.transform.position;
            mat.SetVector("_Globals_Origin", idek);

            }

            if (!MapView.MapIsEnabled) {
            mat.SetFloat("_Exposure", m_HDRExposure);
            } else {
            mat.SetFloat("_Exposure", mapExposure);
            }

            //			int childCnt = 0;
            //			Transform scaledSunTransform=ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == "Sun");
            //			foreach (Transform child in scaledSunTransform)
            //			{
            //				print(childCnt);
//.........这里部分代码省略.........
开发者ID:tarsolya,项目名称:Scatterer,代码行数:101,代码来源:SkyNode.cs

示例7: UpdatePostProcessMaterial

        void UpdatePostProcessMaterial(Material mat)
        {
            //mat.SetFloat ("atmosphereGlobalScale", atmosphereGlobalScale);
            //			mat.SetFloat ("Rg", Rg*atmosphereGlobalScale*postProcessingScale);
            //			mat.SetFloat("Rt", Rt*atmosphereGlobalScale*postProcessingScale);
            //			mat.SetFloat("Rl", RL*atmosphereGlobalScale*postProcessingScale);

            totalscale = 1;
            totalscale2 = 1;
            for (int j = 0; j < 5; j++) {
            totalscale = totalscale * additionalScales[j];
            }

            for (int j = 6; j < 10; j++) {
            totalscale2 = totalscale2 * additionalScales[j];
            }

            mat.SetFloat("Rg", Rg * atmosphereGlobalScale * totalscale);
            mat.SetFloat("Rt", Rt * atmosphereGlobalScale * totalscale);
            mat.SetFloat("Rl", RL * atmosphereGlobalScale * totalscale);

            //mat.SetFloat("_inscatteringCoeff", inscatteringCoeff);
            mat.SetFloat("_extinctionCoeff", extinctionCoeff);
            mat.SetFloat("_global_alpha", postProcessingAlpha);
            mat.SetFloat("_Exposure", postProcessExposure);
            mat.SetFloat("_global_depth", postProcessDepth);
            mat.SetFloat("_global_depth2", totalscale2);

            mat.SetFloat("terrain_reflectance", terrainReflectance);
            mat.SetFloat("_irradianceFactor", irradianceFactor);

            mat.SetFloat("_Scale", postProcessingScale);
            //			mat.SetFloat("_Scale", 1);

            mat.SetFloat("_Ocean_Sigma", oceanSigma);
            mat.SetFloat("_Ocean_Threshold", _Ocean_Threshold);

            //			mat.SetMatrix ("_Globals_CameraToWorld", cams [0].worldToCameraMatrix.inverse);
            if (debugSettings[1]) {
            mat.SetMatrix("_Globals_CameraToWorld", farCamera.worldToCameraMatrix.inverse);
            } else {
            mat.SetMatrix("_Globals_CameraToWorld", scaledSpaceCamera.worldToCameraMatrix.inverse);
            }

            if (debugSettings[2]) {
            mat.SetVector("_CameraForwardDirection", farCamera.transform.forward);
            } else {
            mat.SetVector("_CameraForwardDirection", scaledSpaceCamera.transform.forward);
            }

            if (debugSettings[3]) {
            mat.SetVector("_Globals_Origin", /*Vector3.zero-*/ parentCelestialBody.transform.position);
            } else

            {

            //				celestialTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == parentCelestialBody.name);
            celestialTransform = ParentPlanetTransform;
            idek = celestialTransform.position;
            mat.SetVector("_Globals_Origin", /*Vector3.zero-*/ idek);
            }

            //mat.SetVector("betaR", m_betaR / (Rg / m_radius));
            //			mat.SetVector("betaR", m_betaR / (postProcessDepth));
            mat.SetVector("betaR", new Vector4(2.9e-3f, 0.675e-2f, 1.655e-2f, 0.0f));
            mat.SetFloat("mieG", 0.4f);
            mat.SetVector("SUN_DIR", m_manager.GetSunNodeDirection());
            mat.SetFloat("SUN_INTENSITY", sunIntensity);

            Matrix4x4 ctol1 = farCamera.cameraToWorldMatrix;
            Vector3d tmp = (farCamera.transform.position) - m_manager.parentCelestialBody.transform.position;

            Matrix4x4d viewMat = new Matrix4x4d(ctol1.m00, ctol1.m01, ctol1.m02, tmp.x,
                                            ctol1.m10, ctol1.m11, ctol1.m12, tmp.y,
                                            ctol1.m20, ctol1.m21, ctol1.m22, tmp.z,
                                            ctol1.m30, ctol1.m31, ctol1.m32, ctol1.m33);

            //			print ("viewmat");
            //			print (viewMat.ToMatrix4x4());

            //			Matrix4x4 viewMat = farCamera.worldToCameraMatrix;
            viewMat = viewMat.Inverse();
            Matrix4x4 projMat = GL.GetGPUProjectionMatrix(farCamera.projectionMatrix, false);

            //			projMat.m23 = projMat.m23 * 0.5f;

            //			print ("projmat");
            //			print (projMat);

            Matrix4x4 viewProjMat = (projMat * viewMat.ToMatrix4x4());
            mat.SetMatrix("_ViewProjInv", viewProjMat.inverse);

            //			mat.SetMatrix("_ViewToWorld", viewMat.ToMatrix4x4());
            //
            //			var lpoints = RecalculateFrustrumPoints(farCamera);
            //			mat.SetVector("_FrustrumPoints", new Vector4(
            //				lpoints[4].x,lpoints[5].x,lpoints[5].y,lpoints[6].y));
            //
            //			mat.SetFloat("_CameraFar", farCamera.farClipPlane);
        }
开发者ID:tarsolya,项目名称:Scatterer,代码行数:100,代码来源:SkyNode.cs

示例8: InitMaterial

    void InitMaterial(Material mat)
    {
        mat.SetVector ("_SunDir", SunDir);
        mat.SetMatrix ("_Moon_wtl", getMoonMatrix);

        mat.SetVector ("_betaR", BetaR);
        mat.SetVector ("_betaM", BetaM);

        // x = Sunset, y = Day, z = Rayleigh, w = Night
        mat.SetVector ("_SkyMultiplier", skyMultiplier);

        mat.SetFloat ("_SunSize", 24.0f / SunSize);
        mat.SetVector ("_mieConst", mieConst);
        mat.SetVector ("_miePhase_g", miePhase_g);
        mat.SetVector ("_SkyTint", skyTint);
        mat.SetVector ("_GroundColor", bottomTint);
        mat.SetVector ("_NightHorizonColor", NightHorizonColor * nt);
        mat.SetVector ("_NightZenithColor", getNightZenithColor);
        mat.SetVector ("_MoonInnerCorona", getMoonInnerCorona);
        mat.SetVector ("_MoonOuterCorona", getMoonOuterCorona);
        mat.SetFloat ("_MoonSize", MoonSize);
        mat.SetVector ("_colorCorrection", ColorCorrection);

        mat.shaderKeywords = hdrMode.ToArray ();

        if (EnableNightSky)
            mat.DisableKeyword("NIGHTSKY_OFF");
        else
            mat.EnableKeyword("NIGHTSKY_OFF");

        mat.SetFloat ("_OuterSpaceIntensity", OuterSpaceIntensity);
        starMaterial.SetFloat ("StarIntensity", starBrightness);
    }
开发者ID:MalboM,项目名称:MTVJam2015,代码行数:33,代码来源:uSkyManager.cs

示例9: RenderDistortion

    public static void RenderDistortion(Material material, RenderTexture source, RenderTexture destination, float angle, Vector3 center, float radius, int subdivisions)
    {
        RenderTexture.active = destination;

        angle *= Mathf.Deg2Rad;
        Matrix4x4 rotationMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.EulerAngles (0, 0, angle), Vector3.one);
        Vector4 pixelCenter = new Vector4 (source.width * center.x, source.height * center.y, 1, 1);
        radius *= source.height;

        material.SetMatrix("_RotationMatrix", rotationMatrix);
        material.SetVector("_Center", pixelCenter);
        material.SetFloat("_Radius", radius);
        material.SetFloat("_Angle", angle);
        material.SetTexture("_MainTex", source);

        GL.PushMatrix ();
        GL.LoadOrtho ();

        for (int i = 0; i < material.passCount; i++) {
            material.SetPass (i);
            ImageEffects.DrawGrid(subdivisions, subdivisions);
        }
        GL.PopMatrix ();
    }
开发者ID:juanluislm,项目名称:MindShoot,代码行数:24,代码来源:ImageEffects.cs

示例10: DrawField

 private void DrawField(Material material)
 {
     material.SetPass(0);
     material.SetMatrix("object_to_world", transform.localToWorldMatrix);
     Graphics.DrawProcedural(MeshTopology.Points, PointCount);
 }
开发者ID:DynamicStatic,项目名称:Gravity-Demo,代码行数:6,代码来源:GravitationalField.cs

示例11: ComputeColorComposition

    public static void ComputeColorComposition(Camera camera, Material colorCompositeMaterial, RenderTexture dst, RenderTexture instanceIdBuffer, RenderTexture atomIdBuffer, RenderTexture depthBuffer)
    {
        var temp1 = new DisplayInfo[CPUBuffers.Get.IngredientsDisplayInfo.Count];
        var temp2 = new DisplayInfo[CPUBuffers.Get.IngredientGroupsDisplayInfo.Count];

        GPUBuffers.Get.IngredientsColorInfo.GetData(temp1);
        GPUBuffers.Get.IngredientGroupsColorInfo.GetData(temp2);

        CPUBuffers.Get.IngredientsDisplayInfo = temp1.ToList();
        CPUBuffers.Get.IngredientGroupsDisplayInfo = temp2.ToList();

        //Debug.Log(temp2[5].ToString());

        /**************/

        //colorCompositeMaterial.SetFloat("_depth", ColorManager.Get.depthSlider);
        colorCompositeMaterial.SetFloat("_UseHCL", Convert.ToInt32(ColorManager.Get.UseHCL));
        colorCompositeMaterial.SetFloat("_ShowAtoms", Convert.ToInt32(ColorManager.Get.ShowAtoms));
        colorCompositeMaterial.SetFloat("_ShowChains", Convert.ToInt32(ColorManager.Get.ShowChains));
        colorCompositeMaterial.SetFloat("_ShowResidues", Convert.ToInt32(ColorManager.Get.ShowResidues));
        colorCompositeMaterial.SetFloat("_ShowSecondaryStructures", Convert.ToInt32(ColorManager.Get.ShowSecondaryStructures));
        
        colorCompositeMaterial.SetFloat("_AtomDistance", ColorManager.Get.AtomDistance);
        colorCompositeMaterial.SetFloat("_ChainDistance", ColorManager.Get.ChainDistance);
        colorCompositeMaterial.SetFloat("_ResidueDistance", ColorManager.Get.ResidueDistance);
        colorCompositeMaterial.SetFloat("_SecondaryStructureDistance", ColorManager.Get.SecondaryStructureDistance);

        // LOD infos

        var rangeValues = Matrix4x4.zero;
        
        int distAcc = 0;
        for (int i = 0; i < ColorManager.Get.LevelRanges.Length; i++)
        {
            distAcc += (int)(ColorManager.Get.LevelRanges[i] * ColorManager.Get.DistanceMax);
            rangeValues[i] = distAcc;
        }
        rangeValues[ColorManager.Get.LevelRanges.Length] = ColorManager.Get.DistanceMax;

        var selectionSphere = (Vector4)SelectionManager.Instance.SelectionGameObject.transform.position;
        selectionSphere.w = SelectionManager.Instance.SelectionGameObject.GetComponent<SphereCollider>().radius;

        colorCompositeMaterial.SetVector("_FocusSphere", selectionSphere);
        colorCompositeMaterial.SetMatrix("_ProjectionMatrix", camera.projectionMatrix);
        colorCompositeMaterial.SetMatrix("_InverseViewMatrix", camera.cameraToWorldMatrix);

        colorCompositeMaterial.SetInt("_UseDistanceLevels", Convert.ToInt32(ColorManager.Get.UseDistanceLevels));
        
        colorCompositeMaterial.SetInt("_NumLevelMax", ColorManager.Get.NumLevelMax);
        colorCompositeMaterial.SetInt("_DistanceMax", ColorManager.Get.DistanceMax);
        colorCompositeMaterial.SetMatrix("_LevelRanges", rangeValues);

        //*****//
        colorCompositeMaterial.SetFloat("_LevelLerpFactor", ColorManager.Get.LevelLerpFactor);
        colorCompositeMaterial.SetInt("_NumPixels", instanceIdBuffer.width * instanceIdBuffer.height);

        //*****//
        colorCompositeMaterial.SetTexture("_DepthBuffer", depthBuffer);
        colorCompositeMaterial.SetTexture("_AtomIdBuffer", atomIdBuffer);
        colorCompositeMaterial.SetTexture("_InstanceIdBuffer", instanceIdBuffer);

        // Properties
        colorCompositeMaterial.SetBuffer("_ProteinAtomInfos", GPUBuffers.Get.ProteinAtomInfo);
        colorCompositeMaterial.SetBuffer("_ProteinAtomInfos2", GPUBuffers.Get.ProteinAtomInfo2);
        colorCompositeMaterial.SetBuffer("_ProteinInstanceInfo", GPUBuffers.Get.ProteinInstancesInfo);
        colorCompositeMaterial.SetBuffer("_LipidAtomInfos", GPUBuffers.Get.LipidAtomPositions);
        colorCompositeMaterial.SetBuffer("_LipidInstancesInfo", GPUBuffers.Get.LipidInstancesInfo);

        colorCompositeMaterial.SetBuffer("_IngredientsInfo", GPUBuffers.Get.IngredientsInfo);
        colorCompositeMaterial.SetBuffer("_IngredientGroupsColorInfo", GPUBuffers.Get.IngredientGroupsColorInfo);
        colorCompositeMaterial.SetBuffer("_ProteinIngredientsColorInfo", GPUBuffers.Get.IngredientsColorInfo);

        // Predifined colors 
        colorCompositeMaterial.SetBuffer("_AtomColors", GPUBuffers.Get.AtomColors);
        colorCompositeMaterial.SetBuffer("_AminoAcidColors", GPUBuffers.Get.AminoAcidColors);
        colorCompositeMaterial.SetBuffer("_IngredientsColors", GPUBuffers.Get.IngredientsColors);
        colorCompositeMaterial.SetBuffer("_IngredientsChainColors", GPUBuffers.Get.IngredientsChainColors);
        colorCompositeMaterial.SetBuffer("_IngredientGroupsColor", GPUBuffers.Get.IngredientGroupsColor);

        // Values for color generation on the fly 
        colorCompositeMaterial.SetBuffer("_IngredientGroupsLerpFactors", GPUBuffers.Get.IngredientGroupsLerpFactors);
        colorCompositeMaterial.SetBuffer("_IngredientGroupsColorValues", GPUBuffers.Get.IngredientGroupsColorValues);
        colorCompositeMaterial.SetBuffer("_IngredientGroupsColorRanges", GPUBuffers.Get.IngredientGroupsColorRanges);
        colorCompositeMaterial.SetBuffer("_ProteinIngredientsRandomValues", GPUBuffers.Get.ProteinIngredientsRandomValues);

        Graphics.Blit(null, dst, colorCompositeMaterial, 0);
    }
开发者ID:matmuze,项目名称:cellVIEW_color,代码行数:87,代码来源:ColorCompositeUtils.cs

示例12: UpdatePostProcessMaterial

        void UpdatePostProcessMaterial(Material mat)
        {
            //mat.SetFloat ("atmosphereGlobalScale", atmosphereGlobalScale);
            //			mat.SetFloat ("Rg", Rg*atmosphereGlobalScale*postProcessingScale);
            //			mat.SetFloat("Rt", Rt*atmosphereGlobalScale*postProcessingScale);
            //			mat.SetFloat("Rl", RL*atmosphereGlobalScale*postProcessingScale);

            float totalscale  = 1;
            float totalscale2 = 1;
            for (int j=0; j<5; j++)
            {
                totalscale=totalscale*additionalScales[j];
            }

            for (int j=6; j<10; j++)
            {
                totalscale2=totalscale2*additionalScales[j];
            }

            mat.SetFloat ("Rg", Rg*atmosphereGlobalScale*totalscale);
            mat.SetFloat("Rt", Rt*atmosphereGlobalScale*totalscale);
            mat.SetFloat("Rl", RL*atmosphereGlobalScale*totalscale);

            //mat.SetFloat("_inscatteringCoeff", inscatteringCoeff);
            mat.SetFloat("_extinctionCoeff", extinctionCoeff);
            mat.SetFloat("_global_alpha", postProcessingAlpha);
            mat.SetFloat("_Exposure", postProcessExposure);
            mat.SetFloat("_global_depth", postProcessDepth);
            mat.SetFloat("_global_depth2", totalscale2);

            mat.SetFloat("_Scale", postProcessingScale);
            //			mat.SetFloat("_Scale", 1);

            //			mat.SetMatrix ("_Globals_CameraToWorld", cams [0].worldToCameraMatrix.inverse);
            if (debugSettings [1]) {
                mat.SetMatrix ("_Globals_CameraToWorld", farCamera.worldToCameraMatrix.inverse);
            }
            else
            {
                mat.SetMatrix ("_Globals_CameraToWorld", scaledSpaceCamera.worldToCameraMatrix.inverse);
            }

            if (debugSettings [2]) {
                mat.SetVector ("_CameraForwardDirection", farCamera.transform.forward);
            } else {
                mat.SetVector ("_CameraForwardDirection", scaledSpaceCamera.transform.forward);
            }

            if (debugSettings [3]) {
                mat.SetVector ("_Globals_Origin", /*Vector3.zero-*/parentCelestialBody.transform.position);
            } else

            {

                Transform celestialTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == parentCelestialBody.name);
                Vector3 idek =celestialTransform.position;
                mat.SetVector ("_Globals_Origin", /*Vector3.zero-*/ idek);
            }

            //mat.SetVector("betaR", m_betaR / (Rg / m_radius));
            //			mat.SetVector("betaR", m_betaR / (postProcessDepth));
            mat.SetVector("betaR", new Vector4(2.9e-3f, 0.675e-2f, 1.655e-2f, 0.0f));
            mat.SetFloat("mieG", 0.4f);
            mat.SetVector("SUN_DIR", /*Vector3.zero-*/m_manager.GetSunNodeDirection());
            mat.SetFloat("SUN_INTENSITY", sun_intensity);
        }
开发者ID:Climberfx,项目名称:Scatterer,代码行数:66,代码来源:SkyNode+-+Copy.cs

示例13: SetUniforms

        public void SetUniforms(Material mat)
        {
            //Sets uniforms that this or other gameobjects may need
            if(mat == null) return;
            //mat.SetFloat ("atmosphereGlobalScale", atmosphereGlobalScale);

            mat.SetFloat ("_Alpha_Cutoff", alphaCutoff);
            mat.SetFloat ("_Alpha_Global", alphaGlobal);

            mat.SetFloat("scale",atmosphereGlobalScale);
            mat.SetFloat("Rg", Rg*atmosphereGlobalScale);
            mat.SetFloat("Rt", Rt*atmosphereGlobalScale);
            mat.SetFloat("RL", RL*atmosphereGlobalScale);

            //			if (debugSettings [5])
            if(!MapView.MapIsEnabled)
            {
                mat.SetFloat ("_Globals_ApparentDistance", apparentDistance);
            }
            else
            {
                mat.SetFloat("_Globals_ApparentDistance", (float)(parentCelestialBody.Radius/100.2f));
            }

            //			if (debugSettings[1])
            if(!MapView.MapIsEnabled)
            {

                mat.SetMatrix ("_Globals_WorldToCamera", farCamera.worldToCameraMatrix);
                mat.SetMatrix ("_Globals_CameraToWorld", farCamera.worldToCameraMatrix.inverse);
            }

            else
            {
                mat.SetMatrix ("_Globals_WorldToCamera", scaledSpaceCamera.worldToCameraMatrix);
                mat.SetMatrix ("_Globals_CameraToWorld", scaledSpaceCamera.worldToCameraMatrix.inverse);
            }

            mat.SetVector("betaR", m_betaR / 1000.0f);
            mat.SetFloat("mieG", Mathf.Clamp(m_mieG, 0.0f, 0.99f));
            mat.SetTexture("_Sky_Transmittance", m_transmit);
            mat.SetTexture("_Sky_Inscatter", m_inscatter);
            mat.SetTexture("_Sky_Irradiance", m_irradiance);
            //			mat.SetTexture("_Sky_Map", m_skyMap);
            mat.SetFloat("_Sun_Intensity", sun_intensity);
            mat.SetVector("_Sun_WorldSunDir", m_manager.getDirectionToSun().normalized);
            //			mat.SetVector("_Sun_WorldSunDir", m_manager.getDirectionToSun());

            //			//copied from m_manager's set uniforms

            Matrix4x4 p;
            //			if (debugSettings [2])
            if(!MapView.MapIsEnabled)
            {
                p = farCamera.projectionMatrix;
            }
            else
            {
                p = scaledSpaceCamera.projectionMatrix;
            }

            m_cameraToScreenMatrix = new Matrix4x4d (p);
            mat.SetMatrix ("_Globals_CameraToScreen", m_cameraToScreenMatrix.ToMatrix4x4 ());
            mat.SetMatrix ("_Globals_ScreenToCamera", m_cameraToScreenMatrix.Inverse ().ToMatrix4x4 ());

            //			if (debugSettings [3])
            {
                mat.SetVector ("_Globals_WorldCameraPos", farCamera.transform.position);
            }
            //			else
            //			{
            //				Vector3 newpos= ScaledSpace.ScaledToLocalSpace(scaledSpaceCamera.transform.position);
            //				//				m_skyMaterial.SetVector ("_Globals_WorldCameraPos", scaledSpaceCamera.transform.position);
            //				mat.SetVector ("_Globals_WorldCameraPos", newpos);
            //			}

            //			if (debugSettings [4])
            if(!MapView.MapIsEnabled)
            {
                mat.SetVector ("_Globals_Origin", parentCelestialBody.transform.position);
            }
            else
            {

                Transform celestialTransform = ScaledSpace.Instance.scaledSpaceTransforms.Single(t => t.name == parentCelestialBody.name);
                Vector3 idek =celestialTransform.position;
                mat.SetVector ("_Globals_Origin", idek);

            }

            mat.SetFloat ("_Exposure", m_HDRExposure);
        }
开发者ID:Climberfx,项目名称:Scatterer,代码行数:92,代码来源:SkyNode+-+Copy.cs

示例14: SetValues

	public void SetValues(Material m, IEnumerable<StoredValue> values)
	{
		foreach(var v in values)
		{
			switch(v.Property.type)
			{
			case MaterialProperty.PropertyType.color:
				m.SetColor(v.Property.name, (Color)v.Value);
				break;
			case MaterialProperty.PropertyType.real:
				m.SetFloat(v.Property.name, (float)v.Value);
				break;
			case MaterialProperty.PropertyType.texture:
				m.SetTexture(v.Property.name, (Texture)v.Value);
				break;
			case MaterialProperty.PropertyType.vector:
				m.SetVector(v.Property.name, (Vector4)v.Value);
				break;
			case MaterialProperty.PropertyType.textureOffset:
				m.SetTextureOffset(v.Property.name, (Vector2)v.Value);
				break;
			case MaterialProperty.PropertyType.textureScale:
				m.SetTextureScale(v.Property.name, (Vector2)v.Value);
				break;
			case MaterialProperty.PropertyType.matrix:
				m.SetMatrix(v.Property.name, (Matrix4x4)v.Value);
				break;
			}
		}
	}
开发者ID:MHaubenstock,项目名称:RPG-Board-3D,代码行数:30,代码来源:StoreMaterials.cs

示例15: updateStuff


//.........这里部分代码省略.........
			//local to ocean transform
			//computed from oo and ux, uy, uz should be correct
			Matrix4x4d localToOcean = new Matrix4x4d (
				ux.x, ux.y, ux.z, -ux.Dot (oo),
				uy.x, uy.y, uy.z, -uy.Dot (oo),
				uz.x, uz.y, uz.z, -uz.Dot (oo),
				0.0, 0.0, 0.0, 1.0);


			Matrix4x4d cameraToOcean = localToOcean * camToLocal;


			//Couldn't figure out how to change the wind's direction in all that math so I tried to do the easy thing
			//And Rotated the ocean and the sun
			//This didn't work

			//deleted rotation code here



			
			Vector3d2 delta = new Vector3d2 (0, 0, 0);
			
			if (m_oldlocalToOcean != Matrix4x4d.Identity ()) {
				delta = localToOcean * (m_oldlocalToOcean.Inverse () * Vector3d2.Zero ());
				m_offset += delta;
			}
			
			m_oldlocalToOcean = localToOcean;
			
			Matrix4x4d ctos = ModifiedProjectionMatrix (inCamera);
			Matrix4x4d stoc = ctos.Inverse ();
			
			Vector3d2 oc = cameraToOcean * Vector3d2.Zero ();
			
			h = oc.z;
			
			Vector4d stoc_w = (stoc * Vector4d.UnitW ()).XYZ0 ();
			Vector4d stoc_x = (stoc * Vector4d.UnitX ()).XYZ0 ();
			Vector4d stoc_y = (stoc * Vector4d.UnitY ()).XYZ0 ();
			
			Vector3d2 A0 = (cameraToOcean * stoc_w).XYZ ();
			Vector3d2 dA = (cameraToOcean * stoc_x).XYZ ();
			Vector3d2 B = (cameraToOcean * stoc_y).XYZ ();
			
			Vector3d2 horizon1, horizon2;
			
//			Vector3d2 offset = new Vector3d2 (-m_offset.x, -m_offset.y, h);
			offset = new Vector3d2 (-m_offset.x, -m_offset.y, h);
//			Vector3d2 offset = new Vector3d2 (0f, 0f, h);
			
			double h1 = h * (h + 2.0 * radius);
			double h2 = (h + radius) * (h + radius);
			double alpha = B.Dot (B) * h1 - B.z * B.z * h2;
			
			double beta0 = (A0.Dot (B) * h1 - B.z * A0.z * h2) / alpha;
			double beta1 = (dA.Dot (B) * h1 - B.z * dA.z * h2) / alpha;
			
			double gamma0 = (A0.Dot (A0) * h1 - A0.z * A0.z * h2) / alpha;
			double gamma1 = (A0.Dot (dA) * h1 - A0.z * dA.z * h2) / alpha;
			double gamma2 = (dA.Dot (dA) * h1 - dA.z * dA.z * h2) / alpha;
			
			horizon1 = new Vector3d2 (-beta0, -beta1, 0.0);
			horizon2 = new Vector3d2 (beta0 * beta0 - gamma0, 2.0 * (beta0 * beta1 - gamma1), beta1 * beta1 - gamma2);
			
			Vector3d2 sunDir = new Vector3d2 (m_manager.getDirectionToSun ().normalized);
			Vector3d2 oceanSunDir = localToOcean.ToMatrix3x3d () * sunDir;
			
			oceanMaterial.SetVector ("_Ocean_SunDir", oceanSunDir.ToVector3 ());
			
			oceanMaterial.SetVector ("_Ocean_Horizon1", horizon1.ToVector3 ());
			oceanMaterial.SetVector ("_Ocean_Horizon2", horizon2.ToVector3 ());
			
			oceanMaterial.SetMatrix ("_Ocean_CameraToOcean", cameraToOcean.ToMatrix4x4 ());
			oceanMaterial.SetMatrix ("_Ocean_OceanToCamera", cameraToOcean.Inverse ().ToMatrix4x4 ());
			
			oceanMaterial.SetMatrix ("_Globals_CameraToScreen", ctos.ToMatrix4x4 ());
			oceanMaterial.SetMatrix ("_Globals_ScreenToCamera", stoc.ToMatrix4x4 ());
			
			oceanMaterial.SetVector ("_Ocean_CameraPos", offset.ToVector3 ());
			
			oceanMaterial.SetVector ("_Ocean_Color", new Color(m_oceanUpwellingColor.x,m_oceanUpwellingColor.y,m_oceanUpwellingColor.z) /*  *0.1f   */);
			oceanMaterial.SetVector ("_Ocean_ScreenGridSize", new Vector2 ((float)m_resolution / (float)Screen.width, (float)m_resolution / (float)Screen.height));
			oceanMaterial.SetFloat ("_Ocean_Radius", (float)radius);
			
			//			oceanMaterial.SetFloat("scale", 1);
			oceanMaterial.SetFloat ("scale", oceanScale);

			oceanMaterial.SetFloat ("_OceanAlpha", oceanAlpha);
			oceanMaterial.SetFloat ("alphaRadius", alphaRadius);


			oceanMaterial.SetFloat ("sunReflectionMultiplier", sunReflectionMultiplier);
			oceanMaterial.SetFloat ("skyReflectionMultiplier", skyReflectionMultiplier);
			oceanMaterial.SetFloat ("seaRefractionMultiplier", seaRefractionMultiplier);


			m_manager.GetSkyNode ().SetOceanUniforms (oceanMaterial);
			
		}
开发者ID:kharbechteinn,项目名称:Scatterer,代码行数:101,代码来源:OceanNode.cs


注:本文中的UnityEngine.Material.SetMatrix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。