Initial Commit
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
Shader "DBV/Kristo/FastGrass2.0"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic ("Metallic", Range(0,1)) = 0.0
|
||||
|
||||
[Space]
|
||||
_AlphaCutoff ("Alpha cutoff", Range(0,1)) = 0.05
|
||||
|
||||
[Space]
|
||||
_WindTexture ("Wind texture", 2D) = "white" {}
|
||||
_WindSpeed ("Wind direction", Vector) = (1,1,1,1)
|
||||
_HeightStart ("Height start", Float) = 0.05
|
||||
_WindStrength ("Wind strength", Float) = 1
|
||||
_WindTimeSpeed ("Wind speed", Float) = 1
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Transparent" }
|
||||
LOD 200
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
|
||||
CGPROGRAM
|
||||
// Physically based Standard lighting model, and enable shadows on all light types
|
||||
#pragma surface surf Standard vertex:vert noshadowmask nodynlightmap nodirlightmap nolightmap noshadow
|
||||
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex,_WindTexture;
|
||||
|
||||
struct Input {
|
||||
float2 uv_MainTex;
|
||||
};
|
||||
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
fixed4 _Color;
|
||||
float _AlphaCutoff, _HeightStart, _WindStrength, _WindTimeSpeed;
|
||||
float4 _WindSpeed;
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
// put more per-instance properties here
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
void vert (inout appdata_full v) {
|
||||
// get vertex world position
|
||||
float4 worldPos = mul(v.vertex, unity_ObjectToWorld);
|
||||
float2 samplePos = worldPos.xz;
|
||||
samplePos += _Time.x * _WindSpeed.xz;
|
||||
float windAmount = tex2Dlod(_WindTexture, float4(samplePos, 0, 0));
|
||||
float heightAmount = v.vertex.z > _HeightStart;//v.vertex.y - _HeightStart;
|
||||
v.vertex.y += sin(_WindTimeSpeed*windAmount)*_WindStrength * heightAmount;
|
||||
v.vertex.x += cos(_WindTimeSpeed*windAmount)*_WindStrength * heightAmount;
|
||||
}
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o)
|
||||
{
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb;
|
||||
// Metallic and smoothness come from slider variables
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
clip(c.a-_AlphaCutoff);
|
||||
o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db7b361255b6374438781f932dd1e8e0
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,334 @@
|
||||
// Used Unitys "Standard geometry shader example" as a base to get unitys standard lighting and stuff w/ a custom geometry stage since surface shaders dont allow this
|
||||
//and when writing from the ground up lighting has to be done by hand
|
||||
// https://github.com/keijiro/StandardGeometryShader
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityGBuffer.cginc"
|
||||
#include "UnityStandardUtils.cginc"
|
||||
|
||||
// Cube map shadow caster; Used to render point light shadows on platforms
|
||||
// that lacks depth cube map support.
|
||||
#if defined(SHADOWS_CUBE) && !defined(SHADOWS_CUBE_IN_DEPTH_TEX)
|
||||
#define PASS_CUBE_SHADOWCASTER
|
||||
#endif
|
||||
|
||||
// Shader uniforms
|
||||
half4 _Color;
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
|
||||
sampler2D _BumpMap;
|
||||
float _BumpScale;
|
||||
|
||||
sampler2D _OcclusionMap;
|
||||
float _OcclusionStrength;
|
||||
|
||||
float _LocalTime;
|
||||
|
||||
// Vertex input attributes
|
||||
struct Attributes {
|
||||
float4 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
float2 texcoord : TEXCOORD;
|
||||
};
|
||||
|
||||
// Fragment varyings
|
||||
struct Varyings {
|
||||
float4 position : SV_POSITION;
|
||||
|
||||
#if defined(PASS_CUBE_SHADOWCASTER)
|
||||
// Cube map shadow caster pass
|
||||
float3 shadow : TEXCOORD0;
|
||||
|
||||
#elif defined(UNITY_PASS_SHADOWCASTER)
|
||||
// Default shadow caster pass
|
||||
|
||||
#else
|
||||
// GBuffer construction pass
|
||||
float3 normal : NORMAL;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 tspace0 : TEXCOORD1;
|
||||
float4 tspace1 : TEXCOORD2;
|
||||
float4 tspace2 : TEXCOORD3;
|
||||
half3 ambient : TEXCOORD4;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
//
|
||||
// Vertex stage
|
||||
//
|
||||
|
||||
Attributes Vertex(Attributes input) {
|
||||
// Only do object space to world space transform.
|
||||
input.position = mul(unity_ObjectToWorld, input.position);
|
||||
input.normal = UnityObjectToWorldNormal(input.normal);
|
||||
input.tangent.xyz = UnityObjectToWorldDir(input.tangent.xyz);
|
||||
input.texcoord = TRANSFORM_TEX(input.texcoord, _MainTex);
|
||||
return input;
|
||||
}
|
||||
|
||||
//
|
||||
// Geometry stage
|
||||
//
|
||||
|
||||
Varyings VertexOutput(float3 wpos, half3 wnrm, half4 wtan, float2 uv) {
|
||||
Varyings o;
|
||||
#if defined(PASS_CUBE_SHADOWCASTER)
|
||||
// Cube map shadow caster pass: Transfer the shadow vector.
|
||||
o.position = UnityWorldToClipPos(float4(wpos, 1));
|
||||
o.shadow = wpos - _LightPositionRange.xyz;
|
||||
#elif defined(UNITY_PASS_SHADOWCASTER)
|
||||
// Default shadow caster pass: Apply the shadow bias.
|
||||
float scos = dot(wnrm, normalize(UnityWorldSpaceLightDir(wpos)));
|
||||
wpos -= wnrm * unity_LightShadowBias.z * sqrt(1 - scos * scos);
|
||||
o.position = UnityApplyLinearShadowBias(UnityWorldToClipPos(float4(wpos, 1)));
|
||||
#else
|
||||
// GBuffer construction pass
|
||||
half3 bi = cross(wnrm, wtan) * wtan.w * unity_WorldTransformParams.w;
|
||||
o.position = UnityWorldToClipPos(float4(wpos, 1));
|
||||
o.normal = wnrm;
|
||||
o.texcoord = uv;
|
||||
o.tspace0 = float4(wtan.x, bi.x, wnrm.x, wpos.x);
|
||||
o.tspace1 = float4(wtan.y, bi.y, wnrm.y, wpos.y);
|
||||
o.tspace2 = float4(wtan.z, bi.z, wnrm.z, wpos.z);
|
||||
o.ambient = ShadeSHPerVertex(wnrm, 0);
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
float3 ConstructNormal(float3 v1, float3 v2, float3 v3) {
|
||||
return normalize(cross(v2 - v1, v3 - v1));
|
||||
}
|
||||
|
||||
float rand(float3 co){
|
||||
return frac(sin(dot(co.xyz, float3(12.9898, 78.233, 53.539))) * 43758.5453);
|
||||
}
|
||||
float3x3 AngleAxis3x3(float angle, float3 axis){
|
||||
float c, s;
|
||||
sincos(angle, s, c);
|
||||
float t = 1 - c;
|
||||
float x = axis.x;
|
||||
float y = axis.y;
|
||||
float z = axis.z;
|
||||
return float3x3(
|
||||
t * x * x + c, t * x * y - s * z, t * x * z + s * y,
|
||||
t * x * y + s * z, t * y * y + c, t * y * z - s * x,
|
||||
t * x * z - s * y, t * y * z + s * x, t * z * z + c
|
||||
);
|
||||
}
|
||||
|
||||
float _BladeHeight, _BladeHeightRandom, _BladeWidth, _BladeWidthRandom, _BendRotationRandom;
|
||||
int _Test;
|
||||
|
||||
[instance(5)]
|
||||
[maxvertexcount(42)]
|
||||
void Geometry( triangle Attributes input[3], uint pid : SV_PrimitiveID, inout TriangleStream<Varyings> outStream, uint InstanceID : SV_GSInstanceID) {
|
||||
//Vertex inputs;
|
||||
|
||||
//
|
||||
//float2 uv0 = input[0].texcoord;
|
||||
//float2 uv1 = input[1].texcoord;
|
||||
//float2 uv2 = input[2].texcoord;
|
||||
|
||||
float3 pos = input[0].position;
|
||||
float3 vNormal = input[0].normal;
|
||||
float4 vTangent = input[0].tangent;
|
||||
float3 vBinormal = cross (vNormal,vTangent)*vTangent.w;
|
||||
|
||||
float height = (rand(pos.zyx) * 2 - 1) * _BladeHeightRandom + _BladeHeight;
|
||||
float width = (rand(pos.xzy) * 2 - 1) * _BladeWidthRandom + _BladeWidth;
|
||||
|
||||
float3x3 tangentToLocal = float3x3(
|
||||
vTangent.x, vBinormal.x, vNormal.x,
|
||||
vTangent.y, vBinormal.y, vNormal.y,
|
||||
vTangent.z, vBinormal.z, vNormal.z
|
||||
);
|
||||
|
||||
|
||||
|
||||
//TODO add geometry instancing
|
||||
//TODO create nodes based on world pos
|
||||
//TODO find out if need to remember geometry instancing index to create mor tris
|
||||
//TODO keep track of how many verts used
|
||||
|
||||
//Add node
|
||||
//float3 wn = ConstructNormal(wp3, wp4, wp5);
|
||||
//outStream.Append(VertexOutput(pos + mul(transformationMatrix, float3( width, 0, 0 )),half3(0,1,0),float4(1,1,0,0), float2(1.25,0) ));
|
||||
//outStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(-width, 0, 0 )),half3(0,1,0),float4(1,1,0,0), float2(-0.25,0) ));
|
||||
//outStream.Append(VertexOutput(pos + mul(transformationMatrix, float3( 0 , 0, height)),half3(0,1,0),float4(1,1,0,0), float2(0.5,1.5) ));
|
||||
//outStream.RestartStrip();
|
||||
//outStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(0, width, 0 )),half3(0,1,0),float4(1,1,0,0), float2(1.25,0) ));
|
||||
//outStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(0, -width, 0 )),half3(0,1,0),float4(1,1,0,0), float2(-0.25,0) ));
|
||||
//outStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(0, 0 , height)),half3(0,1,0),float4(1,1,0,0), float2(0.5,1.5) ));
|
||||
//outStream.RestartStrip();
|
||||
|
||||
//Do triangle
|
||||
float3 wp0 = input[0].position.xyz;
|
||||
float3 wp1 = input[1].position.xyz;
|
||||
float3 wp2 = input[2].position.xyz;
|
||||
//1. Order points
|
||||
float3 p1 = max(wp0,max(wp1,wp2));
|
||||
float3 p2;
|
||||
float3 p3 = min(wp0,min(wp1,wp2));
|
||||
if (all(p1 >= wp0) && all(p3 <= wp0)) {p2 = wp0;}
|
||||
else if(all(p1 >= wp1) && all(p3 <= wp1)) {p2 = wp1;}
|
||||
else if(all(p1 >= wp2) && all(p3 <= wp2)) {p2 = wp2;}
|
||||
//2. Get directions
|
||||
float3 vec1 = p3-p1;
|
||||
float3 vec2 = p2-p1;
|
||||
float3 vec3 = p3-p2;
|
||||
float dir1Len = length(vec1);
|
||||
float dir2Len = length(vec2);
|
||||
float dir3Len = length(vec3);
|
||||
float3 dir1 = vec1 / dir1Len;
|
||||
float3 dir2 = vec2 / dir2Len;
|
||||
float3 dir3 = vec3 / dir3Len;
|
||||
//3. Define values
|
||||
float unit = 0.5;
|
||||
float3 step1 = dir1 * unit;
|
||||
float3 step2 = dir2 * unit * abs(vec2.x/vec1.x);
|
||||
float3 step3 = dir3 * unit;
|
||||
float3 current1 = p1;
|
||||
float3 current2 = p1;
|
||||
//4. loop
|
||||
int unitsToX = abs(floor(vec1.x/unit));
|
||||
for (int i = 0; i < unitsToX; ++i) {
|
||||
current1 += step1;
|
||||
current2 += step2;
|
||||
int unitsToZ = abs(floor((current1.z-current2.z)/unit));
|
||||
//1. create start and ends
|
||||
float3 current = floor(current1);
|
||||
for (int j = 0; j < unitsToZ; ++j) {//loop and create nodes
|
||||
|
||||
float3x3 facingRotationMatrix = AngleAxis3x3(rand(pos) * UNITY_TWO_PI, float3(0, 0, 1));
|
||||
float3x3 bendRotationMatrix = AngleAxis3x3(rand(pos.zzx) * _BendRotationRandom * UNITY_PI * 0.5, float3(-1, 0, 0));
|
||||
float3x3 transformationMatrix = mul(mul(tangentToLocal, facingRotationMatrix),bendRotationMatrix);
|
||||
|
||||
float k = i+j+1;
|
||||
//-Creat node- START
|
||||
outStream.Append(VertexOutput(current + mul(transformationMatrix, float3( width, 0, 0 )),half3(0,1,0),float4(1,1,0,0), float2(1.25,0) ));
|
||||
outStream.Append(VertexOutput(current + mul(transformationMatrix, float3(-width, 0, 0 )),half3(0,1,0),float4(1,1,0,0), float2(-0.25,0) ));
|
||||
outStream.Append(VertexOutput(current + mul(transformationMatrix, float3( 0 , 0, height*k)),half3(0,1,0),float4(1,1,0,0), float2(0.5,1.5) ));
|
||||
outStream.RestartStrip();
|
||||
outStream.Append(VertexOutput(current + mul(transformationMatrix, float3(0, width, 0 )),half3(0,1,0),float4(1,1,0,0), float2(1.25,0) ));
|
||||
outStream.Append(VertexOutput(current + mul(transformationMatrix, float3(0, -width, 0 )),half3(0,1,0),float4(1,1,0,0), float2(-0.25,0) ));
|
||||
outStream.Append(VertexOutput(current + mul(transformationMatrix, float3(0, 0 , height*k)),half3(0,1,0),float4(1,1,0,0), float2(0.5,1.5) ));
|
||||
outStream.RestartStrip();
|
||||
//-Create node- END
|
||||
|
||||
current.z += unit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Extrusion amount
|
||||
//float ext = saturate(0.4 - cos(_LocalTime * UNITY_PI * 2) * 0.41);
|
||||
//ext *= 1 + 0.3 * sin(pid * 832.37843 + _LocalTime * 88.76);
|
||||
//
|
||||
//// Extrusion points
|
||||
//float3 offs = ConstructNormal(wp0, wp1, wp2) * ext;
|
||||
//float3 wp3 = wp0 + offs;
|
||||
//float3 wp4 = wp1 + offs;
|
||||
//float3 wp5 = wp2 + offs;
|
||||
//
|
||||
//// Cap triangle
|
||||
//float3 wn = ConstructNormal(wp3, wp4, wp5);
|
||||
//float np = saturate(ext * 10);
|
||||
//float3 wn0 = lerp(input[0].normal, wn, np);
|
||||
//float3 wn1 = lerp(input[1].normal, wn, np);
|
||||
//float3 wn2 = lerp(input[2].normal, wn, np);
|
||||
//outStream.Append(VertexOutput(wp3, wn0, input[0].tangent, uv0));
|
||||
//outStream.Append(VertexOutput(wp4, wn1, input[1].tangent, uv1));
|
||||
//outStream.Append(VertexOutput(wp5, wn2, input[2].tangent, uv2));
|
||||
//outStream.RestartStrip();
|
||||
//
|
||||
//// Side faces
|
||||
//float4 wt = float4(normalize(wp3 - wp0), 1); // world space tangent
|
||||
//wn = ConstructNormal(wp3, wp0, wp4);
|
||||
//outStream.Append(VertexOutput(wp3, wn, wt, uv0));
|
||||
//outStream.Append(VertexOutput(wp0, wn, wt, uv0));
|
||||
//outStream.Append(VertexOutput(wp4, wn, wt, uv1));
|
||||
//outStream.Append(VertexOutput(wp1, wn, wt, uv1));
|
||||
//outStream.RestartStrip();
|
||||
//
|
||||
//wn = ConstructNormal(wp4, wp1, wp5);
|
||||
//outStream.Append(VertexOutput(wp4, wn, wt, uv1));
|
||||
//outStream.Append(VertexOutput(wp1, wn, wt, uv1));
|
||||
//outStream.Append(VertexOutput(wp5, wn, wt, uv2));
|
||||
//outStream.Append(VertexOutput(wp2, wn, wt, uv2));
|
||||
//outStream.RestartStrip();
|
||||
//
|
||||
//wn = ConstructNormal(wp5, wp2, wp3);
|
||||
//outStream.Append(VertexOutput(wp5, wn, wt, uv2));
|
||||
//outStream.Append(VertexOutput(wp2, wn, wt, uv2));
|
||||
//outStream.Append(VertexOutput(wp3, wn, wt, uv0));
|
||||
//outStream.Append(VertexOutput(wp0, wn, wt, uv0));
|
||||
//outStream.RestartStrip();
|
||||
}
|
||||
|
||||
//
|
||||
// Fragment phase
|
||||
//
|
||||
|
||||
#if defined(PASS_CUBE_SHADOWCASTER)
|
||||
|
||||
// Cube map shadow caster pass
|
||||
half4 Fragment(Varyings input) : SV_Target {
|
||||
float depth = length(input.shadow) + unity_LightShadowBias.x;
|
||||
return UnityEncodeCubeShadowDepth(depth * _LightPositionRange.w);
|
||||
}
|
||||
|
||||
#elif defined(UNITY_PASS_SHADOWCASTER)
|
||||
|
||||
// Default shadow caster pass
|
||||
half4 Fragment() : SV_Target { return 0; }
|
||||
|
||||
#else
|
||||
|
||||
float _AlphaCutoff;
|
||||
|
||||
// GBuffer construction pass
|
||||
void Fragment( Varyings input, out half4 outGBuffer0 : SV_Target0, out half4 outGBuffer1 : SV_Target1, out half4 outGBuffer2 : SV_Target2, out half4 outEmission : SV_Target3) {
|
||||
// Sample textures
|
||||
float4 sample = tex2D(_MainTex, input.texcoord);
|
||||
if(sample.a <= _AlphaCutoff) clip(-1);
|
||||
half3 albedo = sample.rgb * _Color.rgb;
|
||||
|
||||
half4 normal = tex2D(_BumpMap, input.texcoord);
|
||||
normal.xyz = UnpackScaleNormal(normal, _BumpScale);
|
||||
|
||||
half occ = tex2D(_OcclusionMap, input.texcoord).g;
|
||||
occ = LerpOneTo(occ, _OcclusionStrength);
|
||||
|
||||
// PBS workflow conversion (metallic -> specular)
|
||||
half3 c_diff, c_spec;
|
||||
half refl10;
|
||||
c_diff = DiffuseAndSpecularFromMetallic(
|
||||
albedo, _Metallic, // input
|
||||
c_spec, refl10 // output
|
||||
);
|
||||
|
||||
// Tangent space conversion (tangent space normal -> world space normal)
|
||||
float3 wn = normalize(float3( dot(input.tspace0.xyz, normal), dot(input.tspace1.xyz, normal), dot(input.tspace2.xyz, normal) ));
|
||||
|
||||
// Update the GBuffer.
|
||||
UnityStandardData data;
|
||||
data.diffuseColor = c_diff;
|
||||
data.occlusion = occ;
|
||||
data.specularColor = c_spec;
|
||||
data.smoothness = _Glossiness;
|
||||
data.normalWorld = wn;
|
||||
UnityStandardDataToGbuffer(data, outGBuffer0, outGBuffer1, outGBuffer2);
|
||||
|
||||
// Calculate ambient lighting and output to the emission buffer.
|
||||
float3 wp = float3(input.tspace0.w, input.tspace1.w, input.tspace2.w);
|
||||
half3 sh = ShadeSHPerPixel(data.normalWorld, input.ambient, wp);
|
||||
outEmission = half4(sh * c_diff, 1) * occ;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1828c58b5b8ba824296cee46b4d55d78
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,86 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GrassMaterial
|
||||
m_Shader: {fileID: 4800000, guid: db7b361255b6374438781f932dd1e8e0, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 1
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 527cea5a6b017984894d91563b2bdefb, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _WindTexture:
|
||||
m_Texture: {fileID: 2800000, guid: 5e187697202a0ca4f80836a911eb0633, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _AlphaCutoff: 0.948
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 1
|
||||
- _GlossyReflections: 1
|
||||
- _HeightStart: 0.86
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _WindStrength: 0.5
|
||||
- _WindTimeSpeed: 0.02
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.8343865, g: 0.8584906, b: 0.75725347, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _WindSpeed: {r: 100, g: 100, b: 1, a: 1}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7703a0bcaa149214693ccf4e5154e464
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,110 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: GrassShader
|
||||
m_Shader: {fileID: 4800000, guid: 83a3afa28b3f4da48981ac72df1bc398, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 527cea5a6b017984894d91563b2bdefb, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _AlphaCutoff: 0.297
|
||||
- _BendRotationRandom: 0
|
||||
- _BladeHeight: 1.87
|
||||
- _BladeHeightRandom: 0.2
|
||||
- _BladeWidth: 0.6
|
||||
- _BladeWidthRandom: 0.2
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailBumpScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 1
|
||||
- _LocalTime: 0
|
||||
- _Metallic: 0.917
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _ParallaxStrength: 0
|
||||
- _Smoothness: 0.1
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _TessellationEdgeLength: 32.5
|
||||
- _TessellationUniform: 17.7
|
||||
- _Test: 6.63
|
||||
- _UVSec: 0
|
||||
- _WindQuality: 0
|
||||
- _WireframeSmoothing: 1
|
||||
- _WireframeThickness: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BottomCol: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _Color: {r: 0.8808059, g: 1, b: 0.514151, a: 1}
|
||||
- _Emission: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _HueVariation: {r: 1, g: 0.5, b: 0, a: 0.1}
|
||||
- _TopCol: {r: 0, g: 0.990566, b: 0.1815736, a: 1}
|
||||
- _WireframeColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ab8ff7b784eb34449b2a9c40a0df1d3
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,79 @@
|
||||
// Standard geometry shader example
|
||||
// https://github.com/keijiro/StandardGeometryShader
|
||||
|
||||
Shader "DBV/Kristo/GrassShader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color("Color", Color) = (1, 1, 1, 1)
|
||||
_MainTex("Albedo", 2D) = "white" {}
|
||||
|
||||
[Space]
|
||||
_Glossiness("Smoothness", Range(0, 1)) = 0.5
|
||||
[Gamma] _Metallic("Metallic", Range(0, 1)) = 0
|
||||
|
||||
[Space]
|
||||
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||
_BumpScale("Scale", Float) = 1
|
||||
|
||||
[Space]
|
||||
_OcclusionMap("Occlusion Map", 2D) = "white" {}
|
||||
_OcclusionStrength("Strength", Range(0, 1)) = 1
|
||||
|
||||
[Space]
|
||||
_LocalTime("Animation Time", Float) = 0.0
|
||||
|
||||
[Space]
|
||||
_BendRotationRandom("Bend Rotation Random", Range(0, 1)) = 0.2
|
||||
|
||||
[Space]
|
||||
_BladeWidth("Blade Width", Float) = 0.05
|
||||
_BladeWidthRandom("Blade Width Random", Float) = 0.02
|
||||
_BladeHeight("Blade Height", Float) = 0.5
|
||||
_BladeHeightRandom("Blade Height Random", Float) = 0.3
|
||||
|
||||
[Space]
|
||||
_AlphaCutoff ("Alpha cutoff", Range(0,1)) = 0.05
|
||||
_Test ("_Test", Range(0,10)) = 1
|
||||
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
|
||||
// This shader only implements the deferred rendering pass (GBuffer
|
||||
// construction) and the shadow caster pass, so that it doesn't
|
||||
// support forward rendering.
|
||||
|
||||
|
||||
|
||||
Pass
|
||||
{
|
||||
Tags { "LightMode"="Deferred" }
|
||||
Cull Off
|
||||
CGPROGRAM
|
||||
#pragma target 5.0
|
||||
#pragma vertex Vertex
|
||||
#pragma geometry Geometry
|
||||
#pragma fragment Fragment
|
||||
#pragma multi_compile_prepassfinal noshadowmask nodynlightmap nodirlightmap nolightmap
|
||||
#include "GrassGeometry.cginc"
|
||||
ENDCG
|
||||
}
|
||||
|
||||
//Pass
|
||||
//{
|
||||
// Tags { "LightMode"="ShadowCaster" }
|
||||
// Cull Off
|
||||
// CGPROGRAM
|
||||
// #pragma target 5.0
|
||||
// #pragma vertex Vertex
|
||||
// #pragma geometry Geometry
|
||||
// #pragma fragment Fragment
|
||||
// #pragma multi_compile_shadowcaster noshadowmask nodynlightmap nodirlightmap nolightmap
|
||||
// #define UNITY_PASS_SHADOWCASTER
|
||||
// #include "GrassGeometry.cginc"
|
||||
// ENDCG
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83a3afa28b3f4da48981ac72df1bc398
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,138 @@
|
||||
Shader "Unlit/GrassShaderLearn"
|
||||
{
|
||||
Properties {
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_Color ("Color", COlor) = (1,1,1,1)
|
||||
_BottomCol ("Bottom", COlor) = (1,1,1,1)
|
||||
_TopCol ("Top", COlor) = (1,1,1,1)
|
||||
_BendRotationRandom("Bend Rotation Random", Range(0, 1)) = 0.2
|
||||
|
||||
_BladeWidth("Blade Width", Float) = 0.05
|
||||
_BladeWidthRandom("Blade Width Random", Float) = 0.02
|
||||
_BladeHeight("Blade Height", Float) = 0.5
|
||||
_BladeHeightRandom("Blade Height Random", Float) = 0.3
|
||||
|
||||
_TessellationUniform("Tessellation Uniform", Range(1, 64)) = 1
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma geometry geo
|
||||
//#pragma hull hull
|
||||
//#pragma domain domain
|
||||
// make fog work
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
//#include "Shaders/CustomTessellation.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
//UNITY_FOG_COORDS(1)
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 tangent : TANGENT;
|
||||
};
|
||||
|
||||
struct geometryOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
geometryOutput VertexOutput(float3 pos, float2 uv){
|
||||
geometryOutput o;
|
||||
o.pos = UnityObjectToClipPos(pos);
|
||||
o.uv = uv;
|
||||
return o;
|
||||
}
|
||||
|
||||
float rand(float3 co){
|
||||
return frac(sin(dot(co.xyz, float3(12.9898, 78.233, 53.539))) * 43758.5453);
|
||||
}
|
||||
float3x3 AngleAxis3x3(float angle, float3 axis){
|
||||
float c, s;
|
||||
sincos(angle, s, c);
|
||||
float t = 1 - c;
|
||||
float x = axis.x;
|
||||
float y = axis.y;
|
||||
float z = axis.z;
|
||||
return float3x3(
|
||||
t * x * x + c, t * x * y - s * z, t * x * z + s * y,
|
||||
t * x * y + s * z, t * y * y + c, t * y * z - s * x,
|
||||
t * x * z - s * y, t * y * z + s * x, t * z * z + c
|
||||
);
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
fixed4 _Color, _BottomCol, _TopCol;
|
||||
float _BendRotationRandom;
|
||||
|
||||
float _BladeHeight;
|
||||
float _BladeHeightRandom;
|
||||
float _BladeWidth;
|
||||
float _BladeWidthRandom;
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = v.vertex;//UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.normal = v.normal;
|
||||
o.tangent = v.tangent;
|
||||
//UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
[maxvertexcount(3)]
|
||||
void geo(triangle v2f IN[3] : SV_POSITION, inout TriangleStream<geometryOutput> triStream) {
|
||||
float3 pos = IN[0].vertex;
|
||||
float3 vNormal = IN[0].normal;
|
||||
float4 vTangent = IN[0].tangent;
|
||||
float3 vBinormal = cross (vNormal,vTangent)*vTangent.w;
|
||||
|
||||
float height = (rand(pos.zyx) * 2 - 1) * _BladeHeightRandom + _BladeHeight;
|
||||
float width = (rand(pos.xzy) * 2 - 1) * _BladeWidthRandom + _BladeWidth;
|
||||
|
||||
float3x3 tangentToLocal = float3x3(
|
||||
vTangent.x, vBinormal.x, vNormal.x,
|
||||
vTangent.y, vBinormal.y, vNormal.y,
|
||||
vTangent.z, vBinormal.z, vNormal.z
|
||||
);
|
||||
float3x3 facingRotationMatrix = AngleAxis3x3(rand(pos) * UNITY_TWO_PI, float3(0, 0, 1));
|
||||
float3x3 bendRotationMatrix = AngleAxis3x3(rand(pos.zzx) * _BendRotationRandom * UNITY_PI * 0.5, float3(-1, 0, 0));
|
||||
float3x3 transformationMatrix = mul(mul(tangentToLocal, facingRotationMatrix),bendRotationMatrix);
|
||||
|
||||
triStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(width, 0, 0 )), float2(0 ,0) ));
|
||||
triStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(-width, 0, 0)), float2(1 ,0) ));
|
||||
triStream.Append(VertexOutput(pos + mul(transformationMatrix, float3(height, 0, 1 )), float2(0.5,1) ));
|
||||
|
||||
|
||||
}
|
||||
|
||||
fixed4 frag (geometryOutput i) : SV_Target {
|
||||
// sample the texture
|
||||
fixed4 col = tex2D(_MainTex, i.uv) * _Color;
|
||||
// apply fog
|
||||
//UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return lerp(_BottomCol, _TopCol, i.uv.y) * _Color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 115182574462e9e45a2a9fa02a849aa2
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,124 @@
|
||||
Shader "DBV/Kristo/InstancedGrassShader"
|
||||
{
|
||||
Properties {
|
||||
_MainTex("Albedo (RGB)", 2D) = "white" {}
|
||||
_Glossiness("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic("Metallic", Range(0,1)) = 0.0
|
||||
|
||||
[Space]
|
||||
_ColorA("Color A", Color) = (1,1,1,1)
|
||||
_ColorB("Color B", Color) = (1,1,1,1)
|
||||
|
||||
[Space]
|
||||
_AlphaCutoff ("Alpha cutoff", Range(0,1)) = 0.05
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Instanced" }
|
||||
LOD 200
|
||||
Cull Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma surface surf Standard vertex:vert //addshadow
|
||||
#pragma multi_compile_instancing
|
||||
#pragma instancing_options procedural:setup
|
||||
|
||||
#pragma target 4.5
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
struct Input{
|
||||
float2 uv_MainTex;
|
||||
};
|
||||
|
||||
struct GrassElement {
|
||||
float3 position;
|
||||
float rotation;
|
||||
float size;
|
||||
float colorBlend;//0-1
|
||||
};
|
||||
|
||||
//Note
|
||||
//StructuredBuffers are good when there are loads of data that needs to be read at different places by different threads
|
||||
//Constant buffers are good when there isent too much data and threads read the same data
|
||||
|
||||
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
|
||||
StructuredBuffer<GrassElement> grassBuffer;
|
||||
#endif
|
||||
|
||||
|
||||
//https://forum.unity.com/threads/rotating-mesh-in-vertex-shader.501709/
|
||||
float3x3 YRotationMatrix(float degrees) {
|
||||
float alpha = degrees * UNITY_PI / 180.0;
|
||||
float sina, cosa;
|
||||
sincos(alpha, sina, cosa);
|
||||
return float3x3(
|
||||
cosa, 0, -sina,
|
||||
0, 1, 0,
|
||||
sina, 0, cosa);
|
||||
}
|
||||
//USAGE: pos.xyz = mul(YRotationMatrix(degrees),pos.xyz);
|
||||
|
||||
void rotate2D(inout float2 v, float r) {
|
||||
float s, c;
|
||||
sincos(r, s, c);
|
||||
v = float2(v.x * c - v.y * s, v.x * s + v.y * c);
|
||||
}
|
||||
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
fixed4 _ColorA, _ColorB;
|
||||
float _AlphaCutoff;
|
||||
|
||||
void setup () {
|
||||
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
|
||||
GrassElement data = grassBuffer[unity_InstanceID];
|
||||
//Scale the mesh
|
||||
unity_ObjectToWorld._11_21_31_41 = float4(data.size, 0, 0, 0);
|
||||
unity_ObjectToWorld._12_22_32_42 = float4(0, data.size, 0, 0);
|
||||
unity_ObjectToWorld._13_23_33_43 = float4(0, 0, data.size, 0);
|
||||
//position the mesh
|
||||
unity_ObjectToWorld._14_24_34_44 = float4(data.position.xyz, 1);
|
||||
|
||||
//No idea what this does
|
||||
unity_WorldToObject = unity_ObjectToWorld;
|
||||
unity_WorldToObject._14_24_34 *= -1;
|
||||
unity_WorldToObject._11_22_33 = 1.0f / unity_WorldToObject._11_22_33;
|
||||
#endif
|
||||
}
|
||||
|
||||
void vert (inout appdata_full v) {
|
||||
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
|
||||
GrassElement data = grassBuffer[unity_InstanceID];
|
||||
//Rotate
|
||||
v.vertex.xyz = mul(YRotationMatrix(data.rotation),v.vertex);
|
||||
#endif
|
||||
}
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o) {
|
||||
|
||||
//Clip the grass
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
|
||||
clip(c.a - _AlphaCutoff);
|
||||
|
||||
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
|
||||
GrassElement data = grassBuffer[unity_InstanceID];
|
||||
|
||||
float blend = data.colorBlend;
|
||||
fixed4 col = blend * _ColorA + (1-blend) * _ColorB;
|
||||
#else
|
||||
fixed4 col = _ColorA;
|
||||
#endif
|
||||
|
||||
// Albedo comes from a texture tinted by color
|
||||
c = c * col;
|
||||
o.Albedo = c.rgb;
|
||||
// Metallic and smoothness come from slider variables
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1743210f01f7ba843bb566086818c652
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
Shader "Unlit/NewUnlitShader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
// make fog work
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
// sample the texture
|
||||
fixed4 col = tex2D(_MainTex, i.uv);
|
||||
// apply fog
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd51a02f82d912148a47f1383511f846
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,81 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: NormalMat
|
||||
m_Shader: {fileID: 4800000, guid: d81e5fd7a7a2c874d821bd6d5adfc5cd, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.225
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _FadeDistance: 10
|
||||
- _FadeSmooth: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BackFaceColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _FadeColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9363e008b0ee6e2458f8fcacdad04a8b
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,60 @@
|
||||
// Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
|
||||
|
||||
// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
|
||||
|
||||
Shader "Unlit/NormalShader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Cutoff ("Threshold", Range(0,1)) = 0.5
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "RenderType"="Opaque" }
|
||||
LOD 100
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
// make fog work
|
||||
#pragma multi_compile_fog
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float3 normalWorld : TEXCOORD1;
|
||||
UNITY_FOG_COORDS(1)
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
float _Cutoff;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.normalWorld = normalize( mul( float4( v.normal, 0.0 ), unity_WorldToObject ).xyz );
|
||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
clip( dot(i.normalWorld, float3(0,1,0)) - _Cutoff );
|
||||
// apply fog bc why not
|
||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
||||
return half4(0,1,0,1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d81e5fd7a7a2c874d821bd6d5adfc5cd
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,175 @@
|
||||
Shader "Hidden/OcclusionReplacementShader"
|
||||
{
|
||||
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="Opaque"
|
||||
}
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
};
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target {
|
||||
return half4(0,0,0,1);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="CullHighlightOne"
|
||||
}
|
||||
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
|
||||
uniform sampler2D _CameraDepthTexture;
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
|
||||
};
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 screenPos : TEXCOORD1;
|
||||
float2 depth : TEXCOORD2;
|
||||
float dist : TEXCOORD3;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
|
||||
o.vertex = mul(UNITY_MATRIX_MV, v.vertex);
|
||||
//o.depth = o.vertex.z;
|
||||
o.vertex = mul(UNITY_MATRIX_P, o.vertex);
|
||||
|
||||
//UNITY_TRANSFER_DEPTH(o.depth);
|
||||
|
||||
//o.screenPos = ComputeScreenPos(o.vertex);
|
||||
|
||||
o.dist = distance(_WorldSpaceCameraPos, mul(unity_ObjectToWorld, v.vertex) );
|
||||
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (v2f i) : COLOR {
|
||||
//float depth = saturate(-0.005f * i.depth);//(i.depth) / _ProjectionParams.z;
|
||||
float depth = i.dist/_ProjectionParams.z;//SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.screenPos)).r;
|
||||
//depth = Linear01Depth(depth);
|
||||
//depth = Linear01Depth(depth)* _ProjectionParams.z;
|
||||
return half4(1-depth,0,depth,1-depth);
|
||||
//UNITY_OUTPUT_DEPTH(i.depth);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
/*
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="CullHighlightTwo"
|
||||
}
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _CameraDepthTexture;
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target {
|
||||
float depth = tex2D(_CameraDepthTexture,i.uv).r;
|
||||
depth = Linear01Depth(depth)* _ProjectionParams.z;
|
||||
return half4(0,1,0,depth);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
SubShader {
|
||||
Tags {
|
||||
"RenderType"="CullHighlightThree"
|
||||
}
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _CameraDepthTexture;
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert (appdata v) {
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target {
|
||||
float depth = tex2D(_CameraDepthTexture,i.uv).r;
|
||||
depth = Linear01Depth(depth)* _ProjectionParams.z;
|
||||
return half4(0,0,1,depth);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0de689ec91fac7540954eb71df6af20b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
Shader "DBV/Kristo/OcclusionStandardShader"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
||||
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
||||
_Metallic ("Metallic", Range(0,1)) = 0.0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags {
|
||||
"RenderType"="CullHighlightOne"
|
||||
}
|
||||
LOD 200
|
||||
|
||||
CGPROGRAM
|
||||
// Physically based Standard lighting model, and enable shadows on all light types
|
||||
#pragma surface surf Standard fullforwardshadows
|
||||
|
||||
// Use shader model 3.0 target, to get nicer looking lighting
|
||||
#pragma target 3.0
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
struct Input
|
||||
{
|
||||
float2 uv_MainTex;
|
||||
};
|
||||
|
||||
half _Glossiness;
|
||||
half _Metallic;
|
||||
fixed4 _Color;
|
||||
|
||||
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
|
||||
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
|
||||
// #pragma instancing_options assumeuniformscaling
|
||||
UNITY_INSTANCING_BUFFER_START(Props)
|
||||
// put more per-instance properties here
|
||||
UNITY_INSTANCING_BUFFER_END(Props)
|
||||
|
||||
void surf (Input IN, inout SurfaceOutputStandard o)
|
||||
{
|
||||
// Albedo comes from a texture tinted by color
|
||||
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
|
||||
o.Albedo = c.rgb;
|
||||
// Metallic and smoothness come from slider variables
|
||||
o.Metallic = _Metallic;
|
||||
o.Smoothness = _Glossiness;
|
||||
o.Alpha = c.a;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a1b07d3a30e63845b1f8510cafda92b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,81 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &7082488895860155134
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6057719699220877549}
|
||||
- component: {fileID: 2975279872206531291}
|
||||
- component: {fileID: 8824478207646799394}
|
||||
m_Layer: 0
|
||||
m_Name: SingleGrass
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 22
|
||||
m_IsActive: 1
|
||||
--- !u!4 &6057719699220877549
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7082488895860155134}
|
||||
m_LocalRotation: {x: -0.7071068, y: 0, z: -0, w: 0.7071067}
|
||||
m_LocalPosition: {x: 71.13544, y: 34.075233, z: 26.2224}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!33 &2975279872206531291
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7082488895860155134}
|
||||
m_Mesh: {fileID: -5495902117074765545, guid: 37a17204eeb420948a913b69143253af, type: 3}
|
||||
--- !u!23 &8824478207646799394
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7082488895860155134}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 7703a0bcaa149214693ccf4e5154e464, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dba6d7333783064f957dab4a9660a05
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Scripts/DeltaHoone/Weather_System/Grass/Old/grass.blend1
Normal file
BIN
Assets/Scripts/DeltaHoone/Weather_System/Grass/Old/grass.blend1
Normal file
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a23a82050951cf40a7e12d22566dc1a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user