public void Awake() { pos = new Vector4[16]; // No shader? :-( if (this.simulationShader == null) { Debug.LogError("No simulation shader attached to TressFXSimulation :-'("); this.enabled = false; return; } // Get master this.master = this.GetComponent <TressFX> (); if (this.master == null) { Debug.LogError("No TressFX intance attached to TressFXSimulation's gameobject :'-("); this.enabled = false; return; } if (this.master.hairData.hairPartConfig.Length > maxHairSections) { Debug.LogError("TressFX mesh has more hair sections than allowed :'-("); this.enabled = false; return; } // Get Kernel Ids this.IntegrationAndGlobalShapeConstraintsKernelId = this.simulationShader.FindKernel("IntegrationAndGlobalShapeConstraints"); this.LocalShapeConstraintsKernelId = this.simulationShader.FindKernel("LocalShapeConstraints"); this.LocalShapeConstraintsWithIterationKernelId = this.simulationShader.FindKernel("LocalShapeConstraintsWithIteration"); this.LengthConstraintsWindAndCollisionKernelId = this.simulationShader.FindKernel("LengthConstraintsWindAndCollision"); this.UpdateFollowHairVerticesKernelId = this.simulationShader.FindKernel("UpdateFollowHairVertices"); this.PrepareFollowHairBeforeTurningIntoGuideKernelId = this.simulationShader.FindKernel("PrepareFollowHairBeforeTurningIntoGuide"); // Calculate num of strand per tg this.numOfStrandsPerThreadGroup = THREAD_GROUP_SIZE / this.master.hairData.m_NumOfVerticesPerStrand; this.followHairsLastFrame = this.followHairs; // Init part config instances this.partConfigs = new HairPartConfig[this.master.hairData.hairPartConfig.Length]; System.Array.Copy(this.master.hairData.hairPartConfig, this.partConfigs, this.master.hairData.hairPartConfig.Length); }
public virtual void Start() { // Get TressFX master this.master = this.GetComponent <TressFX> (); // Set triangle indices buffer this.g_TriangleIndicesBuffer = new ComputeBuffer(this.master.hairData.m_TriangleIndices.Length, 4); this.g_TriangleIndicesBuffer.SetData(this.master.hairData.m_TriangleIndices); // Generate meshes this.triangleMeshes = this.GenerateTriangleMeshes(); this.lineMeshes = this.GenerateLineMeshes(); // Initialize shadow material this.shadowMaterial = new Material(this.shadowShader); // Create render bounds this.renderingBounds = new Bounds(this.master.hairData.m_bSphere.center, new Vector3(this.master.hairData.m_bSphere.radius, this.master.hairData.m_bSphere.radius, this.master.hairData.m_bSphere.radius)); }
public virtual void Start() { // Get TressFX master this.master = this.GetComponent<TressFX> (); // Set triangle indices buffer this.g_TriangleIndicesBuffer = new ComputeBuffer (this.master.hairData.m_TriangleIndices.Length, 4); this.g_TriangleIndicesBuffer.SetData (this.master.hairData.m_TriangleIndices); // Generate meshes this.triangleMeshes = this.GenerateTriangleMeshes (); this.lineMeshes = this.GenerateLineMeshes (); // Initialize shadow material this.shadowMaterial = new Material (this.shadowShader); // Create render bounds this.renderingBounds = new Bounds (this.master.hairData.m_bSphere.center, new Vector3(this.master.hairData.m_bSphere.radius, this.master.hairData.m_bSphere.radius, this.master.hairData.m_bSphere.radius)); }
public void Start() { // No shader? :-( if (this.simulationShader == null) { Debug.LogError("No simulation shader attached to TressFXSimulation :-'("); this.enabled = false; return; } // Get master this.master = this.GetComponent <TressFX> (); if (this.master == null) { Debug.LogError("No TressFX intance attached to TressFXSimulation's gameobject :'-("); this.enabled = false; return; } if (this.master.hairData.hairPartConfig.Length > maxHairSections) { Debug.LogError("TressFX mesh has more hair sections than allowed :'-("); this.enabled = false; return; } // Get Kernel Ids this.IntegrationAndGlobalShapeConstraintsKernelId = this.simulationShader.FindKernel("IntegrationAndGlobalShapeConstraints"); this.LocalShapeConstraintsKernelId = this.simulationShader.FindKernel("LocalShapeConstraints"); this.LocalShapeConstraintsWithIterationKernelId = this.simulationShader.FindKernel("LocalShapeConstraintsWithIteration"); this.LengthConstriantsWindAndCollisionKernelId = this.simulationShader.FindKernel("LengthConstriantsWindAndCollision"); this.UpdateFollowHairVerticesKernelId = this.simulationShader.FindKernel("UpdateFollowHairVertices"); this.PrepareFollowHairBeforeTurningIntoGuideKernelId = this.simulationShader.FindKernel("PrepareFollowHairBeforeTurningIntoGuide"); // Calculate num of strand per tg this.numOfStrandsPerThreadGroup = this.threadGroupSize / this.master.hairData.m_NumOfVerticesPerStrand; this.followHairsLastFrame = this.followHairs; }
public void Start() { // No shader? :-( if (this.simulationShader == null) { Debug.LogError ("No simulation shader attached to TressFXSimulation :-'("); this.enabled = false; return; } // Get master this.master = this.GetComponent<TressFX> (); if (this.master == null) { Debug.LogError ("No TressFX intance attached to TressFXSimulation's gameobject :'-("); this.enabled = false; return; } if (this.master.hairData.hairPartConfig.Length > maxHairSections) { Debug.LogError ("TressFX mesh has more hair sections than allowed :'-("); this.enabled = false; return; } // Get Kernel Ids this.IntegrationAndGlobalShapeConstraintsKernelId = this.simulationShader.FindKernel ("IntegrationAndGlobalShapeConstraints"); this.LocalShapeConstraintsKernelId = this.simulationShader.FindKernel ("LocalShapeConstraints"); this.LocalShapeConstraintsWithIterationKernelId = this.simulationShader.FindKernel ("LocalShapeConstraintsWithIteration"); this.LengthConstriantsWindAndCollisionKernelId = this.simulationShader.FindKernel ("LengthConstriantsWindAndCollision"); this.UpdateFollowHairVerticesKernelId = this.simulationShader.FindKernel ("UpdateFollowHairVertices"); this.PrepareFollowHairBeforeTurningIntoGuideKernelId = this.simulationShader.FindKernel ("PrepareFollowHairBeforeTurningIntoGuide"); // Calculate num of strand per tg this.numOfStrandsPerThreadGroup = this.threadGroupSize/this.master.hairData.m_NumOfVerticesPerStrand; this.followHairsLastFrame = this.followHairs; }