public override void SetShaderParams() { MainShader.SetInt("L_WIDTH", (int)LifeDimentions.x); MainShader.SetInt("L_HEIGHT", (int)LifeDimentions.y); MainShader.SetVector("displacement", displacement); }
private IEnumerator doLife() { while (true) { if (!lifeIsActive) { yield return(new WaitForEndOfFrame()); } else { Graphics.Blit(Life, Intermediary); SetShaderParams(); MainShader.SetTexture(KERNEL_ID_LifeCycle, "Life", Life); MainShader.SetTexture(KERNEL_ID_LifeCycle, "Intermediary", Intermediary); int threadGroupsX = Mathf.CeilToInt(LifeDimentions.x / ThreadBlockSize.x); int threadGroupsY = Mathf.CeilToInt(LifeDimentions.y / ThreadBlockSize.y); MainShader.Dispatch(KERNEL_ID_LifeCycle, threadGroupsX, threadGroupsY, 1); yield return(new WaitForSeconds(0.05f)); // yield return new WaitForEndOfFrame(); } } }
private void Awake() { KERNEL_ID_Render = MainShader.FindKernel("Render"); KERNEL_ID_Init = MainShader.FindKernel("Init"); KERNEL_ID_Update = MainShader.FindKernel("Update"); SLIME_BLOCK_COUNT = Mathf.CeilToInt(count / InitBlockLength); }
private void Awake() { KERNEL_ID_Init = MainShader.FindKernel("Init"); KERNEL_ID_Render = MainShader.FindKernel("Render"); KERNEL_ID_LifeCycle = MainShader.FindKernel("LifeCycle"); StartCoroutine(doLife()); }
private void InitComputeBuffer() { mainBuffer = new ComputeBuffer(count, stride); SetShaderParams(); MainShader.SetBuffer(KERNEL_ID_Init, "Boids", mainBuffer); MainShader.Dispatch(KERNEL_ID_Init, BOID_CYCLE_BLOCK_COUNT, 1, 1); }
private void Awake() { KERNEL_ID_Render = MainShader.FindKernel("Render"); KERNEL_ID_Init = MainShader.FindKernel("Init"); KERNEL_ID_Update = MainShader.FindKernel("Update"); BOID_CYCLE_BLOCK_COUNT = Mathf.CeilToInt(count / InitBlockLength); InitComputeBuffer(); }
public override void Render(RenderTexture destination) { int threadGroupsX = Mathf.CeilToInt(WIDTH / ThreadBlockSize.x); int threadGroupsY = Mathf.CeilToInt(HEIGHT / ThreadBlockSize.y); MainShader.SetTexture(KERNEL_ID_Render, "Result", Result); MainShader.Dispatch(KERNEL_ID_Render, threadGroupsX, threadGroupsY, 1); Graphics.Blit(Result, destination); }
public override void InitRenderTexture() { if (createTexture(ref Life, (int)LifeDimentions.x, (int)LifeDimentions.y)) { MainShader.SetTexture(KERNEL_ID_Init, "Life", Life); int threadGroupsX = Mathf.CeilToInt(LifeDimentions.x / ThreadBlockSize.x); int threadGroupsY = Mathf.CeilToInt(LifeDimentions.y / ThreadBlockSize.y); MainShader.Dispatch(KERNEL_ID_Init, threadGroupsX, threadGroupsY, 1); } createTexture(ref Intermediary, (int)LifeDimentions.x, (int)LifeDimentions.y); createTexture(ref Result, (int)(WIDTH * zoomFactor), (int)(HEIGHT * zoomFactor)); }
public override void SetShaderParams() { MainShader.SetMatrix("_CameraToWorld", _Camara.cameraToWorldMatrix); MainShader.SetMatrix("_CameraInverseProjection", _Camara.projectionMatrix.inverse); MainShader.SetTexture(KERNEL_ID_Render, "_SkyboxTexture", SkyboxTexture); MainShader.SetVector("_PixelOffset", new Vector2(Random.value, Random.value)); var light = DirectionalLight.transform.forward; MainShader.SetVector("_DirectionalLight", new Vector4(light.x, light.y, light.z, DirectionalLight.intensity)); }
public override void Render(RenderTexture destination) { MainShader.SetBuffer(KERNEL_ID_Update, "Boids", mainBuffer); MainShader.SetTexture(KERNEL_ID_Update, "Result", Result); MainShader.SetTexture(KERNEL_ID_Render, "Result", Result); int threadGroupsX = Mathf.CeilToInt(WIDTH / ThreadBlockSize.x); int threadGroupsY = Mathf.CeilToInt(HEIGHT / ThreadBlockSize.y); MainShader.Dispatch(KERNEL_ID_Render, threadGroupsX, threadGroupsY, 1); MainShader.Dispatch(KERNEL_ID_Update, BOID_CYCLE_BLOCK_COUNT, 1, 1); Graphics.Blit(Result, destination); }
public override void SetShaderParams() { var useTime = Time.time / 20; // var useTime = Mathf.Sin(Time.time * Mathf.PI / 15); var points = new Vector4[120]; for (int i = 0; i < points.Length; i++) { points[i] = new Vector4( Mathf.PerlinNoise(10000 + i * Mathf.PI * 50, useTime) * WIDTH, Mathf.PerlinNoise(10600 + i * Mathf.PI * 50, useTime) * HEIGHT, Mathf.PerlinNoise(10000 + (i + 1) * Mathf.PI * 50, useTime) * WIDTH, Mathf.PerlinNoise(10600 + (i + 1) * Mathf.PI * 50, useTime) * HEIGHT); } MainShader.SetVectorArray("points", points); }
public override void Render(RenderTexture destination) { MainShader.SetTexture(KERNEL_ID_Render, "Result", Result); int threadGroupsX = Mathf.CeilToInt(WIDTH / 8.0f); int threadGroupsY = Mathf.CeilToInt(HEIGHT / 8.0f); MainShader.Dispatch(KERNEL_ID_Render, threadGroupsX, threadGroupsY, 1); if (_addMaterial == null) { _addMaterial = new Material(Shader.Find("Hidden/AddShader")); } _addMaterial.SetFloat("_Sample", _currentSample); Graphics.Blit(Result, destination, _addMaterial); _currentSample++; }
public override void SetShaderParams() { MainShader.SetInt("count", count); }
private void Awake() { _Camara = GetComponent <Camera>(); KERNEL_ID_Render = MainShader.FindKernel("Render"); }
public override void SetShaderParams() { MainShader.SetInt("count", count); MainShader.SetFloat("speed", 10); }
private void Awake() { KERNEL_ID_Render = MainShader.FindKernel("Render"); }