|
@@ -7,12 +7,8 @@ namespace GameLogic.Combat.Hero.HeroGPU
|
|
|
{
|
|
|
protected Map<string, BetterList<HeroGPUMono>> gpuRenderMap = new Map<string, BetterList<HeroGPUMono>>();
|
|
|
|
|
|
- readonly int enableShaderId = Shader.PropertyToID("_EnableAnimation");
|
|
|
- readonly int animtionStateId = Shader.PropertyToID("_AnimationState");
|
|
|
- readonly int edgeColor = Shader.PropertyToID("_edgeColor");
|
|
|
- readonly int edgeStrength = Shader.PropertyToID("_edgeStrength");
|
|
|
- readonly int injuriedStrength = Shader.PropertyToID("_injuriedStrength");
|
|
|
-
|
|
|
+ protected Map<string, GPURender> gpuRender = new Map<string, GPURender>();
|
|
|
+ // MaterialPropertyBlock _materialPropertyBlock = new MaterialPropertyBlock();
|
|
|
public HeroGPURenderManager()
|
|
|
{
|
|
|
StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
|
|
@@ -50,34 +46,40 @@ namespace GameLogic.Combat.Hero.HeroGPU
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- MaterialPropertyBlock _materialPropertyBlock = new MaterialPropertyBlock();
|
|
|
- RenderParams rp = new RenderParams(gpuRenderMap.Value[0].Material);
|
|
|
- rp.matProps = _materialPropertyBlock;
|
|
|
- rp.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
|
|
|
- rp.receiveShadows = false;
|
|
|
- Matrix4x4[] instData = new Matrix4x4[count];
|
|
|
- Matrix4x4[] animtionStata = new Matrix4x4[count];
|
|
|
- float[] enableAnimations = new float[count];
|
|
|
- Vector4[] edgeColor = new Vector4[count];
|
|
|
- float[] edgeStrength = new float[count];
|
|
|
- float[] injuriedStrength = new float[count];
|
|
|
- for (int i = 0; i < count; i++)
|
|
|
+ if (!gpuRender.TryGetValue(gpuRenderMap.Key, out GPURender render))
|
|
|
{
|
|
|
- HeroGPUMono heroGPUMono = gpuRenderMap.Value[i];
|
|
|
- instData[i] = heroGPUMono.rootTrans.localToWorldMatrix;
|
|
|
- animtionStata[i] = heroGPUMono.animtionState;
|
|
|
- edgeColor[i] = heroGPUMono.edgecolor;
|
|
|
- edgeStrength[i] = heroGPUMono.edgeStength;
|
|
|
- injuriedStrength[i] = heroGPUMono.injuriedStrength;
|
|
|
- enableAnimations[i] = 1;
|
|
|
+ render = new GPURender();
|
|
|
+ render.Init(gpuRenderMap.Value[0].Material,gpuRenderMap.Value[0].Mesh);
|
|
|
+ gpuRender.Add(gpuRenderMap.Key, render);
|
|
|
}
|
|
|
-
|
|
|
- _materialPropertyBlock.SetFloatArray(enableShaderId, enableAnimations);
|
|
|
- _materialPropertyBlock.SetMatrixArray(animtionStateId, animtionStata);
|
|
|
- _materialPropertyBlock.SetVectorArray(this.edgeColor, edgeColor);
|
|
|
- _materialPropertyBlock.SetFloatArray(this.edgeStrength, edgeStrength);
|
|
|
- _materialPropertyBlock.SetFloatArray(this.injuriedStrength, injuriedStrength);
|
|
|
- Graphics.RenderMeshInstanced(rp, gpuRenderMap.Value[0].Mesh, 0, instData);
|
|
|
+ render.Render(gpuRenderMap.Value);
|
|
|
+ // RenderParams rp = new RenderParams(gpuRenderMap.Value[0].Material);
|
|
|
+ // rp.matProps = _materialPropertyBlock;
|
|
|
+ // rp.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
|
|
|
+ // rp.receiveShadows = false;
|
|
|
+ // Matrix4x4[] instData = new Matrix4x4[count];
|
|
|
+ // Matrix4x4[] animtionStata = new Matrix4x4[count];
|
|
|
+ // float[] enableAnimations = new float[count];
|
|
|
+ // Vector4[] edgeColor = new Vector4[count];
|
|
|
+ // float[] edgeStrength = new float[count];
|
|
|
+ // float[] injuriedStrength = new float[count];
|
|
|
+ // for (int i = 0; i < count; i++)
|
|
|
+ // {
|
|
|
+ // HeroGPUMono heroGPUMono = gpuRenderMap.Value[i];
|
|
|
+ // instData[i] = heroGPUMono.rootTrans.localToWorldMatrix;
|
|
|
+ // animtionStata[i] = heroGPUMono.animtionState;
|
|
|
+ // edgeColor[i] = heroGPUMono.edgecolor;
|
|
|
+ // edgeStrength[i] = heroGPUMono.edgeStength;
|
|
|
+ // injuriedStrength[i] = heroGPUMono.injuriedStrength;
|
|
|
+ // enableAnimations[i] = 1;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // _materialPropertyBlock.SetFloatArray(enableShaderId, enableAnimations);
|
|
|
+ // _materialPropertyBlock.SetMatrixArray(animtionStateId, animtionStata);
|
|
|
+ // _materialPropertyBlock.SetVectorArray(this.edgeColor, edgeColor);
|
|
|
+ // _materialPropertyBlock.SetFloatArray(this.edgeStrength, edgeStrength);
|
|
|
+ // _materialPropertyBlock.SetFloatArray(this.injuriedStrength, injuriedStrength);
|
|
|
+ // Graphics.RenderMeshInstanced(rp, gpuRenderMap.Value[0].Mesh, 0, instData);
|
|
|
}
|
|
|
}
|
|
|
}
|