[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Odd error trying to initialize shaders in chrome dev



Please find attached an example. I used the blinnphong shader from the
O3D examples.

Thanks for the help.

On Thu, Jan 13, 2011 at 3:10 PM, Kenneth Russell <kbr@google.com> wrote:
> WebKit bug filed as https://bugs.webkit.org/show_bug.cgi?id=52390 .
> Will try to fix today.
>
> -Ken
>
> On Thu, Jan 13, 2011 at 12:04 PM,  <steve@sjbaker.org> wrote:
>>
>> Hell yes you need to "relax" that!  It's nuts that you can't use simple
>> ASCII characters in comments.  I can't think of another language on the
>> planet that doesn't allow it!  It would be a constant pain in the butt for
>> programmers who just want to type a comment in normal, plain English who
>> will forget once in a while and get some kind of cryptic error (EOF in
>> shader - doesn't exactly convey "You have a quote in your comment").
>>
>> Not to mention things like company lawyers who demand that I place a very
>> specific copyright/disclaimer at the top of every file - and if they
>> happened to use a quote in that text, it could take a month and a thousand
>> dollars in <s>blood-sucking</s> lawyer fees to get an alternative version
>> without the quotes approved.  If you ever need to write a shader for the
>> government...well, <s>don't</s> dont get me started on that!
>>
>> WebGL is fragile enough as it is - let's not make it unnecessarily worse.
>>
>> Anyway - I've removed the quotes from my shaders - but only under protest!
>>
>>  :-)
>>
>>  -- Steve
>>
>>> My best guess is the presence of the quote in the shader's comments.
>>> Chrome and Safari have recently begun rejecting shaders that contain
>>> characters outside the ESSL character set, even if they are in
>>> comments. There's another ongoing thread discussing this change in
>>> behavior.
>>>
>>> Perhaps we should relax this behavior. We could filter out comments
>>> before testing the shader for characters outside the legal set.
>>>
>>> -Ken
>>>
>>> On Thu, Jan 13, 2011 at 9:25 AM,  <steve@sjbaker.org> wrote:
>>>>
>>>> Quite a few people have been seeing that error in my game too.
>>>>
>>>> Looks like a Chrome snafu.
>>>>
>>>>  -- Steve
>>>>
>>>>> I just noticed a weird error looking a some (not all) demos and my app
>>>>> using the latest chrome dev channel.
>>>>>
>>>>> Example where error occurs:
>>>>>
>>>>> http://industrialarithmetic.blogspot.com/2011/01/test.html
>>>>>
>>>>> the error I get is:
>>>>> ERROR: 0:1: 'unexpected EOF' : syntax error
>>>>>
>>>>> Any changes to the way chrome reads shaders?
>>>>>
>>>>> Thanks
>>>>>
>>>>> --
>>>>> -----------------
>>>>> Nicolas Kassis
>>>>> -----------------------------------------------------------
>>>>> You are currently subscribed to public_webgl@khronos.org.
>>>>> To unsubscribe, send an email to majordomo@khronos.org with
>>>>> the following command in the body of your email:
>>>>> unsubscribe public_webgl
>>>>> -----------------------------------------------------------
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> -----------------------------------------------------------
>>>> You are currently subscribed to public_webgl@khronos.org.
>>>> To unsubscribe, send an email to majordomo@khronos.org with
>>>> the following command in the body of your email:
>>>> unsubscribe public_webgl
>>>> -----------------------------------------------------------
>>>>
>>>>
>>>
>>> -----------------------------------------------------------
>>> You are currently subscribed to public_webgl@khronos.org.
>>> To unsubscribe, send an email to majordomo@khronos.org with
>>> the following command in the body of your email:
>>> unsubscribe public_webgl
>>> -----------------------------------------------------------
>>>
>>>
>>
>>
>>
>



-- 
-----------------
Nicolas Kassis
/*
 * Copyright 2009, Google Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

uniform mat4 worldViewProjection;
uniform mat4 world;
uniform mat4 worldInverseTranspose;

attribute vec4 position;
attribute vec4 normal;
attribute vec4 color;
varying vec3 v_normal;
varying vec3 v_worldPosition;
varying vec4 v_color;

void main() {
  gl_Position = worldViewProjection * position;
  
  vec3 worldPosition = (world * position).xyz;
  v_normal = (worldInverseTranspose * normal).xyz;
  v_worldPosition = worldPosition;
  v_color = color;
}

// #o3d SplitMarker

uniform mat4 viewInverse;
uniform vec3 lightWorldPos;
uniform vec4 ambientIntensity;
uniform vec4 lightIntensity;
uniform vec4 emissive;
uniform vec4 ambient;
uniform vec4 colorMult;
uniform vec4 specular;
uniform float shininess;

varying vec3 v_normal;
varying vec3 v_worldPosition;
varying vec4 v_color;


vec4 lit(float l ,float h, float m) {
  return vec4(1.0,
              max(l, 0.0),
              (l > 0.0) ? pow(max(0.0, h), m) : 0.0,
              1.0);
}

void main() {
  vec3 surfaceToLight = normalize(lightWorldPos - v_worldPosition);
  vec3 worldNormal = normalize(v_normal);
  vec3 surfaceToView = normalize(viewInverse[3].xyz - v_worldPosition);
  vec3 halfVector = normalize(surfaceToLight + surfaceToView);
  vec4 litResult = lit(dot(worldNormal, surfaceToLight),
                         dot(worldNormal, halfVector), shininess);

  vec4 outColor = ambientIntensity * ambient * colorMult;
  outColor += lightIntensity * (v_color * colorMult * litResult.y +
      specular * litResult.z);
  outColor += emissive;
  gl_FragColor = vec4(outColor.rgb, v_color.a * colorMult.a);
}