Added Presets.

Reworked shaders and added more presets.
This commit is contained in:
max
2021-03-31 13:01:43 +02:00
parent 12a4122134
commit a4eafe007c
51 changed files with 2126 additions and 108 deletions

View File

@ -0,0 +1,30 @@
Shader "Hidden/RS/Lit"
{
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
#include "RSPropertiesCG.cginc"
struct Input
{
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_RS_Texture, IN.uv_MainTex) * _RS_Color;
o.Albedo = c.rgb;
o.Metallic = _RS_Metallic;
o.Smoothness = _RS_Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: fa8b3bbeb520d1c47b2ee619fe14e343
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,37 @@
Shader "Hidden/RS/ObjectSpaceNormals"
{
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f
{
half3 normal : TEXCOORD0;
float4 pos : SV_POSITION;
};
v2f vert(float4 vertex : POSITION, float3 normal : NORMAL)
{
v2f o;
o.pos = UnityObjectToClipPos(vertex);
o.normal = normal;
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 c = 0;
c.a = 1;
c.rgb = i.normal * 0.5 + 0.5;
return c;
}
ENDCG
}
}
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7f376fdcb4cabb94fa00a24677019988
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,4 @@
Shader "Hidden/Overdraw"
Shader "Hidden/RS/Overdraw"
{
SubShader
{
@ -19,6 +19,8 @@ Shader "Hidden/Overdraw"
#pragma fragment frag
#include "UnityCG.cginc"
#include "RSPropertiesCG.cginc"
#include "RSUtilsCG.cginc"
struct appdata
{
@ -37,8 +39,6 @@ Shader "Hidden/Overdraw"
return o;
}
fixed4 _RS_Color;
fixed4 frag (v2f i) : SV_Target
{
return _RS_Color;

View File

@ -0,0 +1,11 @@
#ifndef RS_PROPERTIES_CG_INCLUDED
#define RS_PROPERTIES_CG_INCLUDED
sampler2D _RS_Texture;
float4 _RS_Texture_ST;
float _RS_Sharpness;
fixed4 _RS_Color;
half _RS_Metallic;
half _RS_Glossiness;
#endif

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 932b73fee7600724b8740711c79dc3fc
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,37 @@
#ifndef RS_UTILS_CG_INCLUDED
#define RS_UTILS_CG_INCLUDED
// https://www.ronja-tutorials.com/post/010-triplanar-mapping/
fixed4 SampleTriPlanar(sampler2D tex, float4 tex_ST, float3 position, float3 normal, float sharpness)
{
//calculate UV coordinates for three projections
float2 uv_front = TRANSFORM_TEX(position.xy, tex);
float2 uv_side = TRANSFORM_TEX(position.zy, tex);
float2 uv_top = TRANSFORM_TEX(position.xz, tex);
//read texture at uv position of the three projections
fixed4 col_front = tex2D(tex, uv_front);
fixed4 col_side = tex2D(tex, uv_side);
fixed4 col_top = tex2D(tex, uv_top);
//generate weights from world normals
float3 weights = normal;
//show texture on both sides of the object (positive and negative)
weights = abs(weights);
//make the transition sharper
weights = pow(weights, sharpness);
//make it so the sum of all components is 1
weights = weights / (weights.x + weights.y + weights.z);
//combine weights with projected colors
col_front *= weights.z;
col_side *= weights.x;
col_top *= weights.y;
//combine the projected colors
fixed4 col = col_front + col_side + col_top;
return col;
}
#endif

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6a6a8ee4b7ec5974abb1157bc943d8de
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,4 +1,4 @@
Shader "Hidden/Surface"
Shader "Hidden/RS/TriPlanarLit"
{
SubShader
{
@ -12,23 +12,24 @@ Shader "Hidden/Surface"
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _RS_Texture;
fixed4 _RS_Color;
half _RS_Metallic;
half _RS_Glossiness;
#include "RSPropertiesCG.cginc"
#include "RSUtilsCG.cginc"
struct Input
{
float2 uv_RS_Texture;
float3 worldPos;
float3 worldNormal;
};
void surf (Input IN, inout SurfaceOutputStandard o)
{
o.Albedo = tex2D(_RS_Texture, IN.uv_RS_Texture) * _RS_Color;
fixed4 c = SampleTriPlanar(_RS_Texture, _RS_Texture_ST, IN.worldPos, IN.worldNormal, _RS_Sharpness);
o.Albedo = c * _RS_Color;
o.Metallic = _RS_Metallic;
o.Smoothness = _RS_Glossiness;
}
ENDCG
}
FallBack "Diffuse"
}
}

View File

@ -1,79 +0,0 @@
// https://www.ronja-tutorials.com/post/010-triplanar-mapping/
Shader "Hidden/TriPlanarTexture"
{
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct v2f
{
float4 vertex : SV_POSITION;
float3 worldPos : TEXCOORD0;
float3 normal : TEXCOORD1;
};
sampler2D _RS_Texture;
float4 _RS_Texture_ST;
float _RS_Sharpness;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
o.normal = normalize(mul(v.normal, (float3x3)unity_WorldToObject));
return o;
}
fixed4 frag (v2f i) : SV_Target
{
//calculate UV coordinates for three projections
float2 uv_front = TRANSFORM_TEX(i.worldPos.xy, _RS_Texture);
float2 uv_side = TRANSFORM_TEX(i.worldPos.zy, _RS_Texture);
float2 uv_top = TRANSFORM_TEX(i.worldPos.xz, _RS_Texture);
//read texture at uv position of the three projections
fixed4 col_front = tex2D(_RS_Texture, uv_front);
fixed4 col_side = tex2D(_RS_Texture, uv_side);
fixed4 col_top = tex2D(_RS_Texture, uv_top);
//generate weights from world normals
float3 weights = i.normal;
//show texture on both sides of the object (positive and negative)
weights = abs(weights);
//make the transition sharper
weights = pow(weights, _RS_Sharpness);
//make it so the sum of all components is 1
weights = weights / (weights.x + weights.y + weights.z);
//combine weights with projected colors
col_front *= weights.z;
col_side *= weights.x;
col_top *= weights.y;
//combine the projected colors
fixed4 col = col_front + col_side + col_top;
return col;
// return fixed4(abs(i.normal.xyz), 1);
}
ENDCG
}
}
}

View File

@ -0,0 +1,50 @@
Shader "Hidden/RS/TriPlanarUnlit"
{
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "RSPropertiesCG.cginc"
#include "RSUtilsCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct v2f
{
float4 vertex : SV_POSITION;
float3 worldPos : TEXCOORD0;
float3 normal : TEXCOORD1;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
o.normal = normalize(mul(v.normal, (float3x3)unity_WorldToObject));
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 c = SampleTriPlanar(_RS_Texture, _RS_Texture_ST, i.worldPos, i.normal, _RS_Sharpness);
c *= _RS_Color;
return c;
//return fixed4(abs(i.normal.xyz), 1);
}
ENDCG
}
}
}

View File

@ -0,0 +1,45 @@
Shader "Hidden/RS/Unlit"
{
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "RSPropertiesCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _RS_Texture);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_RS_Texture, i.uv);
return col;
}
ENDCG
}
}
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b7f90ee778e287d4f9bde3252fe9bdd9
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,46 @@
// https://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html
Shader "Hidden/RS/WorldSpaceNormals"
{
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// include file that contains UnityObjectToWorldNormal helper function
#include "UnityCG.cginc"
struct v2f
{
// we'll output world space normal as one of regular ("texcoord") interpolators
half3 worldNormal : TEXCOORD0;
float4 pos : SV_POSITION;
};
// vertex shader: takes object space normal as input too
v2f vert(float4 vertex : POSITION, float3 normal : NORMAL)
{
v2f o;
o.pos = UnityObjectToClipPos(vertex);
// UnityCG.cginc file contains function to transform
// normal from object to world space, use that
o.worldNormal = UnityObjectToWorldNormal(normal);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed4 c = 0;
c.a = 1;
// normal is a 3D vector with xyz components; in -1..1
// range. To display it as color, bring the range into 0..1
// and put into red, green, blue components
c.rgb = i.worldNormal * 0.5 + 0.5;
return c;
}
ENDCG
}
}
}

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: f2163d0d9cb9f8a4fbb6c07dcf8ac7d3
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 60a6c65bf59247d41bcc18553d97d2c5
guid: cb526cf389f85f541aa681de312dd588
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
@ -32,7 +32,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
filterMode: -1
aniso: 2
mipBias: -100
wrapU: 0

BIN
Runtime/Textures/UV_01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

View File

@ -0,0 +1,144 @@
fileFormatVersion: 2
guid: f2e2a666b464cc84982b530d4dcd36d7
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 2
mipBias: -100
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,144 @@
fileFormatVersion: 2
guid: f8b8cfeccdb9c194bac037761af51a41
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 2
mipBias: -100
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant: