private void Validate() { if (nebula == null) { nebula = SGT_Helper.CreateGameObject("Nebula", this); } if (nebulaMesh == null) { nebulaMesh = new SGT_Mesh(); } if (nebulaMaterial == null) { nebulaMaterial = SGT_Helper.CreateMaterial("Hidden/SGT/Nebula/" + nebulaTechnique); } SGT_Helper.SetParent(nebula, gameObject); SGT_Helper.SetLayer(nebula, gameObject.layer); SGT_Helper.SetTag(nebula, gameObject.tag); var finalColour = SGT_Helper.Premultiply(particleColour); nebulaMaterial.SetColor("particleColour", finalColour); nebulaMaterial.SetTexture("particleTexture", particleTexture); nebulaMaterial.SetFloat("particleFadeInDistance", particleFadeInDistance); SGT_Helper.SetRenderQueue(nebulaMaterial, nebulaRenderQueue); nebulaMesh.GameObject = nebula; nebulaMesh.HasMeshRenderer = true; nebulaMesh.MeshRendererEnabled = SGT_Helper.IsBlack(finalColour) == false; nebulaMesh.SharedMesh = generatedMesh; nebulaMesh.SharedMaterial = nebulaMaterial; nebulaMesh.Update(); }
private void Validate() { if (dust == null) { dust = SGT_Helper.CreateGameObject("Dust", this); } if (dustMesh == null) { dustMesh = new SGT_Mesh(); } if (dustMaterial == null) { dustMaterial = SGT_Helper.CreateMaterial("Hidden/SGT/Dust/" + dustTechnique); } if (dustCamera == null) { dustCamera = SGT_Helper.FindCamera(); } SGT_Helper.SetParent(dust, gameObject); SGT_Helper.SetLayer(dust, gameObject.layer); SGT_Helper.SetTag(dust, gameObject.tag); var finalColour = SGT_Helper.Premultiply(particleColour); var oldDustCameraRotation = dustCameraRotation; if (dustCamera != null) { dustCameraRotation = dustCamera.transform.rotation; } var cameraRotationDelta = Quaternion.Inverse(oldDustCameraRotation) * dustCameraRotation; particleRoll -= cameraRotationDelta.eulerAngles.z; var roll = Quaternion.Euler(new Vector3(0.0f, 0.0f, particleRoll)); dustMaterial.SetTexture("dustTexture", particleTexture); dustMaterial.SetFloat("dustRadius", dustRadius); dustMaterial.SetColor("particleColour", finalColour); dustMaterial.SetFloat("particleFadeInDistance", dustRadius / particleFadeInDistance); dustMaterial.SetFloat("particleFadeOutDistance", dustRadius / particleFadeOutDistance); dustMaterial.SetMatrix("particleRoll", SGT_MatrixHelper.Rotation(roll)); SGT_Helper.SetRenderQueue(dustMaterial, dustRenderQueue); dustMesh.GameObject = dust; dustMesh.HasMeshRenderer = true; dustMesh.MeshRendererEnabled = SGT_Helper.IsBlack(finalColour) == false; dustMesh.SharedMesh = generatedMesh; dustMesh.SharedMaterial = dustMaterial; dustMesh.Update(); }
private void Validate() { if (nebula == null) { nebula = SGT_Helper.CreateGameObject("Nebula", this); } if (nebulaMesh == null) { nebulaMesh = new SGT_Mesh(); } if (nebulaMaterial == null) { nebulaMaterial = SGT_Helper.CreateMaterial("Hidden/SGT/Nebula/" + nebulaTechnique); } if (nebulaCamera == null) { NebulaCamera = SGT_Helper.FindCamera(); // NOTE: Assigning property } SGT_Helper.SetParent(nebula, gameObject); SGT_Helper.SetLayer(nebula, gameObject.layer); SGT_Helper.SetTag(nebula, gameObject.tag); var sideOrTop = Mathf.Abs(Vector3.Dot((SGT_Helper.GetPosition(nebulaCamera) - transform.position).normalized, transform.up)); var finalColour = SGT_Helper.Premultiply(Color.Lerp(particleSideColour, particleTopColour, sideOrTop)); var oldCameraRotation = nebulaCameraRotation; if (nebulaCamera != null) { nebulaCameraRotation = nebulaCamera.transform.rotation; } var cameraRotationDelta = Quaternion.Inverse(oldCameraRotation) * nebulaCameraRotation; nebulaCameraRoll = SGT_Helper.Wrap(nebulaCameraRoll - cameraRotationDelta.eulerAngles.z, 0.0f, 360.0f); var roll = Quaternion.Euler(new Vector3(0.0f, 0.0f, nebulaCameraRoll)); nebulaMaterial.SetColor("particleColour", finalColour); nebulaMaterial.SetTexture("particleTexture", particleTexture); nebulaMaterial.SetFloat("particleFadeInDistance", particleFadeInDistance); nebulaMaterial.SetMatrix("cameraRoll", SGT_MatrixHelper.Rotation(roll)); SGT_Helper.SetRenderQueue(nebulaMaterial, nebulaRenderQueue); nebulaMesh.GameObject = nebula; nebulaMesh.HasMeshRenderer = true; nebulaMesh.MeshRendererEnabled = SGT_Helper.IsBlack(finalColour) == false; nebulaMesh.SharedMesh = generatedMesh; nebulaMesh.SharedMaterial = nebulaMaterial; nebulaMesh.Update(); }
private void UpdateShader() { var uniformScale = UniformScale; // Update shader variables coronaMaterial.SetTexture("coronaTexture", coronaTexture); coronaMaterial.SetVector("coronaPosition", transform.position); coronaMaterial.SetColor("coronaColour", SGT_Helper.Premultiply(coronaColour)); coronaMaterial.SetFloat("coronaFalloff", coronaFalloff * coronaFalloff); if (cullNear == true) { coronaMaterial.SetFloat("cullNearOffset", cullNearOffset * uniformScale); coronaMaterial.SetFloat("invCullNearLength", SGT_Helper.Reciprocal(cullNearLength * uniformScale)); } if (meshType == Type.Ring) { coronaMaterial.SetFloat("coronaRadius", meshRadius * uniformScale); coronaMaterial.SetFloat("coronaHeight", meshHeight * uniformScale); } }
private void Validate() { if (dust == null) { dust = SGT_Helper.CreateGameObject("Dust", this); } if (dustMesh == null) { dustMesh = new SGT_Mesh(); } if (dustMaterial == null) { dustMaterial = SGT_Helper.CreateMaterial("Hidden/SGT/Dust/" + dustTechnique); } SGT_Helper.SetParent(dust, gameObject); SGT_Helper.SetLayer(dust, gameObject.layer); SGT_Helper.SetTag(dust, gameObject.tag); var finalColour = SGT_Helper.Premultiply(particleColour); dustMaterial.SetTexture("dustTexture", particleTexture); dustMaterial.SetFloat("dustRadius", dustRadius); dustMaterial.SetColor("particleColour", finalColour); dustMaterial.SetFloat("particleFadeInDistance", dustRadius / particleFadeInDistance); dustMaterial.SetFloat("particleFadeOutDistance", dustRadius / particleFadeOutDistance); SGT_Helper.SetRenderQueue(dustMaterial, dustRenderQueue); dustMesh.GameObject = dust; dustMesh.HasMeshRenderer = true; dustMesh.MeshRendererEnabled = SGT_Helper.IsBlack(finalColour) == false; dustMesh.SharedMesh = generatedMesh; dustMesh.SharedMaterial = dustMaterial; dustMesh.Update(); }