Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stalomeow/shaderutilsforsrp
Utilities for SRP shaders.
https://github.com/stalomeow/shaderutilsforsrp
shader srp unity
Last synced: 2 months ago
JSON representation
Utilities for SRP shaders.
- Host: GitHub
- URL: https://github.com/stalomeow/shaderutilsforsrp
- Owner: stalomeow
- License: mit
- Created: 2023-07-02T13:22:14.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-10T14:16:01.000Z (over 1 year ago)
- Last Synced: 2024-06-06T22:50:14.422Z (8 months ago)
- Topics: shader, srp, unity
- Language: C#
- Homepage:
- Size: 454 KB
- Stars: 52
- Watchers: 3
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Shader Utils for SRP v2
[![openupm](https://img.shields.io/npm/v/com.stalomeow.srp-shader-utils?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.cn/packages/com.stalomeow.srp-shader-utils/)
Utilities for **SRP** shaders.
## Requirements
- Unity >= 2021.3.
- Core RP Library >= 12.0.0.## File Extensions
Create HLSL and SRP Shader files easily using menu item.
![menu item](Screenshots~/menu_item.png)
## Preference Settings
Settings can be found in `Preferences/Shader Utils for SRP`.
![pref settings](Screenshots~/pref_settings.png)
## Advanced Shader GUI
Use `StaloSRPShaderGUI` as CustomEditor.
``` shaderlab
CustomEditor "StaloSRPShaderGUI"
```![shader gui](Screenshots~/shader_gui.png)
### Advanced Shader Property Attributes
- `HeaderFoldout(label[, ...tooltips])`
Begin an animated foldout header.
- `Indent([count])`
Add indents before the property. The default count is 1.
- `HelpBox(None|Info|Warning|Error, ...messages)`
Display a HelpBox above the property.
- `PostHelpBox(None|Info|Warning|Error, ...messages)`
Display a HelpBox under the property.
- `MinMaxRange(min-limit, max-limit)`
Display a vector property with a MinMaxSlider.
- `property.x`: Min value.
- `property.y`: Max value.- `RampTexture`
Display a texture as a ramp texture (similar to a color gradient).
- `SingleLineTextureNoScaleOffset([color-property])`
Display a texture property in single line without `Tiling` and `Offset`. If `color-property` is specified, an additional color field will be displayed next to the texture.
- `TextureScaleOffset`
Display a vector property as the `Tiling` and `Offset` of a texture.
- `property.xy`: Tiling (Scale).
- `property.zw`: Offset.- `If(expr)`
Display the property if `expr` evaluates to `true`. You can write complex expression like `((not _KEYWORD_A and true) or (_KEYWORD_B and not not not false)) and not _KEYWORD_C`.
Operator precedence: `not` > `and` > `or`.
### Material Property Wrapper
This is similar to Unity's `MaterialPropertyDrawer`.
You can write a custom class inherited from `MaterialPropertyWrapper` (in namespace `Stalo.ShaderUtils.Editor`) to control the GUI of a material property.
Here's an example:
``` c#
internal class PostHelpBoxWrapper : MaterialPropertyWrapper
{
private readonly MessageType m_MsgType;
private readonly string m_Message;public PostHelpBoxWrapper(string rawArgs) : base(rawArgs)
{
string[] args = rawArgs.Split(',', StringSplitOptions.RemoveEmptyEntries);for (int i = 0; i < args.Length; i++)
{
args[i] = args[i].Trim();
}m_MsgType = Enum.Parse(args[0]);
m_Message = string.Join(", ", args[1..]);
}public override void OnDidDrawProperty(MaterialProperty prop, string label, MaterialEditor editor)
{
EditorGUILayout.HelpBox(m_Message, m_MsgType);
}
}
```