• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Ashaira

Shader ';' : syntax error; parse error

5 posts in this topic

I'm working on adding normal map lighting to my terrain shader and for some reason i get a syntax error when it compiles but i cant find whats wrong with it. i added a total of nor more than 15 lines from the previous ver which compiled and worked fine.

this is what it looks like with the modifications for the normal map.

[code]# Vertex Shader Start
uniform mat4 u_MVP;

attribute vec3 aPosition;
varying vec3 vPosition;

attribute vec2 a_texCoord;
varying vec2 v_texCoord;
attribute vec3 a_Tangents;
varying vec3 v_Tangents;
attribute vec3 a_Bitangents;
varying vec3 v_Bitangents;
uniform mat4 matWorld;
uniform vec3 CameraPos;
varying float v_eyeDist;
uniform sampler2D texture5;
attribute vec3 a_Normals;
varying vec3 v_Normals;
varying vec3 v_viewDirection;
varying vec3 v_lightDirection;

void main()
{
vPosition = aPosition;
v_texCoord = a_texCoord;
v_Normals = normalize(vec3(matWorld * vec4(a_Normals, 0.0)));
vec4 tmp5 = texture2D(texture5,v_texCoord);
vPosition.y = vPosition.y + ((tmp5.r + tmp5.g*2.0 + tmp5.b*3.0)/10.0) * 20.0;
vec4 vWorldPos = matWorld * vec4(vPosition,1.0);
v_eyeDist = sqrt( (vWorldPos.x - CameraPos.x) * (vWorldPos.x - CameraPos.x) + (vWorldPos.y - CameraPos.y) * (vWorldPos.y - CameraPos.y) + (vWorldPos.z - CameraPos.z) * (vWorldPos.z - CameraPos.z) );

vec3 viewDirectionWorld = vWorldPos.xyz - vPosition;
vec3 lightPos = (matWorld * vec4(0.0,1000.0,1000.0,1.0).xyz;
vec3 lightDirection = lightPos - vPosition;
mat3 tangentMat = mat3(a_Tangents,a_Bitangents,a_Normals);
v_viewDirection = viewDirectionWorld * tangentMat;
v_lightDirection = lightDirection * tangentMat;
gl_Position = u_MVP * vec4(vPosition,1.0);
}
# Vertex Shader End
# Fragment Shader Start
precision highp float;
varying vec2 v_texCoord;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D texture3;
uniform sampler2D texture4;
uniform sampler2D texture6;
varying vec3 v_Normals;
varying vec3 v_viewDirection;
varying vec3 v_lightDirection;
varying float v_eyeDist;

float computeLinearFogFactor()
{
float u_fogMaxDist = 10.0;
float u_fogMinDist = 1.0;
float factor;

factor = (v_eyeDist - u_fogMinDist) /(u_fogMaxDist - u_fogMinDist );

factor = clamp(factor, 0.0, 1.0);
return factor;
}

void main()
{
vec4 u_fogColor = vec4(0.7,0.7,0.7,1.0);
float fogFactor = computeLinearFogFactor();
vec4 tmp1 = texture2D(texture1,v_texCoord*32.0);
vec4 tmp2 = texture2D(texture2,v_texCoord*32.0);
vec4 tmp3 = texture2D(texture3,v_texCoord*32.0);
vec4 tmp4 = texture2D(texture4,v_texCoord);
float factor = 1.0 / ( tmp4.x + tmp4.y + tmp4.z );
vec4 tmp = vec4( (tmp1.rgb * tmp4.x + tmp2.rgb * tmp4.y + tmp3.rgb * tmp4.z) * factor, 1.0 );
vec4 lightColor = vec4(1.0,1.0,1.0,1.0);
vec4 normal = texture2D(texture6, v_texCoord);
normal = normalize(normal * 2.0 - 1.0);
vec3 lightDirection = normalize(v_lightDirection);
vec3 viewDirection = normalize(v_viewDirection);
float nDotL = dot(normal.xyz, lightDirection);
vec3 reflection = (2.0 * normal.xyz * nDotL) - lightDirection;
float rDotV = max(0.0, dot(reflection, viewDirection));
vec4 ambient = lightColor * tmp;
vec4 diffuse = lightColor * nDotL * tmp;
vec4 specular = lightColor * pow(rDotV, 2.0);
vec4 FinalColor = diffuse + specular + ambient;
gl_FragColor = fogFactor * u_fogColor + (1.0 - fogFactor) * FinalColor;
}
# Fragment Shader End [/code]

and these are the lines that where added and are probably causing the error.

[code] vec3 viewDirectionWorld = vWorldPos.xyz - vPosition;
vec3 lightPos = (matWorld * vec4(0.0,1000.0,1000.0,1.0).xyz;
vec3 lightDirection = lightPos - vPosition;
mat3 tangentMat = mat3(a_Tangents,a_Bitangents,a_Normals);
v_viewDirection = viewDirectionWorld * tangentMat;
v_lightDirection = lightDirection * tangentMat;[/code]

[code] vec4 lightColor = vec4(1.0,1.0,1.0,1.0);
vec4 normal = texture2D(texture6, v_texCoord);
normal = normalize(normal * 2.0 - 1.0);
vec3 lightDirection = normalize(v_lightDirection);
vec3 viewDirection = normalize(v_viewDirection);
float nDotL = dot(normal.xyz, lightDirection);
vec3 reflection = (2.0 * normal.xyz * nDotL) - lightDirection;
float rDotV = max(0.0, dot(reflection, viewDirection));
vec4 ambient = lightColor * tmp;
vec4 diffuse = lightColor * nDotL * tmp;
vec4 specular = lightColor * pow(rDotV, 2.0);
vec4 FinalColor = diffuse + specular + ambient; [/code]

can anyone see where the problem might be? or at least hint me as to what exactly the error is about cause i sure as hell checked all the ;
0

Share this post


Link to post
Share on other sites
[color=#000000]vec3 lightPos [/color][color=#666600]=[/color][color=#000000] [/color][color=#666600]([/color][color=#000000]matWorld [/color][color=#666600]*[/color][color=#000000] vec4[/color][color=#666600]([/color][color=#006666]0.0[/color][color=#666600],[/color][color=#006666]1000.0[/color][color=#666600],[/color][color=#006666]1000.0[/color][color=#666600],[/color][color=#006666]1.0[/color][color=#666600]).[/color][color=#000000]xyz[/color]


[color=#000000]I'm sure you need another closed bracket there.[/color]
1

Share this post


Link to post
Share on other sites
[quote name='RobinsonUK' timestamp='1333643756' post='4928524']
[color=#000000]vec3 lightPos [/color][color=#666600]=[/color][color=#000000] [/color][color=#666600]([/color][color=#000000]matWorld [/color][color=#666600]*[/color][color=#000000] vec4[/color][color=#666600]([/color][color=#006666]0.0[/color][color=#666600],[/color][color=#006666]1000.0[/color][color=#666600],[/color][color=#006666]1000.0[/color][color=#666600],[/color][color=#006666]1.0[/color][color=#666600]).[/color][color=#000000]xyz[/color]


[color=#000000]I'm sure you need another closed bracket there.[/color]
[/quote]
"facepalm.jpg"
um im just go over to that corner and hang myself. ty for the help.
1

Share this post


Link to post
Share on other sites
Doesn't the error log mention line number in shader source where the error is?
0

Share this post


Link to post
Share on other sites
[quote name='Martins Mozeiko' timestamp='1333696244' post='4928693']
Doesn't the error log mention line number in shader source where the error is?
[/quote]

mine always says line 1 so.......
0

Share this post


Link to post
Share on other sites
Then your shader code is most likely loaded without line breaks. Verify that each line of shader code is actually separated by a line break and that they aren't lost when you load the shader.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0