private void SceneRender(OpenGL gl) { ShaderVariables shaderVars = GetShaderVars(); // Get a reference to the raytracer shader. var shader = shaderRayMarch; shader.Bind(gl); shaderVars.Set(gl, shader); int rt1 = shader.GetUniformLocation(gl, "renderedTexture"); int rn1 = shader.GetUniformLocation(gl, "randomNumbers"); gl.Uniform1(rt1, 0); gl.Uniform1(rn1, 1); shader.SetUniform1(gl, "depth", _Depth ? 1 : 0); shader.SetUniform1(gl, "screenWidth", _TargetWidth); shader.SetUniform1(gl, "screenHeight", _TargetHeight); gl.ActiveTexture(OpenGL.GL_TEXTURE0); gl.BindTexture(OpenGL.GL_TEXTURE_2D, _RaytracerBuffer[_PingPong ? 0 : 1]); gl.ActiveTexture(OpenGL.GL_TEXTURE1); gl.BindTexture(OpenGL.GL_TEXTURE_2D, _RandomNumbers[0]); gl.ActiveTexture(OpenGL.GL_TEXTURE0); if (_Rendering) { gl.DrawArrays(OpenGL.GL_TRIANGLES, 0, (256 / _ProgressiveSteps) * 6); // CheckForError(gl); } shader.Unbind(gl); }
public void SetFractalDeclerations(ref ShaderVariables shaderVariables) { for (int i = 0; i < _FractalIterations.Count; i++) { _FractalIterations[i].SetDeclarations(ref shaderVariables); } }
ShaderVariables GetShaderVars() { ShaderVariables shaderVars = new ShaderVariables(); shaderVars.Add("progressiveIndex", _ProgressiveIndex); // shaderVars.Add("screenWidth", _TargetWidth); // shaderVars.Add("screenHeight", _TargetHeight); shaderVars.Add("frameNumber", _FrameNumber++); shaderVars.Add("viewMatrix", _ViewMatrix); shaderVars.Add("camPos", _Position); // shaderVars.Add("renderedTexture", 0); // shaderVars.Add("randomNumbers", 1); // shaderVars.Add("depth", _Depth ? 1 : 0); shaderVars.Add("mouseX", _MouseX); shaderVars.Add("mouseY", _TargetHeight - _MouseY); shaderVars.Add("sunDirection", _SunDirection); shaderVars.Add("focusDepth", (float)_Camera._FocusDepth); shaderVars.Add("apertureSize", (float)_Camera._ApertureSize); shaderVars.Add("fov", (float)_Camera._FOV); shaderVars.Add("spherical", (float)_Camera._Spherical); shaderVars.Add("stereographic", (float)_Camera._Stereographic); shaderVars.Add("fogStrength", (float)_FractalSettings._RenderOptions._FogStrength); shaderVars.Add("fogSamples", (float)_FractalSettings._RenderOptions._FogSamples); shaderVars.Add("fogColour", _FractalSettings._RenderOptions._FogColour); shaderVars.Add("fogType", (_FractalSettings._RenderOptions._FogType == EFogType.Vanilla) ? 0.0f : 1.0f); shaderVars.Add("distanceExtents", (float)_FractalSettings._RenderOptions._DistanceExtents); _FractalSettings.SetFractalDeclerations(ref shaderVars); _FractalSettings.SetColourDeclerations(ref shaderVars); return(shaderVars); }
public ParticleEffectPool(CommandBuffer commands) { cmd = commands; //Free particles (is this efficient?) for (int i = MAX_PARTICLES - 1; i >= 0; i--) { FreeParticles.Push(i); } //Set up vertices vbo = new VertexBuffer(typeof(ParticleVertex), MAX_PARTICLES * 4, true); //Indices ibo = new ElementBuffer(MAX_PARTICLES * 6); ushort[] indices = new ushort[MAX_PARTICLES * 6]; int iptr = 0; for (int i = 0; i < (MAX_PARTICLES * 4); i += 4) { //Triangle 1 indices[iptr++] = (ushort)i; indices[iptr++] = (ushort)(i + 1); indices[iptr++] = (ushort)(i + 2); //Triangle 2 indices[iptr++] = (ushort)(i + 1); indices[iptr++] = (ushort)(i + 3); indices[iptr++] = (ushort)(i + 2); } ibo.SetData(indices); vbo.SetElementBuffer(ibo); basicShader = ShaderCache.Get("Particle.vs", "Billboard.frag"); }
public void SetColourDeclerations(ref ShaderVariables shaderVariables) { shaderVariables.Add("divisor", _FractalColours.Count); for (int i = 0; i < _FractalColours.Count; i++) { _FractalColours[i].SetDeclarations(ref shaderVariables, i); } }
public override void SetDeclarations(ref ShaderVariables shaderVars) { Matrix3 rot = new Matrix3(); rot.MakeFromRPY(_Rotation.x, _Rotation.y, _Rotation.z); mat3 glRot = rot.GetGLMat3(); shaderVars.Add("fracScale" + _Iteration, _Scale); shaderVars.Add("fracRot" + _Iteration, glRot); shaderVars.Add("fracMinRad" + _Iteration, (float)_MinRadius); }
public string GetShader(bool burnVariables) { string program = _Program; if (burnVariables) { ShaderVariables shaderVars = GetShaderVars(); shaderVars.BurnVariables(ref program); } return(program); }
public override void SetDeclarations(ref ShaderVariables shaderVars) { Matrix3 preRot = new Matrix3(); preRot.MakeFromRPY(_PreRotation.x, _PreRotation.y, _PreRotation.z); mat3 glPreRot = preRot.GetGLMat3(); Matrix3 postRot = new Matrix3(); postRot.MakeFromRPY(_PostRotation.x, _PostRotation.y, _PostRotation.z); mat3 glPostRot = postRot.GetGLMat3(); shaderVars.Add("fracScale" + _Iteration, (float)_Scale); shaderVars.Add("fracOffset" + _Iteration, _Offset); shaderVars.Add("fracPreRot" + _Iteration, glPreRot); shaderVars.Add("fracPostRot" + _Iteration, glPostRot); }
public CubemapViewer(string title, TextureCube texture, MainWindow mw) { Title = title; EnvMapTest.Compile(); shader = EnvMapTest.Get(); tex = texture; sphere = new QuadSphere(32); viewport = new Viewport3D(mw); viewport.DefaultOffset = new Vector3(0, 0, 4); viewport.ModelScale = 0.01f; viewport.Mode = CameraModes.Arcball; viewport.Background = new Vector4(0.12f, 0.12f, 0.12f, 1f); viewport.ResetControls(); cubemapIndex = shader.Shader.GetLocation("Cubemap"); shader.Shader.SetInteger(cubemapIndex, 0); cameraPositionIndex = shader.Shader.GetLocation("CameraPosition"); }
private void UpdateShader(ShaderVariables variables) { if (emotiveRenderer != null) { emotiveRenderer.GetPropertyBlock(emotivePropertyBlock); } else if (emotiveRendererSkinned != null) { emotiveRendererSkinned.GetPropertyBlock(emotivePropertyBlock); } emotivePropertyBlock.SetFloat("_Smoothness", variables.smoothness); if (variables.emotionTexure != null) { emotivePropertyBlock.SetTexture("_EmoteTex", variables.emotionTexure); } if (variables.colorTexture != null) { emotivePropertyBlock.SetTexture("_ColorTex", variables.colorTexture); } emotivePropertyBlock.SetColor("_ColorTint", variables.tint); emotivePropertyBlock.SetFloat("_ColorXSpeed", variables.colorXSpeed); emotivePropertyBlock.SetFloat("_ColorYSpeed", variables.colorZSpeed); if (variables.displTexture != null) { emotivePropertyBlock.SetTexture("_DispTex", variables.displTexture); } emotivePropertyBlock.SetFloat("_Displacement", variables.displacement); emotivePropertyBlock.SetFloat("_DispSpeed", variables.displYSpeed); emotivePropertyBlock.SetFloat("_DispXSpeed", variables.displXSpeed); emotivePropertyBlock.SetFloat("_DispYSpeed", variables.displZSpeed); if (emotiveRenderer != null) { emotiveRenderer.SetPropertyBlock(emotivePropertyBlock); } else if (emotiveRendererSkinned != null) { emotiveRendererSkinned.SetPropertyBlock(emotivePropertyBlock); } }
public void Compile(OpenGL gl, string fragmentShader, int raysPerPixel) { _RaysPerPixel = raysPerPixel; _FramesRendered = 0; _Rays = 0; _StopWatch = new Stopwatch(); _Program = fragmentShader; const uint positionAttribute = 0; var attributeLocations = new Dictionary <uint, string> { { positionAttribute, "Position" } }; try { if (_BurnVariables) { ShaderVariables shaderVars = GetShaderVars(); shaderVars.BurnVariables(ref fragmentShader); } DateTime start = DateTime.Now; shaderRayMarch = new ShaderProgram(); shaderRayMarch.Create(gl, ManifestResourceLoader.LoadTextFile(@"Shaders\RayMarchProgressive.vert"), fragmentShader, attributeLocations); DateTime end = DateTime.Now; TimeSpan duration = end - start; Console.WriteLine(duration.ToString()); } catch (ShaderCompilationException exception) { _ShaderError = true; MessageBox.Show(exception.Message + "\r\n" + exception.CompilerOutput); } }
public override void SetDeclarations(ref ShaderVariables shaderVars) { shaderVars.Add("fracFoldRadius" + _Iteration, _FoldRadius); }
public abstract void SetDeclarations(ref ShaderVariables shaderVars);
public override void SetDeclarations(ref ShaderVariables shaderVars) { shaderVars.Add("fracScale" + _Iteration, (float)_Scale); shaderVars.Add("fracCSize" + _Iteration, _CSize); shaderVars.Add("fracJulia" + _Iteration, _Julia); }
public void UpdateVariables(ShaderVariables newVariables) { UpdateShader(newVariables); }
/// <summary> /// Initialises the Scene. /// </summary> /// <param name="gl">The OpenGL instance.</param> public void Initialise(OpenGL gl, int width, int height, mat4 viewMatrix, vec3 position, bool burnVariables) { Logger.Log("ShaderRenderer.Initialise Started"); _GL = gl; if (_Initialised) { Destroy(gl); _Initialised = true; } _ViewMatrix = viewMatrix; _Position = position; _TargetWidth = width; _TargetHeight = height; _ProgressiveSteps = 1; _ProgressiveIndex = 0; _BurnVariables = burnVariables; // We're going to specify the attribute locations for the position and normal, // so that we can force both shaders to explicitly have the same locations. const uint positionAttribute = 0; var attributeLocations = new Dictionary <uint, string> { { positionAttribute, "Position" } }; Logger.Log("ShaderRenderer.Initialise Loading shaders from manifest"); // Create the raymarch shader shaderRayMarch = new ShaderProgram(); if (_Program == null) { shaderRayMarch.Create(gl, ManifestResourceLoader.LoadTextFile(@"Shaders\RayMarchProgressive.vert"), ManifestResourceLoader.LoadTextFile(@"Shaders\RayMarch.frag"), attributeLocations); } else { if (_BurnVariables) { ShaderVariables shaderVars = GetShaderVars(); shaderVars.BurnVariables(ref _Program); } _ShaderError = false; try { shaderRayMarch.Create(gl, ManifestResourceLoader.LoadTextFile(@"Shaders\RayMarchProgressive.vert"), _Program, attributeLocations); } catch (ShaderCompilationException exception) { _ShaderError = true; MessageBox.Show(exception.Message + "\r\n" + exception.CompilerOutput); } } // Create the transfer shader string fragShader = @" #version 130 in vec2 texCoord; out vec4 FragColor; uniform float mode; // 0=ramp, 1=exposure, 2=standard uniform float toneFactor; uniform float gammaFactor; uniform float gammaContrast; uniform sampler2D renderedTexture; vec3 filmic(vec3 value) { float A=0.22; float B=0.30; float C=0.1; float D=0.2; float E=0.01; float F=0.3; return ((value*(A*value+C*B)+D*E)/(value*(A*value+B)+D*F)) - E/F; } void main() { vec4 rgb = texture(renderedTexture, vec2((texCoord.x+1)*0.5, (texCoord.y+1)*0.5)); FragColor=rgb; // FragColor.rgb /= FragColor.a; // brightness/contrast float luminance = dot(FragColor.rgb, vec3(0.2126,0.7152,0.0722)); float luminanceOut = gammaFactor * pow(luminance, gammaContrast); float multiplier = (max(0, luminance) * luminanceOut) / (luminance * luminance); FragColor.rgb *= multiplier; if (mode>2.9 && mode<3.1) { //filmic https://www.slideshare.net/ozlael/hable-john-uncharted2-hdr-lighting FragColor.rgb = filmic(FragColor.rgb)/filmic(vec3(toneFactor)); } else if (mode>1.9 && mode<2.1) { //reinhard https://imdoingitwrong.wordpress.com/2010/08/19/why-reinhard-desaturates-my-blacks-3/ float nL = luminance * (1+luminance/(toneFactor*toneFactor)) / (1+luminance); FragColor.rgb *= nL; } else if (mode>0.9 && mode<1.1) { //exposure originally Matt Fairclough FragColor.rgb = 1 - exp(-FragColor.rgb * toneFactor); } else { FragColor.rgb /= toneFactor; } } "; shaderTransfer = new ShaderProgram(); shaderTransfer.Create(gl, ManifestResourceLoader.LoadTextFile(@"Shaders\RayMarch.vert"), fragShader, attributeLocations); CheckForError(gl); fragShader = @" #version 130 in vec2 texCoord; out vec4 FragColor; void main() { FragColor=vec4(0,0,0,0); } "; shaderClean = new ShaderProgram(); shaderClean.Create(gl, ManifestResourceLoader.LoadTextFile(@"Shaders\RayMarch.vert"), fragShader, attributeLocations); CheckForError(gl); // Create the transfer shader string fragShaderIntTransfer = @" #version 130 in vec2 texCoord; out vec4 FragColor; uniform sampler2D renderedTexture; void main() { vec4 rgb = texture(renderedTexture, vec2((texCoord.x+1)*0.5, (texCoord.y+1)*0.5)); FragColor=rgb; } "; shaderIntTransfer = new ShaderProgram(); shaderIntTransfer.Create(gl, ManifestResourceLoader.LoadTextFile(@"Shaders\RayMarch.vert"), fragShaderIntTransfer, attributeLocations); CheckForError(gl); Logger.Log("ShaderRenderer.Initialise Loading random numbers"); LoadRandomNumbers(gl); Logger.Log("ShaderRenderer.Initialise Finished loading random numbers"); float[] viewport = new float[4]; gl.GetFloat(OpenGL.GL_VIEWPORT, viewport); gl.GenFramebuffersEXT(2, _FrameBuffer); CheckForError(gl); gl.GenTextures(2, _RaytracerBuffer); CheckForError(gl); for (int i = 0; i < 2; i++) { gl.BindFramebufferEXT(OpenGL.GL_FRAMEBUFFER_EXT, _FrameBuffer[i]); gl.BindTexture(OpenGL.GL_TEXTURE_2D, _RaytracerBuffer[i]); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_CLAMP_TO_EDGE); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_CLAMP_TO_EDGE); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_GENERATE_MIPMAP_SGIS, OpenGL.GL_FALSE); // automatic mipmap // gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, OpenGL.GL_RGBA, (int)viewport[2], (int)viewport[3], 0, // OpenGL.GL_RGBA, OpenGL.GL_FLOAT, null); gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, OpenGL.GL_RGBA32F, _TargetWidth, _TargetHeight, 0, OpenGL.GL_RGBA, OpenGL.GL_FLOAT, null); CheckForError(gl); gl.FramebufferTexture2DEXT(OpenGL.GL_FRAMEBUFFER_EXT, OpenGL.GL_COLOR_ATTACHMENT0_EXT, OpenGL.GL_TEXTURE_2D, _RaytracerBuffer[i], 0); gl.FramebufferRenderbufferEXT(OpenGL.GL_FRAMEBUFFER_EXT, OpenGL.GL_DEPTH_ATTACHMENT_EXT, OpenGL.GL_RENDERBUFFER_EXT, 0); } gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0); gl.GenFramebuffersEXT(2, _EffectFrameBuffer); CheckForError(gl); gl.GenTextures(2, _EffectRaytracerBuffer); CheckForError(gl); for (int i = 0; i < 2; i++) { gl.BindFramebufferEXT(OpenGL.GL_FRAMEBUFFER_EXT, _EffectFrameBuffer[i]); gl.BindTexture(OpenGL.GL_TEXTURE_2D, _EffectRaytracerBuffer[i]); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_CLAMP_TO_EDGE); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_CLAMP_TO_EDGE); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_GENERATE_MIPMAP_SGIS, OpenGL.GL_FALSE); // automatic mipmap gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, OpenGL.GL_RGBA32F, _TargetWidth, _TargetHeight, 0, OpenGL.GL_RGBA, OpenGL.GL_FLOAT, null); CheckForError(gl); gl.FramebufferTexture2DEXT(OpenGL.GL_FRAMEBUFFER_EXT, OpenGL.GL_COLOR_ATTACHMENT0_EXT, OpenGL.GL_TEXTURE_2D, _EffectRaytracerBuffer[i], 0); gl.FramebufferRenderbufferEXT(OpenGL.GL_FRAMEBUFFER_EXT, OpenGL.GL_DEPTH_ATTACHMENT_EXT, OpenGL.GL_RENDERBUFFER_EXT, 0); } gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0); // and now initialise the integer framebuffer gl.GenFramebuffersEXT(1, _IntFrameBuffer); CheckForError(gl); gl.GenTextures(1, _PostprocessBuffer); CheckForError(gl); gl.BindFramebufferEXT(OpenGL.GL_FRAMEBUFFER_EXT, _IntFrameBuffer[0]); gl.BindTexture(OpenGL.GL_TEXTURE_2D, _PostprocessBuffer[0]); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_CLAMP_TO_EDGE); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_CLAMP_TO_EDGE); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_GENERATE_MIPMAP_SGIS, OpenGL.GL_FALSE); // automatic mipmap gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, OpenGL.GL_RGBA, _TargetWidth, _TargetHeight, 0, OpenGL.GL_RGBA, OpenGL.GL_UNSIGNED_BYTE, null); CheckForError(gl); gl.FramebufferTexture2DEXT(OpenGL.GL_FRAMEBUFFER_EXT, OpenGL.GL_COLOR_ATTACHMENT0_EXT, OpenGL.GL_TEXTURE_2D, _PostprocessBuffer[0], 0); gl.FramebufferRenderbufferEXT(OpenGL.GL_FRAMEBUFFER_EXT, OpenGL.GL_DEPTH_ATTACHMENT_EXT, OpenGL.GL_RENDERBUFFER_EXT, 0); gl.BindTexture(OpenGL.GL_TEXTURE_2D, 0); _PostProcess = new PostProcess(); _PostProcess.Initialise(gl); gl.GenFramebuffersEXT(1, _DepthFrameBuffer); gl.GenTextures(1, _DepthCalcBuffer); gl.BindFramebufferEXT(OpenGL.GL_FRAMEBUFFER_EXT, _DepthFrameBuffer[0]); gl.BindTexture(OpenGL.GL_TEXTURE_2D, _DepthCalcBuffer[0]); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MAG_FILTER, OpenGL.GL_LINEAR); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_MIN_FILTER, OpenGL.GL_LINEAR_MIPMAP_LINEAR); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_S, OpenGL.GL_CLAMP_TO_EDGE); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_TEXTURE_WRAP_T, OpenGL.GL_CLAMP_TO_EDGE); gl.TexParameter(OpenGL.GL_TEXTURE_2D, OpenGL.GL_GENERATE_MIPMAP_SGIS, OpenGL.GL_TRUE); gl.TexImage2D(OpenGL.GL_TEXTURE_2D, 0, OpenGL.GL_RGBA32F, 1, 1, 0, OpenGL.GL_RGBA, OpenGL.GL_FLOAT, null); gl.FramebufferTexture2DEXT(OpenGL.GL_FRAMEBUFFER_EXT, OpenGL.GL_COLOR_ATTACHMENT0_EXT, OpenGL.GL_TEXTURE_2D, _DepthCalcBuffer[0], 0); gl.FramebufferRenderbufferEXT(OpenGL.GL_FRAMEBUFFER_EXT, OpenGL.GL_DEPTH_ATTACHMENT_EXT, OpenGL.GL_RENDERBUFFER_EXT, 0); _Initialised = true; /* * gl.GenRenderbuffersEXT(2, _RaytracerBuffer); * gl.BindRenderbufferEXT(OpenGL.GL_RENDERBUFFER_EXT, _RaytracerBuffer[0]); * gl.RenderbufferStorageEXT(OpenGL.GL_RENDERBUFFER_EXT, OpenGL.GL_RGBA32F, (int)viewport[2], (int)viewport[3]); * gl.BindRenderbufferEXT(OpenGL.GL_RENDERBUFFER_EXT, _RaytracerBuffer[1]); * gl.RenderbufferStorageEXT(OpenGL.GL_RENDERBUFFER_EXT, OpenGL.GL_RGBA32F, (int)viewport[2], (int)viewport[3]); */ // gl.GenRenderbuffersEXT(1, _RenderBuffer); //gl.BindRenderbufferEXT(OpenGL.GL_RENDERBUFFER_EXT, _RenderBuffer[0]); //gl.RenderbufferStorageEXT(OpenGL.GL_RENDERBUFFER_EXT, OpenGL.GL_RGBA, (int)viewport[2], (int)viewport[3]); Logger.Log("ShaderRenderer.Initialise Finished"); }
public void SetDeclarations(ref ShaderVariables shaderVars, int iteration) { vec3[] diffStart = new vec3[_GradientSegments.Count]; vec3[] diffEnd = new vec3[_GradientSegments.Count]; vec3[] specStart = new vec3[_GradientSegments.Count]; vec3[] specEnd = new vec3[_GradientSegments.Count]; vec3[] reflStart = new vec3[_GradientSegments.Count]; vec3[] reflEnd = new vec3[_GradientSegments.Count]; float[] roughStart = new float[_GradientSegments.Count]; float[] roughEnd = new float[_GradientSegments.Count]; float[] dlcStart = new float[_GradientSegments.Count]; float[] dlcEnd = new float[_GradientSegments.Count]; float[] segStart = new float[_GradientSegments.Count]; float[] segEnd = new float[_GradientSegments.Count]; for (int i = 0; i < _GradientSegments.Count; i++) { diffStart[i].x = (float)_GradientSegments[i]._StartColour._DiffuseColour._Red; diffStart[i].y = (float)_GradientSegments[i]._StartColour._DiffuseColour._Green; diffStart[i].z = (float)_GradientSegments[i]._StartColour._DiffuseColour._Blue; diffEnd[i].x = (float)_GradientSegments[i]._EndColour._DiffuseColour._Red; diffEnd[i].y = (float)_GradientSegments[i]._EndColour._DiffuseColour._Green; diffEnd[i].z = (float)_GradientSegments[i]._EndColour._DiffuseColour._Blue; specStart[i].x = (float)_GradientSegments[i]._StartColour._SpecularColour._Red; specStart[i].y = (float)_GradientSegments[i]._StartColour._SpecularColour._Green; specStart[i].z = (float)_GradientSegments[i]._StartColour._SpecularColour._Blue; specEnd[i].x = (float)_GradientSegments[i]._EndColour._SpecularColour._Red; specEnd[i].y = (float)_GradientSegments[i]._EndColour._SpecularColour._Green; specEnd[i].z = (float)_GradientSegments[i]._EndColour._SpecularColour._Blue; reflStart[i].x = (float)_GradientSegments[i]._StartColour._Reflectivity._Red; reflStart[i].y = (float)_GradientSegments[i]._StartColour._Reflectivity._Green; reflStart[i].z = (float)_GradientSegments[i]._StartColour._Reflectivity._Blue; reflEnd[i].x = (float)_GradientSegments[i]._EndColour._Reflectivity._Red; reflEnd[i].y = (float)_GradientSegments[i]._EndColour._Reflectivity._Green; reflEnd[i].z = (float)_GradientSegments[i]._EndColour._Reflectivity._Blue; roughStart[i] = (float)_GradientSegments[i]._StartColour._Roughness; roughEnd[i] = (float)_GradientSegments[i]._EndColour._Roughness; dlcStart[i] = (float)_GradientSegments[i]._StartColour._DiElectric; dlcEnd[i] = (float)_GradientSegments[i]._EndColour._DiElectric; segStart[i] = (float)_GradientSegments[i]._StartX; segEnd[i] = (float)_GradientSegments[i]._EndX; } shaderVars.Add("diffStart" + iteration.ToString(), diffStart); shaderVars.Add("diffEnd" + iteration.ToString(), diffEnd); shaderVars.Add("specStart" + iteration.ToString(), specStart); shaderVars.Add("specEnd" + iteration.ToString(), specEnd); shaderVars.Add("reflStart" + iteration.ToString(), reflStart); shaderVars.Add("reflEnd" + iteration.ToString(), reflEnd); shaderVars.Add("roughStart" + iteration.ToString(), roughStart); shaderVars.Add("roughEnd" + iteration.ToString(), roughEnd); shaderVars.Add("dlcStart" + iteration.ToString(), dlcStart); shaderVars.Add("dlcEnd" + iteration.ToString(), dlcEnd); shaderVars.Add("segStart" + iteration.ToString(), segStart); shaderVars.Add("segEnd" + iteration.ToString(), segEnd); shaderVars.Add("orbitType" + iteration.ToString(), GetOrbitTypeIndex()); shaderVars.Add("multiplier" + iteration.ToString(), (float)_Multiplier); shaderVars.Add("offset" + iteration.ToString(), (float)_Offset); shaderVars.Add("segments" + iteration.ToString(), _GradientSegments.Count()); }