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

Re: [Public WebGL] ESSL 3.5 Comments Compliance



I agree with you. With a little preprocessing at the browser layer
before handing down a const char* to the OpenGL layer (be it the ANGLE
shader translator or OpenGL directly), a WebGL implementation should
be able to allow the entire Unicode character range to be used in
comments by stripping them completely. I don't think we need to
reference UTF-8, since DOMStrings come in in (not necessarily valid)
UTF-16. See http://dev.w3.org/2006/webapi/WebIDL/#idl-DOMString .

Can you either propose some spec text or just edit the spec directly?

-Ken

On Thu, Jan 13, 2011 at 4:49 PM, Gregg Tavares (wrk) <gman@google.com> wrote:
> I really want to emphasize that it would be really insensitive to make WebGL
> only support ASCII in comments in shaders. It's called WebGL because it's on
> the WEB and the WEB is not ASCII.  I know the OpenGL spec says ASCII. I have
> a feeling though few if any drivers enforce that and like I mentioned
> before, even if they do enforce it WebGL implementations can work around it
> by stripping the comments.
> Imagine someone told you couldn't document your code in a language you
> understand.  How would you feel? Imagine if you couldn't even write a blog
> post that showed sample code with inline comments or that if you put inline
> comments in users trying to copy and paste snippets from your tutorial had
> to manually remove all the inline comments.
> Seriously, it seems morally wrong in 2011 to force programmers the world
> over to ASCII only for their shader comments.
> Here's a shader from this page
> WebGL MQO Loader
> Are we really going to tell that guy he has to learn English if he wants to
> document his code?
> I think we should diverge from the OpenGL ES spec here in the interest of
> the needs of the Web and the world at large. Checking for valid UTF8 is easy
> if we want to validate input and workarounds past that are probably not
> needed and even if they are probably very easy. The ANGLE translator already
> strips comments as far as I know so just validating UTF8 and calling the
> translator is enough to allow WebGL to be an international developer
> friendly standard.
>
> ---------------------------
> #ifdef GL_ES
> precision highp float;
> #endif
> //VertexShader
> //入力パラメータ
> attribute vec3 aVertexPosition; //入力位置
> attribute vec3 aVertexNormal; //入力法線
> attribute vec3 aVertexTangent; //入力法線
> attribute vec3 aVertexBinormal; //入力法線
> attribute vec4 aVertexColor; //入力カラー
> attribute vec2 aTextureCoord; //入力UV
> //出力パラメータ
> varying vec4 vColor; //出力カラー
> varying vec2 vTextureCoord; //出力UV
> varying vec3 vNormal; //出力法線
> varying vec3 vTangent; //出力接線
> varying vec3 vBinormal; //出力従法線
> varying vec3 vLightDir; //出力ライト
> varying vec3 vEyeDir; //出力視線
> varying vec4 vShadowMap; //出力シャドウマップ位置
> //固定パラメータ
> uniform mat4 WorldMatrix; //ワールドマトリクス
> uniform mat4 ViewMatrix; //ビューマトリクス
> uniform mat4 ProjMatrix; //プロジェクションマトリクス
> uniform mat4 SMapLightMatrix; //シャドウマップライトマトリクス
> //
> uniform bool use_dif_texture; //ディフューズテクスチャ使用
> uniform bool use_alpha_texture; //アルファテクスチャ使用
> uniform bool use_celsdif_texture; //ディフューズセルシェーダテクスチャ使用
> uniform bool use_celsspc_texture; //スペキュラセルシェーダテクスチャ使用
> uniform bool use_reflec_texture; //リフレクションテクスチャ使用
> uniform bool use_bump_texture; //バンプテクスチャ使用
> uniform bool use_smap_texture; //シャドウマップテクスチャ使用
> uniform bool use_light; //ライティング使用
> uniform bool use_edge; //エッジ使用
> uniform bool draw_smap_flg; //シャドウマップ描画
> //
> uniform vec3 light_dir; //ライト方向
> uniform vec3 g_ViewDir; //エッジ色
> uniform float edge_scale; //エッジスケール
> mat3 transpose_mat3(mat3 mt){
> mat3 mt2;
> mt2[0][0]=mt[0][0];
> mt2[0][1]=mt[1][0];
> mt2[0][2]=mt[2][0];
> mt2[1][0]=mt[0][1];
> mt2[1][1]=mt[1][1];
> mt2[1][2]=mt[2][1];
> mt2[2][0]=mt[0][2];
> mt2[2][1]=mt[1][2];
> mt2[2][2]=mt[2][2];
> return mt2;
> }
> void main(void) {
> vec3 now_pos=aVertexPosition;
> if(use_edge){
> now_pos+=(aVertexNormal*edge_scale);
> }
> mat4 WorldMatrixView=ViewMatrix * WorldMatrix;
> vec3 dpos2 =(WorldMatrixView * vec4(now_pos,1.0)).xyz;
> gl_Position = ProjMatrix * vec4(dpos2,1.0);
> if(use_dif_texture || use_alpha_texture || use_bump_texture){
> vTextureCoord = aTextureCoord;
> }else{
> vTextureCoord = vec2(0.0,0.0);
> }
> if(draw_smap_flg){
> vShadowMap=vec4(gl_Position);
> }else{
> if(use_smap_texture){
> vShadowMap=SMapLightMatrix * vec4(dpos2,1.0);
> }
> }
> //
> vColor = aVertexColor;
> //
> mat3 nmt=mat3(WorldMatrix);
> vec3 norm=normalize(nmt*aVertexNormal);
> vNormal=norm;
> //
> if(use_bump_texture){
> vec3 tangent=normalize(nmt*aVertexTangent);
> vec3 binorm =normalize(nmt*aVertexBinormal);
> mat3 tan_mt=mat3(tangent,binorm,norm);
> // tan_mt=transpose(tan_mt);
> tan_mt=transpose_mat3(tan_mt);
> vTangent =tangent;
> vBinormal=binorm;
> vLightDir=tan_mt*light_dir;
> vEyeDir  =tan_mt*g_ViewDir;
> }else{
> vLightDir=light_dir;
> vEyeDir  =g_ViewDir;
> }
> }
>
-----------------------------------------------------------
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
-----------------------------------------------------------