public void Read(AssetReader reader) { Name = reader.ReadStringAligned(); RtBlend0.Read(reader); RtBlend1.Read(reader); RtBlend2.Read(reader); RtBlend3.Read(reader); RtBlend4.Read(reader); RtBlend5.Read(reader); RtBlend6.Read(reader); RtBlend7.Read(reader); RtSeparateBlend = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); if (IsReadZClip(reader.Version)) { ZClip.Read(reader); } ZTest.Read(reader); ZWrite.Read(reader); Culling.Read(reader); OffsetFactor.Read(reader); OffsetUnits.Read(reader); AlphaToMask.Read(reader); StencilOp.Read(reader); StencilOpFront.Read(reader); StencilOpBack.Read(reader); StencilReadMask.Read(reader); StencilWriteMask.Read(reader); StencilRef.Read(reader); FogStart.Read(reader); FogEnd.Read(reader); FogDensity.Read(reader); FogColor.Read(reader); FogMode = (FogMode)reader.ReadInt32(); GpuProgramID = reader.ReadInt32(); Tags.Read(reader); LOD = reader.ReadInt32(); Lighting = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); }
public void Read(EndianStream stream) { Name = stream.ReadStringAligned(); RtBlend0.Read(stream); RtBlend1.Read(stream); RtBlend2.Read(stream); RtBlend3.Read(stream); RtBlend4.Read(stream); RtBlend5.Read(stream); RtBlend6.Read(stream); RtBlend7.Read(stream); RtSeparateBlend = stream.ReadBoolean(); stream.AlignStream(AlignType.Align4); ZTest.Read(stream); ZWrite.Read(stream); Culling.Read(stream); OffsetFactor.Read(stream); OffsetUnits.Read(stream); AlphaToMask.Read(stream); StencilOp.Read(stream); StencilOpFront.Read(stream); StencilOpBack.Read(stream); StencilReadMask.Read(stream); StencilWriteMask.Read(stream); StencilRef.Read(stream); FogStart.Read(stream); FogEnd.Read(stream); FogDensity.Read(stream); FogColor.Read(stream); FogMode = stream.ReadInt32(); GpuProgramID = stream.ReadInt32(); Tags.Read(stream); LOD = stream.ReadInt32(); Lighting = stream.ReadBoolean(); stream.AlignStream(AlignType.Align4); }
public static bool IsOn(this ZWrite _this) { return(_this == ZWrite.On); }
public static bool IsOff(this ZWrite _this) { return(_this == ZWrite.Off); }
//property.Expanded = EditorGUILayout.Foldout( property.Expanded, property.GetPropertyType().PropertyTypeString() ); public void Draw() { var shaderNameContent = new GUIContent( "Shader Name", "Name for shader. Includes the hierarchy listing, that is, MyShaders/Shader will be in a folder called \"MyShaders\" in the shader selection dropdown. Also used when referring to fallback shaders."); var oldColor = GUI.color; if( string.IsNullOrEmpty(_shaderName ) ) { GUI.color = Color.red; } _shaderName.Value = EditorGUILayout.TextField(shaderNameContent, _shaderName.Value); GUI.color = oldColor; var shaderFallbackContent = new GUIContent( "Shader Fallback", "Fallback shader to use in case this shader can not be used."); _shaderFallback.Value = EditorGUILayout.TextField( shaderFallbackContent, _shaderFallback.Value ); var targetContent = new GUIContent("Shader Model","Requires more recent hardware to use the shader, but allows for more instructions, texture reads, and more input information."); _shaderTarget = (ShaderTarget)EditorGUILayout.EnumPopup( targetContent, _shaderTarget ); var excludePathContent = new GUIContent("Exclude Path","Exclude a renderpath from shader generation"); _excludePath = (ExcludePath)EditorGUILayout.EnumPopup( excludePathContent, _excludePath ); GUILayout.Space(8); _showQueueSettings = EditorGUILayout.Foldout( _showQueueSettings, "Queue Settings" ); if( _showQueueSettings ) { var renderTypeContent = new GUIContent("Render Type","This is the rendertype tag inserted into the shader. Can be used for shader replace"); _renderType = (RenderType)EditorGUILayout.EnumPopup( renderTypeContent, _renderType ); if ( _renderType == RenderType.Custom ) _renderTypeCustom.Value = EditorGUILayout.TextField( "Custom Type" ,_renderTypeCustom.Value ); var queueContent = new GUIContent("Render Queue","The render queue that this material will be put in"); _queue = (Queue)EditorGUILayout.EnumPopup( queueContent, _queue ); var offContent = new GUIContent( "Queue Offset", "Offset for drawing. Used to ensure some things draw before or after others, it specifically is an offset from the given queue- That is to say, you won't have a transparent object draw before an opaque object (or similar) due to this offset."); _queueAdjust = EditorGUILayout.IntSlider(offContent, _queueAdjust.Value, -100, 100); } GUILayout.Space( 8 ); _showCullingAndDepthSettings = EditorGUILayout.Foldout( _showCullingAndDepthSettings, "Culling and Depth Settings" ); if( _showCullingAndDepthSettings ) { var zWriteContent = new GUIContent("Write Depth","Depth is considered when testing other objects. Disable for certain effects, like letting other things draw over yourself, or for speed on most overlays."); _zWrite = (ZWrite)EditorGUILayout.EnumPopup( zWriteContent, _zWrite ); var cullModeContent = new GUIContent("CullMode","Select back / forward to clip backwards facing polygons"); _cullMode = (CullMode)EditorGUILayout.EnumPopup( cullModeContent, _cullMode ); var zTestContent = new GUIContent("ZTest","Select Z-Test Value"); _zTest = (ZTest)EditorGUILayout.EnumPopup( zTestContent, _zTest ); var enableLODContent = new GUIContent("Enable LOD","Enable Shader LOD scaling"); _enableLOD = EditorGUILayout.BeginToggleGroup( enableLODContent, _enableLOD ); _lod = EditorGUILayout.IntSlider( "LOD", _lod, 0, 1000 ); EditorGUILayout.EndToggleGroup(); } GUILayout.Space( 8 ); _showBlending = EditorGUILayout.Foldout( _showBlending, "Blending Settings" ); if( _showBlending ) { var blendingTypeContent = new GUIContent("Blend Type","Use a build in blend mode or a custom blend mode"); _blending = (BlendingType)EditorGUILayout.EnumPopup( blendingTypeContent, _blending ); if( CustomBlendingEnabled() ) { var srcBlendContent = new GUIContent("Src Blend Mode","How the source channel of blending is used"); _srcBlend = (BlendingMode)EditorGUILayout.EnumPopup( srcBlendContent, _srcBlend ); var dstBlendContent = new GUIContent("Dst Blend Mode","How the destination channel of blending is used"); _dstBlend = (BlendingMode)EditorGUILayout.EnumPopup( dstBlendContent, _dstBlend ); } } GUILayout.Space( 8 ); _showColorAndLighting = EditorGUILayout.Foldout( _showColorAndLighting, "Color And Lighting Settings" ); if( _showColorAndLighting ) { GUILayout.BeginHorizontal(); GUILayout.Label( "Color Mask:", GUILayout.ExpandWidth(false) ); _colorMaskR.Value = EditorExtensions.ToggleButton( _colorMaskR.Value, "R","Mask R Channel"); _colorMaskG.Value = EditorExtensions.ToggleButton( _colorMaskG.Value, "G","Mask G Channel"); _colorMaskB.Value = EditorExtensions.ToggleButton( _colorMaskB.Value, "B","Mask B Channel"); _colorMaskA.Value = EditorExtensions.ToggleButton( _colorMaskA.Value, "A","Mask A Channel"); GUILayout.EndHorizontal(); _dualForward = GUILayout.Toggle( _dualForward, new GUIContent( "Forward Dual Lightmaps","Use dual lightmaps in the forward rendering path" )); _fullForwardShadows = GUILayout.Toggle( _fullForwardShadows, new GUIContent( "Forward Full Shadows", "Support all shadow types in Forward rendering path." )); _softVegetation = GUILayout.Toggle( _softVegetation, new GUIContent( "Soft Vegetation", "Makes the surface shader only be rendered when Soft Vegetation is on." )); _noAmbient = GUILayout.Toggle( _noAmbient, new GUIContent( "No Ambient", "Do not apply any ambient lighting or spherical harmonics lights.")); _noLightmap = GUILayout.Toggle( _noLightmap, new GUIContent( "No Lightmaps", "Disables lightmap support in this shader (makes a shader smaller)." )); _addShadow = GUILayout.Toggle( _addShadow, new GUIContent( "Advanced Shadow Pass", "Performs vertex transformations and clipping for the shadow pass, you need to use this if shadows do not display properly." )); _ignoreProjectors = GUILayout.Toggle( _ignoreProjectors, new GUIContent( "Ignore Projectors", "Ignores projector components, should be used if your doing custom vertex transformations or most transparency" )); _approxview = GUILayout.Toggle( _approxview, new GUIContent( "Approximate View", "Computes normalized view direction per-vertex instead of per-pixel, for shaders that need it. This is faster, but view direction is not entirely correct when camera gets close to surface." )); _halfasview = GUILayout.Toggle( _halfasview, new GUIContent( "Half As View", "Pass half-direction vector into the lighting function instead of view-direction. Half-direction will be computed and normalized per vertex. This is faster, but not entirely correct." )); _noForwardAdd = GUILayout.Toggle( _noForwardAdd, new GUIContent( "Disable Forward Add", "Disables Forward rendering additive pass. This makes the shader support one full directional light, with all other lights computed per-vertex/SH. Makes shaders smaller as well." )); } GUILayout.Space( 8 ); _showFogSettings = EditorGUILayout.Foldout( _showFogSettings, "Fog Settings" ); if( _showFogSettings ) { _fogModeOverride = EditorGUILayout.BeginToggleGroup( "Fog Mode Override", _fogModeOverride ); var fogModeContent = new GUIContent("Fog Mode","The type of fog to use"); _fogMode = (FogMode)EditorGUILayout.EnumPopup( fogModeContent, _fogMode ); if( _fogMode == FogMode.Linear ) { _fogNearLinear.Value = EditorGUILayout.FloatField( "Near Linear Range:", _fogNearLinear ); _fogFarLinear.Value = EditorGUILayout.FloatField( "Far Linear Range:", _fogFarLinear ); } EditorGUILayout.EndToggleGroup(); _fogColorOverride = EditorGUILayout.BeginToggleGroup( "Fog Color Override", _fogColorOverride ); _fogColor.Value = EditorGUILayout.ColorField("Fog Color:", _fogColor ); EditorGUILayout.EndToggleGroup(); _fogDensityOverride = EditorGUILayout.BeginToggleGroup( "Fog Density Override", _fogDensityOverride ); _fogDensity.Value = EditorGUILayout.FloatField( "Fog Density:", _fogDensity ); EditorGUILayout.EndToggleGroup(); } }
public static RenderStateDescriptor ZWrite(ZWrite value) => new RenderStateDescriptor { type = RenderStateType.ZWrite, value = $"ZWrite {value}" };
//property.Expanded = EditorGUILayout.Foldout( property.Expanded, property.GetPropertyType().PropertyTypeString() ); public void Draw() { var shaderNameContent = new GUIContent( "Shader Name", "Name for shader. Includes the hierarchy listing, that is, MyShaders/Shader will be in a folder called \"MyShaders\" in the shader selection dropdown. Also used when referring to fallback shaders."); var oldColor = GUI.color; if (string.IsNullOrEmpty(_shaderName)) { GUI.color = Color.red; } _shaderName.Value = EditorGUILayout.TextField(shaderNameContent, _shaderName.Value); GUI.color = oldColor; var shaderFallbackContent = new GUIContent( "Shader Fallback", "Fallback shader to use in case this shader can not be used."); _shaderFallback.Value = EditorGUILayout.TextField(shaderFallbackContent, _shaderFallback.Value); var targetContent = new GUIContent("Shader Model", "Requires more recent hardware to use the shader, but allows for more instructions, texture reads, and more input information."); _shaderTarget = (ShaderTarget)EditorGUILayout.EnumPopup(targetContent, _shaderTarget); var excludePathContent = new GUIContent("Exclude Path", "Exclude a renderpath from shader generation"); _excludePath = (ExcludePath)EditorGUILayout.EnumPopup(excludePathContent, _excludePath); #if UNITY_5_3_OR_NEWER var shaderTypeContent = new GUIContent("Shader Type", "You can select Physically Based Rendering after Unity 5.3"); var currentshaderType = _shaderType; _shaderType = (ShaderType)EditorGUILayout.EnumPopup(shaderTypeContent, currentshaderType); if ((currentshaderType != _shaderType) && (OnChangeShaderType != null)) { OnChangeShaderType(); } #endif GUILayout.Space(8); _showQueueSettings = EditorGUILayout.Foldout(_showQueueSettings, "Queue Settings"); if (_showQueueSettings) { var renderTypeContent = new GUIContent("Render Type", "This is the rendertype tag inserted into the shader. Can be used for shader replace"); _renderType = (RenderType)EditorGUILayout.EnumPopup(renderTypeContent, _renderType); if (_renderType == RenderType.Custom) { _renderTypeCustom.Value = EditorGUILayout.TextField("Custom Type", _renderTypeCustom.Value); } var queueContent = new GUIContent("Render Queue", "The render queue that this material will be put in"); _queue = (Queue)EditorGUILayout.EnumPopup(queueContent, _queue); var offContent = new GUIContent( "Queue Offset", "Offset for drawing. Used to ensure some things draw before or after others, it specifically is an offset from the given queue- That is to say, you won't have a transparent object draw before an opaque object (or similar) due to this offset."); _queueAdjust = EditorGUILayout.IntSlider(offContent, _queueAdjust.Value, -100, 100); } GUILayout.Space(8); _showCullingAndDepthSettings = EditorGUILayout.Foldout(_showCullingAndDepthSettings, "Culling and Depth Settings"); if (_showCullingAndDepthSettings) { var zWriteContent = new GUIContent("Write Depth", "Depth is considered when testing other objects. Disable for certain effects, like letting other things draw over yourself, or for speed on most overlays."); _zWrite = (ZWrite)EditorGUILayout.EnumPopup(zWriteContent, _zWrite); var cullModeContent = new GUIContent("CullMode", "Select back / forward to clip backwards facing polygons"); _cullMode = (CullMode)EditorGUILayout.EnumPopup(cullModeContent, _cullMode); var zTestContent = new GUIContent("ZTest", "Select Z-Test Value"); _zTest = (ZTest)EditorGUILayout.EnumPopup(zTestContent, _zTest); var enableLODContent = new GUIContent("Enable LOD", "Enable Shader LOD scaling"); _enableLOD = EditorGUILayout.BeginToggleGroup(enableLODContent, _enableLOD); _lod = EditorGUILayout.IntSlider("LOD", _lod, 0, 1000); EditorGUILayout.EndToggleGroup(); } GUILayout.Space(8); _showBlending = EditorGUILayout.Foldout(_showBlending, "Blending Settings"); if (_showBlending) { var blendingTypeContent = new GUIContent("Blend Type", "Use a build in blend mode or a custom blend mode"); _blending = (BlendingType)EditorGUILayout.EnumPopup(blendingTypeContent, _blending); if (CustomBlendingEnabled()) { var srcBlendContent = new GUIContent("Src Blend Mode", "How the source channel of blending is used"); _srcBlend = (BlendingMode)EditorGUILayout.EnumPopup(srcBlendContent, _srcBlend); var dstBlendContent = new GUIContent("Dst Blend Mode", "How the destination channel of blending is used"); _dstBlend = (BlendingMode)EditorGUILayout.EnumPopup(dstBlendContent, _dstBlend); } } GUILayout.Space(8); _showColorAndLighting = EditorGUILayout.Foldout(_showColorAndLighting, "Color And Lighting Settings"); if (_showColorAndLighting) { GUILayout.BeginHorizontal(); GUILayout.Label("Color Mask:", GUILayout.ExpandWidth(false)); _colorMaskR.Value = EditorExtensions.ToggleButton(_colorMaskR.Value, "R", "Mask R Channel"); _colorMaskG.Value = EditorExtensions.ToggleButton(_colorMaskG.Value, "G", "Mask G Channel"); _colorMaskB.Value = EditorExtensions.ToggleButton(_colorMaskB.Value, "B", "Mask B Channel"); _colorMaskA.Value = EditorExtensions.ToggleButton(_colorMaskA.Value, "A", "Mask A Channel"); GUILayout.EndHorizontal(); _dualForward = GUILayout.Toggle(_dualForward, new GUIContent("Forward Dual Lightmaps", "Use dual lightmaps in the forward rendering path")); _fullForwardShadows = GUILayout.Toggle(_fullForwardShadows, new GUIContent("Forward Full Shadows", "Support all shadow types in Forward rendering path.")); _softVegetation = GUILayout.Toggle(_softVegetation, new GUIContent("Soft Vegetation", "Makes the surface shader only be rendered when Soft Vegetation is on.")); _noAmbient = GUILayout.Toggle(_noAmbient, new GUIContent("No Ambient", "Do not apply any ambient lighting or spherical harmonics lights.")); _noLightmap = GUILayout.Toggle(_noLightmap, new GUIContent("No Lightmaps", "Disables lightmap support in this shader (makes a shader smaller).")); _addShadow = GUILayout.Toggle(_addShadow, new GUIContent("Advanced Shadow Pass", "Performs vertex transformations and clipping for the shadow pass, you need to use this if shadows do not display properly.")); _ignoreProjectors = GUILayout.Toggle(_ignoreProjectors, new GUIContent("Ignore Projectors", "Ignores projector components, should be used if your doing custom vertex transformations or most transparency")); _approxview = GUILayout.Toggle(_approxview, new GUIContent("Approximate View", "Computes normalized view direction per-vertex instead of per-pixel, for shaders that need it. This is faster, but view direction is not entirely correct when camera gets close to surface.")); _halfasview = GUILayout.Toggle(_halfasview, new GUIContent("Half As View", "Pass half-direction vector into the lighting function instead of view-direction. Half-direction will be computed and normalized per vertex. This is faster, but not entirely correct.")); _noForwardAdd = GUILayout.Toggle(_noForwardAdd, new GUIContent("Disable Forward Add", "Disables Forward rendering additive pass. This makes the shader support one full directional light, with all other lights computed per-vertex/SH. Makes shaders smaller as well.")); } GUILayout.Space(8); _showFogSettings = EditorGUILayout.Foldout(_showFogSettings, "Fog Settings"); if (_showFogSettings) { _fogModeOverride = EditorGUILayout.BeginToggleGroup("Fog Mode Override", _fogModeOverride); var fogModeContent = new GUIContent("Fog Mode", "The type of fog to use"); _fogMode = (FogMode)EditorGUILayout.EnumPopup(fogModeContent, _fogMode); if (_fogMode == FogMode.Linear) { _fogNearLinear.Value = EditorGUILayout.FloatField("Near Linear Range:", _fogNearLinear); _fogFarLinear.Value = EditorGUILayout.FloatField("Far Linear Range:", _fogFarLinear); } EditorGUILayout.EndToggleGroup(); _fogColorOverride = EditorGUILayout.BeginToggleGroup("Fog Color Override", _fogColorOverride); _fogColor.Value = EditorGUILayout.ColorField("Fog Color:", _fogColor); EditorGUILayout.EndToggleGroup(); _fogDensityOverride = EditorGUILayout.BeginToggleGroup("Fog Density Override", _fogDensityOverride); _fogDensity.Value = EditorGUILayout.FloatField("Fog Density:", _fogDensity); EditorGUILayout.EndToggleGroup(); } }
public Command() // default { ZWrite = ZWrite.Off; ZTest = ZTest.LEqual; Cull = Cull.Back; // Don’t render polygons that are facing away from the viewer }