本文整理汇总了C#中UnityEngine.Material.SetFloat方法的典型用法代码示例。如果您正苦于以下问题:C# Material.SetFloat方法的具体用法?C# Material.SetFloat怎么用?C# Material.SetFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Material
的用法示例。
在下文中一共展示了Material.SetFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
mat = GetComponent<Renderer> ().material;
mat.SetColor ("_EnergyColor", energyColor);
mat.SetFloat ("_Visibility", visibility);
mat.SetFloat ("_CollisionTime", -99f); // To ensure that animation is already "over" by the time we start.
}
示例2: DrawProteinsAtoms
public static void DrawProteinsAtoms(Material renderProteinsMaterial, Camera camera, RenderBuffer instanceId, RenderBuffer atomId, RenderBuffer depthBuffer, int pass)
{
// Protein params
renderProteinsMaterial.SetInt("_EnableLod", Convert.ToInt32(GlobalProperties.Get.EnableLod));
renderProteinsMaterial.SetFloat("_Scale", GlobalProperties.Get.Scale);
renderProteinsMaterial.SetFloat("_FirstLevelBeingRange", GlobalProperties.Get.FirstLevelOffset);
renderProteinsMaterial.SetVector("_CameraForward", camera.transform.forward);
renderProteinsMaterial.SetBuffer("_LodLevelsInfos", GPUBuffers.Get.LodInfo);
renderProteinsMaterial.SetBuffer("_ProteinInstanceInfo", GPUBuffers.Get.ProteinInstancesInfo);
renderProteinsMaterial.SetBuffer("_ProteinInstancePositions", GPUBuffers.Get.ProteinInstancePositions);
renderProteinsMaterial.SetBuffer("_ProteinInstanceRotations", GPUBuffers.Get.ProteinInstanceRotations);
renderProteinsMaterial.SetBuffer("_ProteinColors", GPUBuffers.Get.IngredientsColors);
renderProteinsMaterial.SetBuffer("_ProteinAtomInfo", GPUBuffers.Get.ProteinAtomInfo);
renderProteinsMaterial.SetBuffer("_ProteinAtomPositions", GPUBuffers.Get.ProteinAtoms);
renderProteinsMaterial.SetBuffer("_ProteinClusterPositions", GPUBuffers.Get.ProteinAtomClusters);
renderProteinsMaterial.SetBuffer("_ProteinSphereBatchInfos", GPUBuffers.Get.SphereBatches);
/****/
renderProteinsMaterial.SetInt("_NumCutObjects", SceneManager.Get.NumCutObjects);
renderProteinsMaterial.SetInt("_NumIngredientTypes", SceneManager.Get.NumAllIngredients);
renderProteinsMaterial.SetBuffer("_CutInfos", GPUBuffers.Get.CutInfo);
renderProteinsMaterial.SetBuffer("_CutScales", GPUBuffers.Get.CutScales);
renderProteinsMaterial.SetBuffer("_CutPositions", GPUBuffers.Get.CutPositions);
renderProteinsMaterial.SetBuffer("_CutRotations", GPUBuffers.Get.CutRotations);
/****/
Graphics.SetRenderTarget(new[] { instanceId, atomId }, depthBuffer);
renderProteinsMaterial.SetPass(1);
Graphics.DrawProceduralIndirect(MeshTopology.Points, GPUBuffers.Get.ArgBuffer);
}
示例3: Update
void Update()
{
terrain = GetComponent<Terrain>();
tData = terrain ? terrain.terrainData : null;
tMaterial = terrain ? terrain.materialTemplate : null;
if (!terrain || !tData || !tMaterial)
return;
if(disableBasemap && !Application.isPlaying && GetComponent<Terrain>().basemapDistance != 1000000) // only reset on update in edit mode
GetComponent<Terrain>().basemapDistance = 1000000;
if (cutoutMode)
{
if (tMaterial.HasProperty("_CutoutModeHideAlpha") && tMaterial.GetFloat("_CutoutModeHideAlpha") != cutoutModeHideAlpha)
tMaterial.SetFloat("_CutoutModeHideAlpha", cutoutModeHideAlpha);
}
else
if (tMaterial.HasProperty("_CutoutModeHideAlpha") && tMaterial.GetFloat("_CutoutModeHideAlpha") != -1)
tMaterial.SetFloat("_CutoutModeHideAlpha", -1);
if (!Application.isPlaying)
ApplyTransparencyMap();
else
if (!transparencyMap && autoUpdateTransparencyMap)
{
UpdateTransparencyMap();
ApplyTransparencyMap();
}
else
ApplyTransparencyMap();
}
示例4: AddOverlay
private void AddOverlay(TextureSet mTexture, TextureSet dTexture, float altitude, float fadeDistance, float pqsfadeDistance)
{
Assembly assembly = Assembly.GetExecutingAssembly();
string[] resources = assembly.GetManifestResourceNames();
StreamReader shaderStreamReader = new StreamReader(assembly.GetManifestResourceStream("CityLights.Shaders.Compiled-SphereCityLights.shader"));
Log("read stream");
String shaderString = shaderStreamReader.ReadToEnd();
Material lightMaterial = new Material(shaderString);
Material pqsLightMaterial = new Material(shaderString);
lightMaterial.SetTexture("_MainTex", mTexture.Texture);
lightMaterial.SetTexture("_DetailTex", dTexture.Texture);
lightMaterial.SetFloat("_DetailScale", dTexture.Scale);
lightMaterial.SetVector("_DetailOffset", dTexture.Offset);
lightMaterial.SetFloat("_FadeDist", fadeDistance);
lightMaterial.SetFloat("_FadeScale", 1);
pqsLightMaterial.SetTexture("_MainTex", mTexture.Texture);
pqsLightMaterial.SetTexture("_DetailTex", dTexture.Texture);
pqsLightMaterial.SetFloat("_DetailScale", dTexture.Scale);
pqsLightMaterial.SetVector("_DetailOffset", dTexture.Offset);
pqsLightMaterial.SetFloat("_FadeDist", pqsfadeDistance);
pqsLightMaterial.SetFloat("_FadeScale", .02f);
overlayList.Add(Overlay.GeneratePlanetOverlay("Kerbin", altitude, lightMaterial, pqsLightMaterial, mTexture.StartOffset, false, true));
}
示例5: Start
// Use this for initialization
void Start () {
waterZones = GameObject.FindGameObjectsWithTag("InteractableWater");
currentWeather = Weather.CLEAR;
day = true;
skybox = RenderSettings.skybox;
skybox.SetFloat("_DayToNight", 0f);
skybox.SetFloat("_RainToSnow", 0f);
skybox.SetFloat("_NormalToRainSnow", 0f);
skybox.SetFloat("_RainSnowToSpecial", 0f);
mainLight = FindObjectOfType<Light>();
foreach (Material m in materials)
{
m.SetFloat("_Snow", 0f);
}
rain = GameObject.Find("PS_Rain");
snow = GameObject.Find("PS_Snowflakes");
other = GameObject.Find("PS_weather");
rain.SetActive(false);
snow.SetActive(false);
other.SetActive(false);
tM = FindObjectOfType<TrackManager>();
SetAurore(false);
}
示例6: updateSprite
void updateSprite(SpriteRenderer spriteRenderer, AlphaMaskScript mask)
{
Texture2D a = mask.clipTexture;
Texture2D b = spriteRenderer.sprite.texture;
float w1 = (float)a.width;
float h1 = (float)a.height;
float w2 = (float)b.width;
float h2 = (float)b.height;
float xScale = h1 / h2;
float yScale = w1 / w2;
float adjustScale = xScale > yScale ? yScale : xScale;
xScale = xScale / adjustScale / mask.scale;
yScale = yScale / adjustScale / mask.scale;
float xOffset = mask.xOffsetPixel / w2;
float yOffset = mask.yOffsetPixel / h2;
var mat = new Material(Shader.Find("Unlit/AlphaMask"));
mat.name = mask.ToName();
mat.SetTexture("_ClipTex", mask.clipTexture);
mat.SetFloat("_xScale", xScale);
mat.SetFloat("_yScale", yScale);
mat.SetFloat("_xOffset", xOffset);
mat.SetFloat("_yOffset", yOffset);
spriteRenderer.sharedMaterial = mat;
Debug.Log(string.Format(
"update alpha mask target={0}x{1} mask={2}x{3}",
w1,
h1,
w2,
h2
));
}
示例7: CopyMaterialProperties
/// <summary>
/// Copy Shader properties from source to destination material.
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static void CopyMaterialProperties(Material source, Material destination)
{
MaterialProperty[] source_prop = MaterialEditor.GetMaterialProperties(new Material[] { source });
for (int i = 0; i < source_prop.Length; i++)
{
int property_ID = Shader.PropertyToID(source_prop[i].name);
if (destination.HasProperty(property_ID))
{
//Debug.Log(source_prop[i].name + " Type:" + ShaderUtil.GetPropertyType(source.shader, i));
switch (ShaderUtil.GetPropertyType(source.shader, i))
{
case ShaderUtil.ShaderPropertyType.Color:
destination.SetColor(property_ID, source.GetColor(property_ID));
break;
case ShaderUtil.ShaderPropertyType.Float:
destination.SetFloat(property_ID, source.GetFloat(property_ID));
break;
case ShaderUtil.ShaderPropertyType.Range:
destination.SetFloat(property_ID, source.GetFloat(property_ID));
break;
case ShaderUtil.ShaderPropertyType.TexEnv:
destination.SetTexture(property_ID, source.GetTexture(property_ID));
break;
case ShaderUtil.ShaderPropertyType.Vector:
destination.SetVector(property_ID, source.GetVector(property_ID));
break;
}
}
}
}
示例8: DrawProteinSphereBatches
public static void DrawProteinSphereBatches(Material renderProteinsMaterial, Camera camera, RenderBuffer colorBuffer, RenderBuffer depthBuffer, int pass, bool animated = false)
{
// Protein params
renderProteinsMaterial.SetInt("_EnableLod", Convert.ToInt32(PersistantSettings.Instance.EnableLod));
renderProteinsMaterial.SetFloat("_Scale", PersistantSettings.Instance.Scale);
renderProteinsMaterial.SetFloat("_FirstLevelBeingRange", PersistantSettings.Instance.FirstLevelOffset);
renderProteinsMaterial.SetVector("_CameraForward", camera.transform.forward);
renderProteinsMaterial.SetBuffer("_LodLevelsInfos", GPUBuffers.Instance.LodInfo);
renderProteinsMaterial.SetBuffer("_ProteinInstanceInfo", GPUBuffers.Instance.ProteinInstanceInfo);
if(animated) renderProteinsMaterial.SetBuffer("_ProteinInstancePositions", GPUBuffers.Instance.ProteinAnimationPositions);
else renderProteinsMaterial.SetBuffer("_ProteinInstancePositions", GPUBuffers.Instance.ProteinInstancePositions);
if (animated) renderProteinsMaterial.SetBuffer("_ProteinInstanceRotations", GPUBuffers.Instance.ProteinAnimationRotations);
else renderProteinsMaterial.SetBuffer("_ProteinInstanceRotations", GPUBuffers.Instance.ProteinInstanceRotations);
renderProteinsMaterial.SetBuffer("_ProteinAtomCount", GPUBuffers.Instance.ProteinAtomCount);
renderProteinsMaterial.SetBuffer("_ProteinColors", GPUBuffers.Instance.ProteinColors);
renderProteinsMaterial.SetBuffer("_ProteinAtomPositions", GPUBuffers.Instance.ProteinAtoms);
renderProteinsMaterial.SetBuffer("_ProteinClusterPositions", GPUBuffers.Instance.ProteinAtomClusters);
renderProteinsMaterial.SetBuffer("_ProteinSphereBatchInfos", GPUBuffers.Instance.SphereBatches);
Graphics.SetRenderTarget(colorBuffer, depthBuffer);
renderProteinsMaterial.SetPass(pass);
Graphics.DrawProceduralIndirect(MeshTopology.Points, GPUBuffers.Instance.ArgBuffer);
}
示例9: UpdateMeshHeights
public void UpdateMeshHeights(Material material, float minHeight, float maxHeight)
{
savedMinHeight = minHeight;
savedMaxHeight = maxHeight;
material.SetFloat("minHeight", minHeight);
material.SetFloat("maxHeight", maxHeight);
}
示例10: createMaterials
private void createMaterials()
{
gameMaterial = new Material(GameShader);
gameMaterial.SetFloat("_GridStepX", 1.0f/Width);
gameMaterial.SetFloat("_GridStepY", 1.0f/Height);
edgeDetectMaterial = new Material(EdgeDetectShader);
}
示例11: getMaterial
public Material getMaterial(){
if (material == null) {
material = new Material(Shader.Find("Custom/2D Tile Shader"));
material.SetTexture("_Tex", texture);
material.SetFloat("_Width", width);
material.SetFloat("_Height", height);
}
return material;
}
示例12: Awake
void Awake()
{
if(!grayscaleMaterial)
{
grayscaleMaterial = new Material(BDAShaderLoader.GrayscaleEffectShader);
grayscaleMaterial.SetTexture("_RampTex", textureRamp);
grayscaleMaterial.SetFloat("_RedPower", rampOffset);
grayscaleMaterial.SetFloat("_RedDelta", rampOffset);
}
}
示例13: Awake
// Use this for initialization
void Awake()
{
MeshRenderer rend = GetComponent<MeshRenderer>();
shockwaveDistortionMat = rend.material = Instantiate(rend.material);
Callback.DoLerp((float l) =>
{
shockwaveDistortionMat.SetFloat("_MaxRange", l / 2);
shockwaveDistortionMat.SetFloat("_Annulus", 1 - (l * l));
}, time, this);
}
示例14: Apply
public void Apply(ConfigNode node)
{
//create scaled material and set proprties to defaults
scaledMaterial = new Material (Shaders.EmissiveScaled);
scaledMaterial.SetTextureScale ("_EmissiveMap", Vector2.one);
scaledMaterial.SetTextureOffset ("_EmissiveMap", Vector2.zero);
scaledMaterial.SetColor ("_Color", new Color (1f, 1f, 1f));
scaledMaterial.SetFloat ("_Brightness", 1.25f);
scaledMaterial.SetFloat ("_Transparency", 0.75f);
}
示例15: Start
public void Start()
{
fxRes = GetComponent<IndieEffects>();
mat = new Material(shader);
mat.SetColor("_Lift", Lift);
mat.SetFloat("_LiftB", Mathf.Clamp(LiftBright, 0f, 2f));
mat.SetColor("_Gamma", Gamma);
mat.SetFloat("_GammaB", Mathf.Clamp(GammaBright, 0f, 2f));
mat.SetColor("_Gain", Gain);
mat.SetFloat("_GainB", Mathf.Clamp(GainBright, 0f, 2f));
}