void CreateScene() { // Pass the shapes to the raymarching shader as a buffer ComputeBuffer shapeBuffer = new ComputeBuffer(raymarchingShapeData.Length, RaymarchingShapeData.GetSize()); shapeBuffer.SetData(raymarchingShapeData); raymarching.SetBuffer(0, "shapes", shapeBuffer); raymarching.SetInt("numRaymarchingShapes", raymarchingShapeData.Length); buffersToDispose.Add(shapeBuffer); }
RaymarchingShapeData[] GetRaymarchingShapeData() { // Extract the data from the raymarching shapes RaymarchingShapeData[] data = new RaymarchingShapeData[raymarchingShapes.Count]; for (int i = 0; i < raymarchingShapes.Count; i++) { var s = raymarchingShapes[i]; Vector3 col = new Vector3(s.colour.r, s.colour.g, s.colour.b); data[i] = new RaymarchingShapeData() { position = s.Position, scale = s.Scale, colour = col, shapeType = (int)s.shapeType, operation = (int)s.operation, blendStrength = s.blendStrength * 3, numChildren = s.numChildren }; } return(data); }