浏览代码

particle test. implement adding simple particle to scene. seems there is missing API to support particle renderer since it doesnt quite work yet

/OnTileRenderPass2
Filip Iliescu 7 年前
当前提交
f20a89f2
共有 9 个文件被更改,包括 1211 次插入0 次删除
  1. 13
      Assets/ScriptableRenderPipeline/OnTileDeferredPipeline/OnTileDeferredRenderPipeline.cs
  2. 10
      Assets/TestScenes/OnTileDeferredTest/ParticleTest.meta
  3. 1001
      Assets/TestScenes/OnTileDeferredTest/ParticleTest/AlphaBlendedPremultiply.unity
  4. 9
      Assets/TestScenes/OnTileDeferredTest/ParticleTest/AlphaBlendedPremultiply.unity.meta
  5. 81
      Assets/TestScenes/OnTileDeferredTest/ParticleTest/Particle Premultiply Blend.shader
  6. 10
      Assets/TestScenes/OnTileDeferredTest/ParticleTest/Particle Premultiply Blend.shader.meta
  7. 77
      Assets/TestScenes/OnTileDeferredTest/ParticleTest/SRP-Particles-ABPM.mat
  8. 10
      Assets/TestScenes/OnTileDeferredTest/ParticleTest/SRP-Particles-ABPM.mat.meta

13
Assets/ScriptableRenderPipeline/OnTileDeferredPipeline/OnTileDeferredRenderPipeline.cs


}
}
// particles
using (new RenderPass.SubPass (rp, new[] { s_GBufferEmission }, null))
{
// TODO: Use Particle renderer directly? Dont hardocde shader pass name? Not sure yet.
var settings = new DrawRendererSettings(cullResults, camera, new ShaderPassName("SRP_PARTICLES_ALPHA_BLEND_PREMULTIPLY"))
{
sorting = { flags = SortFlags.CommonTransparent }
};
settings.inputFilter.SetQueuesTransparent();
loop.DrawRenderers (ref settings);
}
//Final pass
using (new RenderPass.SubPass(rp, new[] { s_CameraTarget }, new[] { s_GBufferEmission }))
{

10
Assets/TestScenes/OnTileDeferredTest/ParticleTest.meta


fileFormatVersion: 2
guid: f3cad0999f3024ea99ef83a87c601477
folderAsset: yes
timeCreated: 1502761290
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
Assets/TestScenes/OnTileDeferredTest/ParticleTest/AlphaBlendedPremultiply.unity
文件差异内容过多而无法显示
查看文件

9
Assets/TestScenes/OnTileDeferredTest/ParticleTest/AlphaBlendedPremultiply.unity.meta


fileFormatVersion: 2
guid: 27f226d5dd1b6437d9ac9b9ca7ae5967
timeCreated: 1502761311
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

81
Assets/TestScenes/OnTileDeferredTest/ParticleTest/Particle Premultiply Blend.shader


Shader "MobileRenderloop/Particles/Alpha Blended Premultiply" {
Properties {
_MainTex ("Particle Texture", 2D) = "white" {}
_InvFade ("Soft Particles Factor", Range(0.01,3.0)) = 1.0
}
Category {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
Blend One OneMinusSrcAlpha
ColorMask RGB
Cull Off Lighting Off ZWrite Off
SubShader {
Pass {
NAME "SRP_PARTICLES_ALPHA_BLEND_PREMULTIPLY"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_particles
#include "UnityCG.cginc"
sampler2D _MainTex;
fixed4 _TintColor;
struct appdata_t {
float4 vertex : POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
#ifdef SOFTPARTICLES_ON
float4 projPos : TEXCOORD1;
#endif
UNITY_VERTEX_OUTPUT_STEREO
};
float4 _MainTex_ST;
v2f vert (appdata_t v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
#ifdef SOFTPARTICLES_ON
o.projPos = ComputeScreenPos (o.vertex);
COMPUTE_EYEDEPTH(o.projPos.z);
#endif
o.color = v.color;
o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
return o;
}
UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture);
float _InvFade;
fixed4 frag (v2f i) : SV_Target
{
#ifdef SOFTPARTICLES_ON
float sceneZ = LinearEyeDepth (SAMPLE_DEPTH_TEXTURE_PROJ(_CameraDepthTexture, UNITY_PROJ_COORD(i.projPos)));
float partZ = i.projPos.z;
float fade = saturate (_InvFade * (sceneZ-partZ));
i.color.a *= fade;
#endif
return i.color * tex2D(_MainTex, i.texcoord) * i.color.a;
}
ENDCG
}
}
}
}

10
Assets/TestScenes/OnTileDeferredTest/ParticleTest/Particle Premultiply Blend.shader.meta


fileFormatVersion: 2
guid: 3f935117bfd6c435db96bd574fd7753b
timeCreated: 1502762070
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:

77
Assets/TestScenes/OnTileDeferredTest/ParticleTest/SRP-Particles-ABPM.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SRP-Particles-ABPM
m_Shader: {fileID: 4800000, guid: 3f935117bfd6c435db96bd574fd7753b, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
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: 41e2109a383fc40ac81d1676de863fa2, 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}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _InvFade: 1.01
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

10
Assets/TestScenes/OnTileDeferredTest/ParticleTest/SRP-Particles-ABPM.mat.meta


fileFormatVersion: 2
guid: da0bda00273c64ee2bf49046b3b9aad0
timeCreated: 1502761491
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存