本文整理汇总了C#中UnityEngine.Shader类的典型用法代码示例。如果您正苦于以下问题:C# Shader类的具体用法?C# Shader怎么用?C# Shader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Shader类属于UnityEngine命名空间,在下文中一共展示了Shader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowShaderCodeArea
private void ShowShaderCodeArea(Shader s)
{
ShaderInspector.ShowSurfaceShaderButton(s);
ShaderInspector.ShowFixedFunctionShaderButton(s);
this.ShowCompiledCodeButton(s);
this.ShowShaderErrors(s);
}
示例2: SimpleCube
public SimpleCube(float size, ref Material material, Shader shader)
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
GameObject.Destroy(cube.GetComponent<Collider>());
cube.transform.localScale = Vector3.one;
meshContainer = cube;
MeshFilter mf = cube.GetComponent<MeshFilter>();
Vector3[] verts = mf.mesh.vertices;
for (int i = 0; i < verts.Length; i++)
{
verts[i] *= 2*size;
}
mf.mesh.vertices = verts;
mf.mesh.RecalculateBounds();
mf.mesh.RecalculateNormals();
MeshRenderer mr = cube.GetComponent<MeshRenderer>();
material = mr.material;
material.shader = shader;
mr.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
mr.receiveShadows = false;
mr.enabled = true;
}
示例3: ShaderVariant
public ShaderVariant(Shader shader, PassType passType, params string[] keywords)
{
this.shader = shader;
this.passType = passType;
this.keywords = keywords;
ShaderVariantCollection.ShaderVariant.Internal_CheckVariant(shader, passType, keywords);
}
示例4: LoadBundleAssets
public IEnumerator LoadBundleAssets()
{
while (!Caching.ready)
yield return null;
Debug.Log("[B9PW] Aquiring bundle data");
using (WWW www = WWW.LoadFromCacheOrDownload("file://" + KSPUtil.ApplicationRootPath + Path.DirectorySeparatorChar + "GameData"
+ Path.DirectorySeparatorChar + "B9_Aerospace_ProceduralWings" + Path.DirectorySeparatorChar + "wingshader.ksp", 1))
{
yield return www;
AssetBundle shaderBundle = www.assetBundle;
Shader[] objects = shaderBundle.LoadAllAssets<Shader>();
for (int i = 0; i < objects.Length; ++i)
{
Debug.Log($"[B9PW] {objects[i].name}");
if (objects[i].name == "KSP/Specular Layered")
{
wingShader = objects[i] as Shader;
Debug.Log($"[B9 PWings] Wing shader \"{objects[i].name}\" loaded");
}
}
yield return new WaitForSeconds(1.0f); // unknown how neccesary this is
Debug.Log("[B9PW] unloading bundle");
shaderBundle.Unload(false); // unload the raw asset bundle
}
}
示例5: IsSupported
public static bool IsSupported(Shader s, bool needDepth, bool needHdr, MonoBehaviour effect)
{
if (s == null || !s.isSupported)
{
Debug.LogWarningFormat("Missing shader for image effect {0}", effect);
return false;
}
if (!SystemInfo.supportsImageEffects || !SystemInfo.supportsRenderTextures)
{
Debug.LogWarningFormat("Image effects aren't supported on this device ({0})", effect);
return false;
}
if (needDepth && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
{
Debug.LogWarningFormat("Depth textures aren't supported on this device ({0})", effect);
return false;
}
if (needHdr && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf))
{
Debug.LogWarningFormat("Floating point textures aren't supported on this device ({0})", effect);
return false;
}
return true;
}
示例6: OnDisable
void OnDisable()
{
_target = null;
_propertyName = null;
_propertyList = null;
_cachedShader = null;
}
示例7: FourierGPU
public FourierGPU(int size, Shader sdr)
{
if (!Mathf.IsPowerOfTwo(size))
throw new ArgumentException("Fourier grid size must be pow2 number");
m_fourier = new Material(sdr);
m_size = size; //must be pow2 num
m_fsize = (float)m_size;
m_passes = (int)(Mathf.Log(m_fsize) / Mathf.Log(2.0f));
m_butterflyLookupTable = new Texture2D[m_passes];
ComputeButterflyLookupTable();
m_fourier.SetFloat("Ceto_FourierSize", m_fsize);
m_pass0RT2 = new RenderBuffer[2];
m_pass1RT2 = new RenderBuffer[2];
m_pass0RT3 = new RenderBuffer[3];
m_pass1RT3 = new RenderBuffer[3];
m_pass0RT4 = new RenderBuffer[4];
m_pass1RT4 = new RenderBuffer[4];
}
示例8: PlanetProperties
public PlanetProperties(string shader, string landTex, string cliffTex, string snowTex, string landHeightTex = null, string landSubTex = null, float heightScaleFactor=1.5f, int landTexScale = 1)
{
landMaterial = Resources.Load<Material> ("Materials/Terrain/Diffuse");
terrainShader = Resources.Load<Shader> (shader);
landTexture = Resources.Load<Texture2D> (landTex);
if (cliffTex != null) {
cliffTexture = Resources.Load<Texture2D> (cliffTex);
} else {
cliffTexture = landTexture;
}
if (snowTex != null) {
snowTexture = Resources.Load<Texture2D> (snowTex);
} else {
snowTexture = null;
}
if (landHeightTex != null) {
if (landTexture != null && landHeightTex == landTex) {
landHeightTexture = landTexture;
} else {
landHeightTexture = Resources.Load<Texture2D> (landHeightTex);
}
}
if (landSubTex != null) {
if (landHeightTexture != null && landSubTex == landHeightTex) {
landSubTexture = landHeightTexture;
} else {
landSubTexture = Resources.Load<Texture2D> (landSubTex);
}
}
this.heightScaleFactor = heightScaleFactor;
this.landTextureScale = landTexScale;
}
示例9: AssignNewShaderToMaterial
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
{
if (material.HasProperty("_Emission"))
{
material.SetColor("_EmissionColor", material.GetColor("_Emission"));
}
base.AssignNewShaderToMaterial(material, oldShader, newShader);
if ((oldShader == null) || !oldShader.name.Contains("Legacy Shaders/"))
{
SetupMaterialWithBlendMode(material, (BlendMode) ((int) material.GetFloat("_Mode")));
}
else
{
BlendMode opaque = BlendMode.Opaque;
if (oldShader.name.Contains("/Transparent/Cutout/"))
{
opaque = BlendMode.Cutout;
}
else if (oldShader.name.Contains("/Transparent/"))
{
opaque = BlendMode.Fade;
}
material.SetFloat("_Mode", (float) opaque);
Material[] mats = new Material[] { material };
this.DetermineWorkflow(MaterialEditor.GetMaterialProperties(mats));
MaterialChanged(material, this.m_WorkflowMode);
}
}
示例10: ChangeShaderOnMaterial
private static void ChangeShaderOnMaterial(Material material, Shader shader)
{
if ((material != null) && (shader != null))
{
material.shader = shader;
}
}
示例11: SetupRadarCamera
public static void SetupRadarCamera()
{
if(radarRT && radarTex2D && radarCam && radarShader)
{
return;
}
//setup shader first
if(!radarShader)
{
radarShader = BDAShaderLoader.UnlitBlackShader;//.LoadManifestShader("BahaTurret.UnlitBlack.shader");
}
//then setup textures
radarRT = new RenderTexture(radarResolution,radarResolution,16);
radarTex2D = new Texture2D(radarResolution,radarResolution, TextureFormat.ARGB32, false);
//set up camera
radarCam = (new GameObject("RadarCamera")).AddComponent<Camera>();
radarCam.enabled = false;
radarCam.clearFlags = CameraClearFlags.SolidColor;
radarCam.backgroundColor = Color.white;
radarCam.SetReplacementShader(radarShader, string.Empty);
radarCam.cullingMask = 1<<0;
radarCam.targetTexture = radarRT;
//radarCam.nearClipPlane = 75;
//radarCam.farClipPlane = 40000;
}
示例12: GasOverlayMats
static GasOverlayMats()
{
TransmitterShader = ShaderDatabase.MetaOverlay;
Graphic subGraphic = GraphicDatabase.Get<Graphic_Single>(TransmitterAtlasPath, TransmitterShader);
LinkedOverlayGraphic = new Graphic_LinkedGasPipe(subGraphic);
subGraphic.MatSingle.renderQueue = 3800;
}
示例13: CreateAtlas
// with material
public static MadMeshCombinerAtlas CreateAtlas(string texturePath, Texture2D[] textures, Shader shader)
{
var madeReadable = PrepareTextures(textures);
try {
List<MadMeshCombinerAtlas.Item> items = new List<MadMeshCombinerAtlas.Item>();
PackTextures(textures, texturePath, ref items);
var atlas = new MadMeshCombinerAtlas();
atlas.atlasTexture = AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)) as Texture2D;
atlas.AddItemRange(items);
// create material out of atlas
var materialPath = System.IO.Path.ChangeExtension(texturePath, "mat");
//var atlasMaterial = new Material(Shader.Find("Transparent/Cutout/Diffuse"));
var atlasMaterial = new Material(shader);
atlasMaterial.mainTexture = atlas.atlasTexture;
atlas.atlasMaterial = atlasMaterial;
AssetDatabase.CreateAsset(atlasMaterial, materialPath);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
return atlas;
} finally {
RevertAll(madeReadable);
}
}
示例14: CheckShaderAndCreateMaterial
protected Material CheckShaderAndCreateMaterial(Shader s, Material m2Create)
{
if (!s)
{
Debug.Log("Missing shader in " + this.ToString());
enabled = false;
return null;
}
if (s.isSupported && m2Create && m2Create.shader == s)
return m2Create;
if (!s.isSupported)
{
enabled = false;
isSupported = false;
Debug.Log("The shader " + s.ToString() + " on effect " + this.ToString() + " is not supported on this platform!");
return null;
}
else
{
//Debug.Log("Creating material");
m2Create = new Material(s);
m2Create.hideFlags = HideFlags.DontSave;
if (m2Create)
{
return m2Create;
}
else
return null;
}
}
示例15: GetPropertyType
/*
private static string[] kShaderLevels = new string[]
{
"Fixed function",
"SM1.x",
"SM2.0",
"SM3.0",
"SM4.0",
"SM5.0"
};
*/
private static string GetPropertyType( Shader s, int index ) {
ShaderUtil.ShaderPropertyType propertyType = ShaderUtil.GetPropertyType( s, index );
if( propertyType == ShaderUtil.ShaderPropertyType.TexEnv ) {
return ShaderForgeInspector.kTextureTypes[(int)ShaderUtil.GetTexDim( s, index )];
}
return ShaderForgeInspector.kPropertyTypes[(int)propertyType];
}