You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.8 KiB

Shader "UltraCombos/ParticleWorks/ParticleViewer/Instanced"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo (RGB)", 2D) = "white" {}
_Metallic("Metallic", Range(0, 1)) = 0.0
_Smoothness("Smoothness", Range(0, 1)) = 0.5
_Emission("Emission", Range(0, 5)) = 0.0
}
SubShader
{
Tags{ "RenderType" = "Opaque" }
LOD 200
Cull Off
CGPROGRAM
#pragma surface surf Standard fullforwardshadows vertex:vert addshadow
#pragma multi_compile_instancing
#pragma instancing_options assumeuniformscaling procedural:setup
#pragma target 4.5
sampler2D _MainTex;
fixed4 _Color;
half _Smoothness;
half _Metallic;
half _Emission;
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
#include "Inc/Defines.cginc"
StructuredBuffer<Particle> ssbo;
#endif
struct Input {
float3 color;
float2 texcoord;
};
float4x4 model_matrix;
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
void setup()
{
Particle p = ssbo[unity_InstanceID];
unity_ObjectToWorld = mul(model_matrix, p.model_matrix);
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, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
#ifdef UNITY_PROCEDURAL_INSTANCING_ENABLED
Particle p = ssbo[unity_InstanceID];
o.color = p.color;
o.texcoord = v.texcoord;
#endif
}
void surf(Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.texcoord) * _Color * float4(IN.color, 1);
o.Albedo = c.rgb;
o.Metallic = _Metallic;
o.Smoothness = _Smoothness;
o.Alpha = c.a;
//float lumin = pow(Luminance(IN.color), 2.2f);
o.Emission = c.rgb * _Emission;// *lumin;
}
ENDCG
}
FallBack "Diffuse"
}