I've found an extreme lack of documentation regarding GLSL shaders in Unity. I'm trying to debug a distortion shader which will be attached to the camera via a call to: _camera.SetReplacementShader(shaderTest, "RenderType"); where shaderTest is a public Shader set in the editor. Can anybody tell me what's wrong with this shader? I've gotten many obscure errors that I'm having difficulty making sense of. The current error I'm facing is: "Shader error in 'ShaderTest6': GLSL Error in Fragment Shader: 0(50) : error C0204: version directive must be first statement and may not be repeated at line 50" The thing is, I can move that version directive anywhere that would appear to be "first" and it still throws the error. One line before GLSLPROGRAM and it won't compile. One line after and it says it needs to be first. Code (CSharp): Shader "ShaderTest6" { // defines the name of the shader SubShader { // Unity chooses the subshader that fits the GPU best Tags { "RenderType"="Opaque"} Pass { // some shaders require multiple passes GLSLPROGRAM // here begins the part in Unity's GLSL #ifdef VERTEX // here begins the vertex shader #extension GL_ARB_gpu_shader5 : enable out INFO{ vec2 texCoords; float k1_red; float k1_green; float k1_blue; vec2 fullscr_center; vec2 left_center; vec2 right_center; } vs_out; uniform float k1_red; uniform float k1_green; uniform float k1_blue; uniform vec2 fullscr_center; uniform vec2 left_center; uniform vec2 right_center; void main() // all vertex shaders define a main() function { const vec2 texCoords[4] = vec2[4](vec2(0.0, 1.0), vec2(0.0, 0.0), vec2(1.0, 0.0), vec2(1.0, 1.0)); gl_Position = ftransform(); gl_TexCoord[0] = gl_MultiTexCoord0; vs_out.texCoords = texCoords[gl_VertexID]; vs_out.k1_red = k1_red; vs_out.k1_green = k1_green; vs_out.k1_blue = k1_blue; vs_out.fullscr_center = fullscr_center; vs_out.left_center = left_center; vs_out.right_center = right_center; } #endif // here ends the definition of the vertex shader #ifdef FRAGMENT // here begins the fragment shader #version 430 in INFO{ vec2 texCoords; float k1_red; float k1_green; float k1_blue; vec2 fullscr_center; vec2 left_center; vec2 right_center; } fs_in; out vec4 color; layout(binding = 0) uniform sampler2D s; vec2 Distort(vec2 p, float k1) { float r2 = p.x * p.x + p.y * p.y; float r = sqrt(r2); float newRadius = (1 + k1*r*r); p.x = p.x * newRadius; p.y = p.y * newRadius; return p; } void main() // all fragment shaders define a main() function { vec2 uv_red, uv_green, uv_blue; vec4 color_red, color_green, color_blue; vec2 sectorOrigin; sectorOrigin = fs_in.fullscr_center.xy; uv_red = Distort(fs_in.texCoords-sectorOrigin, fs_in.k1_red) + sectorOrigin; uv_green = Distort(fs_in.texCoords-sectorOrigin, fs_in.k1_green) + sectorOrigin; uv_blue = Distort(fs_in.texCoords-sectorOrigin, fs_in.k1_blue) + sectorOrigin; color_red = texture2D(s, uv_red); color_green = texture2D(s, uv_green); color_blue = texture2D(s, uv_blue); if( ((uv_red.x > 0) && (uv_red.x < 1) && (uv_red.y > 0) && (uv_red.y < 1))) { color = vec4(color_red.x, color_green.y, color_blue.z, 1.0); } else { color = vec4(1,0,0,1); //red } } #endif // here ends the definition of the fragment shader ENDGLSL // here ends the part in GLSL } } } Thanks.