Browse Source

Added a first version of the particle explosion effect, reconstructed using Unity's particle system as close to Quake's original particles as I can right now.

readme
Nico de Poel 5 years ago
parent
commit
b25f2a54a9
  1. 15
      Assets/Scripts/Modules/GameModule.Interop.cs
  2. 5
      Assets/Scripts/Modules/GameModule.cs
  3. 17
      Assets/Scripts/VisualStyle.cs
  4. 3
      Assets/Styles/GLQuake/GLQuake.asset
  5. 8
      Assets/Styles/GLQuake/Particles.meta
  6. 143
      Assets/Styles/GLQuake/Particles/Particle.mat
  7. 8
      Assets/Styles/GLQuake/Particles/Particle.mat.meta
  8. BIN
      Assets/Styles/GLQuake/Particles/Particle.png
  9. 108
      Assets/Styles/GLQuake/Particles/Particle.png.meta
  10. 9727
      Assets/Styles/GLQuake/Particles/ParticleExplosion.prefab
  11. 7
      Assets/Styles/GLQuake/Particles/ParticleExplosion.prefab.meta
  12. 2
      engine/Quake/r_part.c
  13. 2
      engine/Quake/render.h
  14. 6
      engine/UniQuake/game_uniquake.c

15
Assets/Scripts/Modules/GameModule.Interop.cs

@ -17,6 +17,8 @@ public partial class GameModule : CallbackHandler<GameModule>
RemoveEntity = CreateCallback<GameRemoveEntityCallback>(Callback_GameRemoveEntity), RemoveEntity = CreateCallback<GameRemoveEntityCallback>(Callback_GameRemoveEntity),
UpdateEntityAnimation = CreateCallback<GameUpdateEntityAnimationCallback>(Callback_GameUpdateEntityAnimation), UpdateEntityAnimation = CreateCallback<GameUpdateEntityAnimationCallback>(Callback_GameUpdateEntityAnimation),
SetEntitySkin = CreateCallback<GameSetEntitySkinCallback>(Callback_GameSetEntitySkin), SetEntitySkin = CreateCallback<GameSetEntitySkinCallback>(Callback_GameSetEntitySkin),
ParticleExplosion = CreateCallback<ParticleExplosionCallback>(Callback_ParticleExplosion),
}; };
RegisterCallbacks(callbacks); RegisterCallbacks(callbacks);
@ -33,6 +35,8 @@ public partial class GameModule : CallbackHandler<GameModule>
public IntPtr RemoveEntity; public IntPtr RemoveEntity;
public IntPtr UpdateEntityAnimation; public IntPtr UpdateEntityAnimation;
public IntPtr SetEntitySkin; public IntPtr SetEntitySkin;
public IntPtr ParticleExplosion;
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
@ -89,4 +93,15 @@ public partial class GameModule : CallbackHandler<GameModule>
GetSelf(context).SetEntitySkin(entityNum, skinNum); GetSelf(context).SetEntitySkin(entityNum, skinNum);
Profiler.EndSample(); Profiler.EndSample();
} }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void ParticleExplosionCallback(IntPtr context, ref QVec3 origin);
[MonoPInvokeCallback(typeof(ParticleExplosionCallback))]
private static void Callback_ParticleExplosion(IntPtr context, ref QVec3 origin)
{
Profiler.BeginSample("ParticleExplosion");
GetSelf(context).ParticleExplosion(origin.ToUnityPosition());
Profiler.EndSample();
}
} }

5
Assets/Scripts/Modules/GameModule.cs

@ -67,4 +67,9 @@ public partial class GameModule
{ {
uq.GameState.GetEntity(entityNum).SetSkin(skinNum); uq.GameState.GetEntity(entityNum).SetSkin(skinNum);
} }
private void ParticleExplosion(Vector3 position)
{
uq.CurrentStyle.Particles.CreateExplosion(position, uq.GameLayer);
}
} }

17
Assets/Scripts/VisualStyle.cs

@ -155,9 +155,24 @@ public class ParticleSystems
[SerializeField] [SerializeField]
protected ParticleSystem explosion; protected ParticleSystem explosion;
public virtual void CreateExplosion(Vector3 position)
public virtual void CreateExplosion(Vector3 position, Layers layer)
{ {
if (explosion == null)
return;
var go = Object.Instantiate(explosion.gameObject); var go = Object.Instantiate(explosion.gameObject);
go.transform.position = position; go.transform.position = position;
SetLayer(go, layer);
}
protected static void SetLayer(GameObject go, Layers layer)
{
go.layer = (int)layer;
int childCount = go.transform.childCount;
for (int i = 0; i < childCount; ++i)
{
go.transform.GetChild(i).gameObject.layer = (int)layer;
}
} }
} }

3
Assets/Styles/GLQuake/GLQuake.asset

@ -23,4 +23,5 @@ MonoBehaviour:
lavaAlpha: 0.9 lavaAlpha: 0.9
teleAlpha: 1 teleAlpha: 1
particles: particles:
explosion: {fileID: 0}
explosion: {fileID: 9150008102338277659, guid: 94e2cf23692eef24d9a5145b0f705c55,
type: 3}

8
Assets/Styles/GLQuake/Particles.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 03879249cd303704eba9c93d55108ba0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

143
Assets/Styles/GLQuake/Particles/Particle.mat

@ -0,0 +1,143 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-826508141333875548
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 4
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Particle
m_Shader: {fileID: 4800000, guid: 0406db5a14f94604a8c57ccfbc9f3b46, type: 3}
m_ShaderKeywords: _COLORCOLOR_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses:
- SHADOWCASTER
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BaseMap:
m_Texture: {fileID: 2800000, guid: 36f6501e4b60c3d4bab2eb2659039dc4, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _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}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_Lightmaps:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_LightmapsInd:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- unity_ShadowMasks:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _BlendOp: 0
- _BumpScale: 1
- _CameraFadingEnabled: 0
- _CameraFarFadeDistance: 2
- _CameraNearFadeDistance: 1
- _ClearCoatMask: 0
- _ClearCoatSmoothness: 0
- _ColorMode: 4
- _Cull: 2
- _Cutoff: 0.5
- _DetailAlbedoMapScale: 1
- _DetailNormalMapScale: 1
- _DistortionBlend: 0.5
- _DistortionEnabled: 0
- _DistortionStrength: 1
- _DistortionStrengthScaled: 0.1
- _DstBlend: 10
- _EnvironmentReflections: 1
- _FlipbookBlending: 0
- _FlipbookMode: 0
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 0
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.005
- _QueueOffset: 0
- _ReceiveShadows: 1
- _Smoothness: 0.5
- _SmoothnessTextureChannel: 0
- _SoftParticlesEnabled: 0
- _SoftParticlesFarFadeDistance: 1
- _SoftParticlesNearFadeDistance: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _Surface: 1
- _WorkflowMode: 1
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _BaseColorAddSubDiff: {r: -1, g: 0, b: 0, a: 0}
- _CameraFadeParams: {r: 0, g: Infinity, b: 0, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SoftParticleFadeParams: {r: 0, g: 0, b: 0, a: 0}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

8
Assets/Styles/GLQuake/Particles/Particle.mat.meta

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4224080a2fee880419642256cbfaee41
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

BIN
Assets/Styles/GLQuake/Particles/Particle.png

After

Width: 64  |  Height: 64  |  Size: 1.8 KiB

108
Assets/Styles/GLQuake/Particles/Particle.png.meta

@ -0,0 +1,108 @@
fileFormatVersion: 2
guid: 36f6501e4b60c3d4bab2eb2659039dc4
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: 1
mipBias: 0
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: 1
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: 2048
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: 2048
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:

9727
Assets/Styles/GLQuake/Particles/ParticleExplosion.prefab
File diff suppressed because it is too large
View File

7
Assets/Styles/GLQuake/Particles/ParticleExplosion.prefab.meta

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 94e2cf23692eef24d9a5145b0f705c55
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

2
engine/Quake/r_part.c

@ -385,6 +385,8 @@ void R_ParticleExplosion (vec3_t org)
} }
} }
} }
UQ_Game_ParticleExplosion(org);
} }
/* /*

2
engine/Quake/render.h

@ -178,4 +178,6 @@ void R_SetVrect (vrect_t *pvrect, vrect_t *pvrectin, int lineadj);
typedef struct mleaf_s mleaf_t; typedef struct mleaf_s mleaf_t;
void UQ_GL_SetupView(vec3_t origin, vec3_t angles, mleaf_t *viewLeaf); void UQ_GL_SetupView(vec3_t origin, vec3_t angles, mleaf_t *viewLeaf);
void UQ_Game_ParticleExplosion(vec3_t origin);
#endif /* _QUAKE_RENDER_H */ #endif /* _QUAKE_RENDER_H */

6
engine/UniQuake/game_uniquake.c

@ -9,6 +9,7 @@ typedef struct unity_gamecalls_s
void(*RemoveEntity)(void *context, int entityNum); void(*RemoveEntity)(void *context, int entityNum);
void(*UpdateEntityAnimation)(void *context, int entityNum, int pose1, int pose2, float blend); void(*UpdateEntityAnimation)(void *context, int entityNum, int pose1, int pose2, float blend);
void(*SetEntitySkin)(void *context, int entityNum, int skinNum); void(*SetEntitySkin)(void *context, int entityNum, int skinNum);
void(*ParticleExplosion)(void *context, vec3_t origin);
} unity_gamecalls_t; } unity_gamecalls_t;
static void *unity_context; static void *unity_context;
@ -44,3 +45,8 @@ void UQ_Game_SetEntitySkin(int entityNum, int skinNum)
{ {
unity_gamecalls->SetEntitySkin(unity_context, entityNum, skinNum); unity_gamecalls->SetEntitySkin(unity_context, entityNum, skinNum);
} }
void UQ_Game_ParticleExplosion(vec3_t origin)
{
unity_gamecalls->ParticleExplosion(unity_context, origin);
}
Loading…
Cancel
Save