Second commit
This commit is contained in:
commit
36840f3ad4
999 files changed
+61364
No files matched your search
@@ -0,0 +1,85 @@
|
||||
Shader "Unlit/BrushPainter"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_DrawPosition("Draw Position", Vector) = (0.5, 0.5, 0, 0)
|
||||
_DrawRadius("Draw Radius", Float) = 0.05
|
||||
_DrawAngleX("Draw Angle (Rad) X", Float) = 0.0
|
||||
_DrawAngleY("Draw Angle (Rad) Y", Float) = 0.0
|
||||
_ToolDirtiness("Tool Dirtiness", Range(0, 1)) = 0
|
||||
[MainTexture] _BrushTex("Brush Texture", 2D) = "white" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderType" = "Transparent"
|
||||
"Queue" = "Transparent"
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
ZTest Always
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionHCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 _DrawPosition;
|
||||
float _DrawRadius;
|
||||
float _DrawAngleX;
|
||||
float _DrawAngleY;
|
||||
float _ToolDirtiness;
|
||||
|
||||
TEXTURE2D(_BrushTex);
|
||||
SAMPLER(sampler_BrushTex);
|
||||
|
||||
Varyings vert(Attributes IN)
|
||||
{
|
||||
Varyings OUT;
|
||||
OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
|
||||
OUT.uv = IN.uv;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
half4 frag(Varyings IN) : SV_Target
|
||||
{
|
||||
float2 centeredUV = (IN.uv - _DrawPosition.xy) / (_DrawRadius * 2.0);
|
||||
|
||||
float2 rotatedUV;
|
||||
rotatedUV.x = centeredUV.x * _DrawAngleX - centeredUV.y * _DrawAngleY;
|
||||
rotatedUV.y = centeredUV.x * _DrawAngleY + centeredUV.y * _DrawAngleX;
|
||||
|
||||
float2 brushUV = rotatedUV + 0.5;
|
||||
|
||||
float inBounds = step(0.0, brushUV.x) * step(brushUV.x, 1.0) *
|
||||
step(0.0, brushUV.y) * step(brushUV.y, 1.0);
|
||||
|
||||
half4 brushColor = SAMPLE_TEXTURE2D(_BrushTex, sampler_BrushTex, brushUV);
|
||||
|
||||
float brushMask = brushColor.a * inBounds;
|
||||
float fillValue = _ToolDirtiness * brushMask;
|
||||
|
||||
return half4(fillValue, fillValue, fillValue, brushMask);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31f42842d3a8460ea125575cb5a72a5a
|
||||
timeCreated: 1785925570
|
||||
Reference in new issue
Block a user