public void InitializeBuffers(decorationStruct[] decorationsArray) { decorations = decorationsArray; // ??? outputBuffer = new ComputeBuffer(decorations.Length, 48); outputBuffer.SetData(decorations); procMaterial.SetBuffer("buf_decorations", outputBuffer); procMaterial.SetColor("_Color", color); procMaterial.SetTexture("_Sprite", sprite); procMaterial.SetVector("_Size", size); procMaterial.SetVector("_SizeRandom", sizeRandom); procMaterial.SetFloat("_BodyColorAmount", bodyColorAmount); //procMaterial.SetFloat("_OrientAttitude", orientAttitude); procMaterial.SetFloat("_OrientForwardTangent", orientForwardTangent); procMaterial.SetFloat("_OrientRandom", orientRandom); procMaterial.SetInt("_Type", type); procMaterial.SetInt("_NumRibbonSegments", numRibbonSegments); procMaterial.SetInt("_StaticCylinderSpherical", billboardType); ribbonPointBuffer = new ComputeBuffer(decorations.Length * (numRibbonSegments), 12); // Create ribbon buffer int kernelID = skinningComputeShader.FindKernel("CSMain"); skinningComputeShader.SetBuffer(kernelID, "buf_DecorationData", outputBuffer); procMaterial.SetBuffer("buf_ribbonPoints", ribbonPointBuffer); // set display shader ribbonPointsBuffer to same ComputeBuffer so it can update it at runtime procMaterial.SetInt("_InitRibbonPoints", 1); indexBuffer = new ComputeBuffer(outputBuffer.count, sizeof(int)); debugBuffer = new ComputeBuffer(outputBuffer.count, sizeof(int)); skinningBuffer = new ComputeBuffer(outputBuffer.count, sizeof(float) * 2 + sizeof(int) * 2); bindPosesArray = new bindPoseStruct[critter.critterSegmentList.Count]; bindPoseBuffer = new ComputeBuffer(critter.critterSegmentList.Count, sizeof(float) * 16); segmentBuffer = new ComputeBuffer(critter.critterSegmentList.Count, sizeof(float) * 26); critterSegmentXforms = new SegmentXform[critter.critterSegmentList.Count]; // grab numSegments from Critter InitBindPose(); }
public void TurnOn(decorationStruct[] decorationsArray) { InitializeBuffers(decorationsArray); isOn = true; }