From car...@ Mon Mar 1 01:54:14 2010 From: car...@ (Carl van Heezik) Date: Mon, 1 Mar 2010 10:54:14 +0100 Subject: [Public WebGL] A Declarative node set for WebGL? In-Reply-To: <45774A4F67BB4C15BFAEA718C7E7BE2F@LenBullardPro> References: <45774A4F67BB4C15BFAEA718C7E7BE2F@LenBullardPro> Message-ID: <099BBCC9-66B4-4490-B365-7C594AC1AADD@microcan.nl> A declarative node set for WebGL is not a bad idea but it should NOT be part of the WebGL spec. From the Khronos website WebGL is a cross-platform, royalty-free web standard for a low-level 3D graphics API based on OpenGL ES 2.0, exposed through the HTML5 Canvas element as Document Object Model interfaces. Please define WebGL as a close to the hardware as possible. Keep the WebGL specification lean so it can run on devices with limited resources. There is a reason why different scene graphs / graphics file formats exist. There is simply no one fits all solution. People have different taste, some like Red others Green or Blue. Even if the red coat fits they prefer the blue coat because of their taste. Scene graphs will come and go and the some will survive because everybody is using them. We have seen in the past that just putting a label on it saying that its a standard doesn't help. If its good it will be used if its bad it will not survive. WebGL will be a success if it works well and is running on millions of devices with appealing applications. In my opinion this will be the case. (I am still a little worried about the speed of javascript, smart use of the GPU will probably help). Best regards, Carl van Heezik Op 27 feb 2010, om 04:34 heeft Len Bullard het volgende geschreven: It's a namespace. The DOM can handle that. It really shouldn't matter what scene graph or encoding is layered on top of WebGL. It's the responsibility of the builder and author to use it efficiently. IMO, HTML is exactly the venue to discover it. HTML isn't exactly a light nugget itself but if namespaced-based integration using the DOM is the basis for blending the markup, then it has to work in HTML. What is more important to interacting with WebGL, HTML or the DOM? Is the WebGL developers concept of the DOM defined by the infoset specification? What limits does HTML place on the WebGL use of the DOM? As far as standardization goes, it goes according to the standards work. Some last. Some don't. As long as it is doing a job for someone, it has its own reason to be there. What Chris seems to be proposing if I understand this is a special set of WebGL element types that are more closely bound to WebGL than any existing scene graph markup or alternative. Where are there examples of the element types proposed? Thanks! len -----Original Message----- From: owner-public_webgl...@ [mailto:owner-public_webgl...@] On Behalf Of Thatcher Ulrich Sent: Thursday, February 25, 2010 11:40 PM To: Len Bullard Cc: Chris Marrin; public webgl Subject: Re: [Public WebGL] A Declarative node set for WebGL? My 2 cents: A 3d scene graph layered on top of WebGL (and/or other rendering backends) in the form of a library: sure, the more the merrier -- WebGL should try to be functional enough to make this work well. A 3d scene graph standardized into HTML: premature. Despite many attempts over the decades, there does not exist a one-size-fits-all scene graph that is small enough to be a good standard. Maybe someday there will be, but HTML standardization is not the venue to discover it. One thing I *would* like to see is a good way to reflect an HTML DOM subtree into a WebGL texture. I think this would enable practically all of the worthwhile use cases of DOM in 3D. If a dominant scene graph library emerges out of that, then think about standardizing it. -T ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Mon Mar 1 14:11:39 2010 From: cma...@ (Chris Marrin) Date: Mon, 01 Mar 2010 14:11:39 -0800 Subject: [Public WebGL] Proposal for depth and stencil FBO attachments In-Reply-To: <921bb11002261129o4b594e98v117c3fec8ff1f76a@mail.gmail.com> References: <921bb11002251128m66df4d80rab6cd127481edbbf@mail.gmail.com> <97AE520D-CF63-4CCA-9A1E-00EF7B291FE4@apple.com> <921bb11002251954y210844a4r906cac4e35582034@mail.gmail.com> <33072142-40DF-4D4A-BD80-F1FB7B48C6E5@apple.com> <921bb11002261129o4b594e98v117c3fec8ff1f76a@mail.gmail.com> Message-ID: <2A53AB74-3D72-4DF5-BE7F-5F0340246C5E@apple.com> On Feb 26, 2010, at 11:29 AM, Kenneth Russell wrote: >> ...Ok, then I agree that we should come up with semantics that can be emulated on all three styles of rendering libraries (OpenGL, GL ES, and D3D). But do we need to get rid of the stencil enums? Can't we just say that you can have one and only one of { depth, stencil, depth_stencil }? In other words, remove your rule 3 and change rule 4 to include STENCIL_ATTACHMENT. Again, I have no problem with getting rid of bare stencils in the spec, but only if there is no other way. There will be some implementations that will be able to optimize memory usage better if they know the author just wants a stencil buffer. > > Yes, we could forbid attaching independent depth and stencil > renderbuffers at the same time, and leave in separate stencil. Even if > we take out separate stencil renderbuffers, we will still have to > change the semantics of framebufferRenderbuffer to return an early > INVALID_OPERATION if an attempt is made to set up another attachment > (depth, stencil, depth+stencil) while any of the others is bound. The > reason is that we can not pass through the call to > glFramebufferRenderbuffer(EXT) immediately and there is no good point > to make the call lazily, so we can not simply return the status as > FRAMEBUFFER_INCOMPLETE_UNSUPPORTED from checkFramebufferStatus. > > If this sounds acceptable I'll write it up and send it out for review. Yes, please write it up and let's see how it feels. ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cal...@ Tue Mar 2 00:45:49 2010 From: cal...@ (Mark Callow) Date: Tue, 02 Mar 2010 17:45:49 +0900 Subject: [Public WebGL] A Declarative node set for WebGL? In-Reply-To: <099BBCC9-66B4-4490-B365-7C594AC1AADD@microcan.nl> References: <45774A4F67BB4C15BFAEA718C7E7BE2F@LenBullardPro> <099BBCC9-66B4-4490-B365-7C594AC1AADD@microcan.nl> Message-ID: <4B8CD03D.2090301@hicorp.co.jp> Most of the objections raised to Chris's proposal are based on the notion that it is a scene graph. The only part of the proposal that is graph-based is the Group element. All the other elements are declarative wrappers for OpenGL ES elements. You can set the transform part of the Group element to Identity and do whatever you want to position your objects. You can even ignore the Group element and write your own Javascript magic to create your favoured organization of the other elements. I don't think we should throw out the entire proposal because people's hackles are raised by a one element of it. Regards -Mark On 01/03/2010 18:54, Carl van Heezik wrote: > A declarative node set for WebGL is not a bad idea but it should NOT > be part of the WebGL spec. > > *From the Khronos website* > WebGL is a cross-platform, royalty-free web standard for a low-level > 3D graphics API based on OpenGL ES 2.0, > exposed through the HTML5 > Canvas element > as Document Object Model interfaces. > > Please define WebGL as a close to the hardware as possible. Keep the > WebGL specification lean so it can run on > devices with limited resources. There is a reason why different scene > graphs / graphics file formats exist. There is > simply no one fits all solution. People have different taste, some > like Red others Green or Blue. Even if the red coat > fits they prefer the blue coat because of their taste. > > Scene graphs will come and go and the some will survive because > everybody is using them. We have seen in the > past that just putting a label on it saying that its a standard > doesn't help. If its good it will be used if its bad it will > not survive. WebGL will be a success if it works well and is running > on millions of devices with appealing applications. > In my opinion this will be the case. (I am still a little worried > about the speed of javascript, smart use of the GPU will > probably help). > > Best regards, > Carl van Heezik > > > > Op 27 feb 2010, om 04:34 heeft Len Bullard het volgende geschreven: > > It's a namespace. The DOM can handle that. > > It really shouldn't matter what scene graph or encoding is layered on > top of > WebGL. It's the responsibility of the builder and author to use it > efficiently. > > IMO, HTML is exactly the venue to discover it. HTML isn't exactly a light > nugget itself but if namespaced-based integration using the DOM is the > basis > for blending the markup, then it has to work in HTML. > > What is more important to interacting with WebGL, HTML or the DOM? Is the > WebGL developers concept of the DOM defined by the infoset specification? > What limits does HTML place on the WebGL use of the DOM? > > As far as standardization goes, it goes according to the standards work. > Some last. Some don't. As long as it is doing a job for someone, it has > its own reason to be there. > > What Chris seems to be proposing if I understand this is a special set of > WebGL element types that are more closely bound to WebGL than any existing > scene graph markup or alternative. Where are there examples of the > element > types proposed? > > Thanks! > > len > > -----Original Message----- > From: owner-public_webgl...@ > > [mailto:owner-public_webgl...@] > On Behalf Of Thatcher Ulrich > Sent: Thursday, February 25, 2010 11:40 PM > To: Len Bullard > Cc: Chris Marrin; public webgl > Subject: Re: [Public WebGL] A Declarative node set for WebGL? > > > > My 2 cents: > > A 3d scene graph layered on top of WebGL (and/or other rendering > backends) in the form of a library: sure, the more the merrier -- > WebGL should try to be functional enough to make this work well. > > A 3d scene graph standardized into HTML: premature. Despite many > attempts over the decades, there does not exist a one-size-fits-all > scene graph that is small enough to be a good standard. Maybe someday > there will be, but HTML standardization is not the venue to discover > it. > > One thing I *would* like to see is a good way to reflect an HTML DOM > subtree into a WebGL texture. I think this would enable practically > all of the worthwhile use cases of DOM in 3D. If a dominant scene > graph library emerges out of that, then think about standardizing it. > > -T > > > > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > . > To unsubscribe, send an email to majordomo...@ > with > the following command in the body of your email: > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: callow_mark.vcf Type: text/x-vcard Size: 398 bytes Desc: not available URL: From vla...@ Tue Mar 2 11:20:59 2010 From: vla...@ (Vladimir Vukicevic) Date: Tue, 02 Mar 2010 11:20:59 -0800 Subject: [Public WebGL] webgl canvas compositing into webpage. In-Reply-To: References: <4B833D1D.5050108@hicorp.co.jp> Message-ID: <4B8D651B.3020805@mozilla.com> On 2/23/2010 2:38 PM, Chris Marrin wrote: > On Feb 22, 2010, at 6:27 PM, Mark Callow wrote: > > >> CLAMP_TO_BORDER is not supported on OGL ES. Therefore WebGL needs to >> specified CLAMP_TO_EDGE or you won't be able to implement on top of true >> OpenGL ES. >> > > The spec doesn't require OpenGL, or even an OpenGL-like renderer be used to do page compositing. So GLES constraints are not the issue here. But I agree with Gregg that consistency is important. So maybe we should add some non-normative text that describes the desired behavior of a page compositor? > > Gregg can you come up with some words about that? Hmm, it doesn't seem like this belongs in the WebGL spec -- how compositing of the element is done into the page is entirely within HTML and CSS, not the individual context. As far as the context is concerned, it doesn't know anything about the CSS scaling that's applied, and so can't really talk about what happens under such scaling. - Vlad ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Tue Mar 2 14:35:44 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 2 Mar 2010 14:35:44 -0800 Subject: [Public WebGL] Proposal for depth and stencil FBO attachments In-Reply-To: <2A53AB74-3D72-4DF5-BE7F-5F0340246C5E@apple.com> References: <921bb11002251128m66df4d80rab6cd127481edbbf@mail.gmail.com> <97AE520D-CF63-4CCA-9A1E-00EF7B291FE4@apple.com> <921bb11002251954y210844a4r906cac4e35582034@mail.gmail.com> <33072142-40DF-4D4A-BD80-F1FB7B48C6E5@apple.com> <921bb11002261129o4b594e98v117c3fec8ff1f76a@mail.gmail.com> <2A53AB74-3D72-4DF5-BE7F-5F0340246C5E@apple.com> Message-ID: <921bb11003021435o4424a443o1684f5de01ec422@mail.gmail.com> On Mon, Mar 1, 2010 at 2:11 PM, Chris Marrin wrote: > > On Feb 26, 2010, at 11:29 AM, Kenneth Russell wrote: > >>> ...Ok, then I agree that we should come up with semantics that can be emulated on all three styles of rendering libraries (OpenGL, GL ES, and D3D). But do we need to get rid of the stencil enums? Can't we just say that you can have one and only one of { depth, stencil, depth_stencil }? In other words, remove your rule 3 and change rule 4 to include STENCIL_ATTACHMENT. Again, I have no problem with getting rid of bare stencils in the spec, but only if there is no other way. There will be some implementations that will be able to optimize memory usage better if they know the author just wants a stencil buffer. >> >> Yes, we could forbid attaching independent depth and stencil >> renderbuffers at the same time, and leave in separate stencil. Even if >> we take out separate stencil renderbuffers, we will still have to >> change the semantics of framebufferRenderbuffer to return an early >> INVALID_OPERATION if an attempt is made to set up another attachment >> (depth, stencil, depth+stencil) while any of the others is bound. The >> reason is that we can not pass through the call to >> glFramebufferRenderbuffer(EXT) immediately and there is no good point >> to make the call lazily, so we can not simply return the status as >> FRAMEBUFFER_INCOMPLETE_UNSUPPORTED from checkFramebufferStatus. >> >> If this sounds acceptable I'll write it up and send it out for review. > > > Yes, please write it up and let's see how it feels. I've checked in the following changes: - Added the DEPTH_STENCIL and DEPTH_STENCIL_ATTACHMENT enums to the spec and webgl.idl - Added a section (now Section 6) to the spec on differences between WebGL and OpenGL ES 2.0; we are going to need to add more subsections here - Added a subsection on framebuffer object attachments Please comment. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From gil...@ Tue Mar 2 14:55:31 2010 From: gil...@ (Giles Thomas) Date: Tue, 2 Mar 2010 22:55:31 +0000 Subject: [Public WebGL] WebKit nightly builds -- WebGL broken? Message-ID: Hi all, Someone just wrote to me to say that my WebGL tutorials seem to be broken in the latest WebKit; on a brief check with the current nightly build, it looks like it's not just my stuff that's not working, but also the demos in the public repository. Is this a known problem? I checked on a MacBook Air running OS X 10.5. Cheers, Giles -- Giles Thomas giles...@ http://www.gilesthomas.com/ http://learningwebgl.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Tue Mar 2 15:08:52 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 2 Mar 2010 15:08:52 -0800 Subject: [Public WebGL] WebGLArray slice() spec In-Reply-To: <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> References: <921bb11002241511h20a9bfdcge9cfca8daf3e2e1f@mail.gmail.com> <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> Message-ID: <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> On Wed, Feb 24, 2010 at 4:32 PM, Chris Marrin wrote: > > On Feb 24, 2010, at 3:11 PM, Kenneth Russell wrote: > >> Vlad's typed array proposal at >> http://people.mozilla.com/~vladimir/jsvec/TypedArray-spec.html changes >> the TypedArrays' slice() behavior to more closely match JavaScript's >> arrays' slice() method. Should we update the WebGL spec and >> implementations to match this behavior with the current >> WebGLArrays? I think we should keep the two specs in sync as long >> as they are separate. > > I agree. But I hope we can soon split the Array stuff out of the WebGL spec and let it have a life of its own. I've updated the WebGL spec and IDL. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Tue Mar 2 15:12:52 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 2 Mar 2010 15:12:52 -0800 Subject: [Public WebGL] WebKit nightly builds -- WebGL broken? In-Reply-To: References: Message-ID: <921bb11003021512g4e139be0ua74e585032ad94d3@mail.gmail.com> On Tue, Mar 2, 2010 at 2:55 PM, Giles Thomas wrote: > Hi all, > > Someone just wrote to me to say that my WebGL tutorials seem to be broken in > the latest WebKit; on a brief check with the current nightly build, it looks > like it's not just my stuff that's not working, but also the demos in the > public repository.? Is this a known problem?? I checked on a MacBook Air > running OS X 10.5. This is a known issue; see https://bugs.webkit.org/show_bug.cgi?id=35338 . -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Tue Mar 2 15:21:12 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 2 Mar 2010 15:21:12 -0800 Subject: [Public WebGL] Adding types to signatures in detail boxes Message-ID: <921bb11003021521i1a6f0ad9ge9a0e357fb5b9d1a@mail.gmail.com> Currently the method signatures in the (green) detail boxes throughout the spec omit the types which are in the IDL snippets in the gray boxes. This seems to have been done to follow the pattern in the Canvas spec, but I find it annoying. In particular, it makes it very difficult to document overloaded methods. I would like to make a pass through the spec and add the types (and overloadings) from the gray boxes into the method signatures in the green boxes. Are there any objections to my doing this? Thanks, -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From van...@ Tue Mar 2 15:30:52 2010 From: van...@ (Vangelis Kokkevis) Date: Tue, 2 Mar 2010 15:30:52 -0800 Subject: [Public WebGL] Adding types to signatures in detail boxes In-Reply-To: <921bb11003021521i1a6f0ad9ge9a0e357fb5b9d1a@mail.gmail.com> References: <921bb11003021521i1a6f0ad9ge9a0e357fb5b9d1a@mail.gmail.com> Message-ID: <95c509b71003021530l45d69365s6478dee6a0ff4fc5@mail.gmail.com> On Tue, Mar 2, 2010 at 3:21 PM, Kenneth Russell wrote: > Currently the method signatures in the (green) detail boxes throughout > the spec omit the types which are in the IDL snippets in the gray > boxes. > > This seems to have been done to follow the pattern in the Canvas spec, > but I find it annoying. In particular, it makes it very difficult to > document overloaded methods. > > I would like to make a pass through the spec and add the types (and > overloadings) from the gray boxes into the method signatures in the > green boxes. Are there any objections to my doing this? > > +1 for adding the types in the green boxes! I also find it annoying that they're currently missing. Thanks, Vangelis > Thanks, > > -Ken > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Tue Mar 2 15:44:02 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 2 Mar 2010 15:44:02 -0800 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> Message-ID: <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> On Wed, Feb 24, 2010 at 12:06 PM, Chris Marrin wrote: > > On Feb 23, 2010, at 5:59 PM, Mark Callow wrote: > >> Hi Chris, >> >> On 24/02/2010 07:25, Chris Marrin wrote: >>> On Feb 22, 2010, at 6:21 PM, Mark Callow wrote: >>> >>> >>>> ... >>>> I agree with Ken that adding support to WebGL for deciphering HTMLImages >>>> that are PNG files to automatically determine the format to use for >>>> TexImage2D is an enhancement. A query will clearly need to be part of >>>> this enhancement. >>>> >>> >>> We don't need queries for this. We simply need to know what the resultant internal format is for each type of image loaded. As I mentioned in other responses, adding a format param would provide this. >>> >> >> "Query will clearly (be) need(ed)" was predicated on "automatically >> determine the format". If you add a format specifier to the TexImage2D >> that accepts an HTMLImage then I completely agree a query is not needed. >> We had the same problem vis-a-vis one-channel luminance vs. alpha when >> loading PNG files in M3G. We added a format parameter there too. >> >> When writing the spec. for this format parameter bear in mind that OGL >> ES does not support internal format conversions. Therefore perhaps you >> should throw an exception if, e.g. the app. tries to load a one-channel >> PNG image as RGB. In other words require that the specified format match >> the HTMLImage contents. > > > Right, anything we do would have to be done with client side conversion. For instance, we could specify a format of RGB and pass in a 1 channel PNG as long as we convert it to RGB on the client and then send it in. We just have to have a table showing the conversions. What is the consensus on what we should do here? As I see it, for programmer convenience we want to leave the following existing texImage2D variant: void texImage2D(in GLenum target, in GLint level, in HTMLImageElement image, in optional GLboolean flipY, in optional GLboolean asPremultipliedAlpha); So the most we should do is add the following overloading: void texImage2D(in GLenum target, in GLint level, in GLenum internalformat, in HTMLImageElement image, in optional GLboolean flipY, in optional GLboolean asPremultipliedAlpha); I have some concerns about adding this API at the present time. 1. It will have to be well tested, meaning that we will have to write test cases for loading ALPHA, LUMINANCE, and LUMINANCE_ALPHA textures from images. 2. Without a query API on HTMLImageElement to determine the "native" format for an image it is not clear that it will solve X3D's problem in particular. 3. There is already a lot of work that needs to be done to make the existing WebGL implementations compliant to the current version of the spec. I think we should defer adding this API until the revision of the spec following 1.0. Does anyone have any comments or feel strongly that it should be added to version 1.0? If not, then we can file an RFE on the Khronos Bugzilla to add it later. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From vla...@ Tue Mar 2 17:31:30 2010 From: vla...@ (Vladimir Vukicevic) Date: Tue, 02 Mar 2010 17:31:30 -0800 Subject: [Public WebGL] WebGLArray slice() spec In-Reply-To: <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> References: <921bb11002241511h20a9bfdcge9cfca8daf3e2e1f@mail.gmail.com> <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> Message-ID: <4B8DBBF2.7060609@mozilla.com> On 3/2/2010 3:08 PM, Kenneth Russell wrote: > On Wed, Feb 24, 2010 at 4:32 PM, Chris Marrin wrote: > >> On Feb 24, 2010, at 3:11 PM, Kenneth Russell wrote: >> >> >>> Vlad's typed array proposal at >>> http://people.mozilla.com/~vladimir/jsvec/TypedArray-spec.html changes >>> the TypedArrays' slice() behavior to more closely match JavaScript's >>> arrays' slice() method. Should we update the WebGL spec and >>> implementations to match this behavior with the current >>> WebGLArrays? I think we should keep the two specs in sync as long >>> as they are separate. >>> >> I agree. But I hope we can soon split the Array stuff out of the WebGL spec and let it have a life of its own. >> > I've updated the WebGL spec and IDL. > > Thanks Ken -- I forgot to update the original spec when I made the change in the typedarray spec. I'm going to check the typed array spec into the webgl svn repo for easier tracking/updating; need to add the WebIDL back and to add the stream reader bits as an appendix. - Vlad ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Tue Mar 2 17:33:59 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 2 Mar 2010 17:33:59 -0800 Subject: [Public WebGL] WebGLArray slice() spec In-Reply-To: <4B8DBBF2.7060609@mozilla.com> References: <921bb11002241511h20a9bfdcge9cfca8daf3e2e1f@mail.gmail.com> <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> <4B8DBBF2.7060609@mozilla.com> Message-ID: <921bb11003021733neec7927o4a9077619e0e631c@mail.gmail.com> On Tue, Mar 2, 2010 at 5:31 PM, Vladimir Vukicevic wrote: > On 3/2/2010 3:08 PM, Kenneth Russell wrote: >> >> On Wed, Feb 24, 2010 at 4:32 PM, Chris Marrin ?wrote: >> >>> >>> On Feb 24, 2010, at 3:11 PM, Kenneth Russell wrote: >>> >>> >>>> >>>> Vlad's typed array proposal at >>>> http://people.mozilla.com/~vladimir/jsvec/TypedArray-spec.html changes >>>> the TypedArrays' slice() behavior to more closely match JavaScript's >>>> arrays' slice() method. Should we update the WebGL spec and >>>> implementations to match this behavior with the current >>>> WebGLArrays? I think we should keep the two specs in sync as long >>>> as they are separate. >>>> >>> >>> I agree. But I hope we can soon split the Array stuff out of the WebGL >>> spec and let it have a life of its own. >>> >> >> I've updated the WebGL spec and IDL. >> >> > > Thanks Ken -- I forgot to update the original spec when I made the change in > the typedarray spec. ?I'm going to check the typed array spec into the webgl > svn repo for easier tracking/updating; need to add the WebIDL back and to > add the stream reader bits as an appendix. That's great -- was hoping we could collaborate on editing the typed array spec. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Tue Mar 2 19:13:29 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 2 Mar 2010 19:13:29 -0800 Subject: [Public WebGL] Lost Context In-Reply-To: <921bb11002241448k53e635demc2b9daadcebe837d@mail.gmail.com> References: <4B773C6E.9010004@mozilla.com> <4B77603C.5040309@mozilla.com> <921bb11002241409o37abb90fv72ed240d96f3f408@mail.gmail.com> <921bb11002241448k53e635demc2b9daadcebe837d@mail.gmail.com> Message-ID: <921bb11003021913i6615824cg38f2d11ec44ed409@mail.gmail.com> On Wed, Feb 24, 2010 at 2:48 PM, Kenneth Russell wrote: > On Wed, Feb 24, 2010 at 2:32 PM, Chris Marrin wrote: >> >> On Feb 24, 2010, at 2:09 PM, Kenneth Russell wrote: >> >>> On Wed, Feb 24, 2010 at 10:27 AM, Gregg Tavares wrote: >>>> Yet another lost context issue... >>>> How about adding a new error CONTEXT_LOST that gl.getError returns on all >>>> commands once the context is lost? >>>> Here's the issue that I think needs solving. >>>> You create a WebGL program that loads stuff asynchronously (like many of the >>>> current WebGL demos), while loading you lose the context (user sleeps the >>>> device, etc...), on recovery if the GL calls don't give CONTEXT_LOST than it >>>> doesn't seem like the initialization code will be able to distinguish >>>> between real failure "ie, this app can't run on this device" and lost >>>> context "ie, I need to start initialization over". >>>> Thoughts? >>> >>> I agree that an indicator is needed. We have been discussing adding a >>> "context lost" extension to desktop OpenGL with a few vendors in >>> preparation for an ARB proposal, and some sort of indication that the >>> context has been lost is needed. The thinking was to make it a >>> glGetInteger query or similar, to avoid needing to call glGetError() >>> to determine that the context has been lost. >>> >>> There are concerns with adding a new enum which isn't present in >>> either OpenGL ES or desktop OpenGL yet. If we do add an enum then we >>> should register it in the extension registry to avoid the possibility >>> of collision in the future. >>> >>> Alternatively, we could add a function like "boolean isContextLost()" >>> or "boolean isContextValid()" to the context itself. This has the >>> disadvantage of introducing another type of error check that may need >>> to be queried by applications. >>> >>> On the whole I would rather wait to see what form the planned desktop >>> GL extension takes before making a decision on the WebGL API. For the >>> time being we can use the asynchronous "context lost" event, and >>> perhaps synthesize INVALID_OPERATION in the case you describe. I think >>> it will still be possible to write apps that handle the lost context >>> case. Upon receiving a context lost event the app should completely >>> reset itself, so if it received GL errors during the last few calls >>> before it received the event, that shouldn't matter. >> >> >> I agree with the idea of returning this as a specific error. But I sure hope we can find a way to make it clear that this is a context-lost error. I'd hate to add a function for this, for the reasons you mention. And I'd hate to return INVALID_OPERATION because that will give the author no clue as to what happened. If OpenGL is working on this, might they have an idea of what the error code will be so we can use it? If not, is there any range of "vendor defined" error codes in OpenGL? > > I've talked with NVIDIA, who are shepherding the extension through > (Greg Roth specifically), and it sounds like it will take form within > a couple of weeks. I think we should simply defer this discussion > until then. In order to make progress on the specification, I've rewritten the section on the WebGLResourceLostEvent as WebGLContextLostEvent as Gregg suggested at the top of the thread. I added the needed "boolean resetContext()" method. Contrary to my argument above I also added a "boolean isContextLost()" method because it seems a query for this state is useful if not necessary. This can certainly be debated more. There is now an ECMAScript example showing how an application might register a listener for this event and attempt to recover from it. Please comment. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Tue Mar 2 21:41:22 2010 From: ced...@ (Cedric Vivier) Date: Wed, 3 Mar 2010 13:41:22 +0800 Subject: [Public WebGL] A replacement or changing for setInterval? In-Reply-To: <08D30173-45ED-409E-8E98-1724B8FB0B05@apple.com> References: <08D30173-45ED-409E-8E98-1724B8FB0B05@apple.com> Message-ID: On Tue, Feb 16, 2010 at 2:44 AM, Chris Marrin wrote: > context.setRenderFunction(renderFunction, targetFramerate); > context.scheduleRender(); > > The first call would be made to setup the callback function and the target > framerate. Whenever you want to render a frame you would call > scheduleRender() and the callback would be called in the near future. For > things like a spinning cube you would call scheduleRender() in your > renderFunction. > This mechanism would do several things that would be hard or impossible > with the existing interval timer: > (...) > Not much discussion on this thread though the issue brought up in this thread is quite important imho. Proposal above makes sense, however for interactive apps that needs an "updateFunction" whether or not the context is actually rendered to screen, I assume this would force usage of at least two timers fighting for CPU time (one for updateFunction, and one internally used by scheduleRender to run renderFunction after other timers have finished execution), I assume this would not be very efficient and makes things more difficult for developers (e.g updateFunction not guaranteed to be run before renderFunction for each frame). Actually the original issue wrt visibility versus wasteful renders can be handled for the most common cases (window minimized, background tab) through just window.onfocus/onblur afaik [1]. However since WebGL indeed will make this issue standout, it could be good idea to make invisibility handling as easy and as discoverable as possible to encourage wide usage of such an eco-friendly feature ;-). I propose an helper that allows developers to handle this as they see fit and potentially improve what would be possible through window.onfocus/onblur when a WebGL implementation also checks if canvas is within html viewport : boolean isContextVisible(); Returns true if context is visible or partially visible, false otherwise (eg. window is minimized, canvas is outside viewport, ...). Example: function renderFunction() { if (!context.IsContextVisible()) return; //skip rendering as the canvas is not visible } Regards, [1] : works on Firefox, on WebKit works only for window minimized currently (see https://bugs.webkit.org/show_bug.cgi?id=18675 ) -------------- next part -------------- An HTML attachment was scrubbed... URL: From cal...@ Tue Mar 2 22:06:22 2010 From: cal...@ (Mark Callow) Date: Wed, 03 Mar 2010 15:06:22 +0900 Subject: [Public WebGL] Proposal for depth and stencil FBO attachments In-Reply-To: <921bb11003021435o4424a443o1684f5de01ec422@mail.gmail.com> References: <921bb11002251128m66df4d80rab6cd127481edbbf@mail.gmail.com> <97AE520D-CF63-4CCA-9A1E-00EF7B291FE4@apple.com> <921bb11002251954y210844a4r906cac4e35582034@mail.gmail.com> <33072142-40DF-4D4A-BD80-F1FB7B48C6E5@apple.com> <921bb11002261129o4b594e98v117c3fec8ff1f76a@mail.gmail.com> <2A53AB74-3D72-4DF5-BE7F-5F0340246C5E@apple.com> <921bb11003021435o4424a443o1684f5de01ec422@mail.gmail.com> Message-ID: <4B8DFC5E.9010201@hicorp.co.jp> Hi Ken, I think it is good. You can remove the last sentence, replacing it with the word "concurrently" in the sentence before the list of combinations: "In WebGL, it is an error to concurrently attach renderbuffers to the following combinations of attachment points:" Regards -Mark On 03/03/2010 07:35, Kenneth Russell wrote: > On Mon, Mar 1, 2010 at 2:11 PM, Chris Marrin wrote: > >> On Feb 26, 2010, at 11:29 AM, Kenneth Russell wrote: >> >> >>>> ...Ok, then I agree that we should come up with semantics that can be emulated on all three styles of rendering libraries (OpenGL, GL ES, and D3D). But do we need to get rid of the stencil enums? Can't we just say that you can have one and only one of { depth, stencil, depth_stencil }? In other words, remove your rule 3 and change rule 4 to include STENCIL_ATTACHMENT. Again, I have no problem with getting rid of bare stencils in the spec, but only if there is no other way. There will be some implementations that will be able to optimize memory usage better if they know the author just wants a stencil buffer. >>>> >>> Yes, we could forbid attaching independent depth and stencil >>> renderbuffers at the same time, and leave in separate stencil. Even if >>> we take out separate stencil renderbuffers, we will still have to >>> change the semantics of framebufferRenderbuffer to return an early >>> INVALID_OPERATION if an attempt is made to set up another attachment >>> (depth, stencil, depth+stencil) while any of the others is bound. The >>> reason is that we can not pass through the call to >>> glFramebufferRenderbuffer(EXT) immediately and there is no good point >>> to make the call lazily, so we can not simply return the status as >>> FRAMEBUFFER_INCOMPLETE_UNSUPPORTED from checkFramebufferStatus. >>> >>> If this sounds acceptable I'll write it up and send it out for review. >>> >> >> Yes, please write it up and let's see how it feels. >> > I've checked in the following changes: > > - Added the DEPTH_STENCIL and DEPTH_STENCIL_ATTACHMENT enums to the > spec and webgl.idl > - Added a section (now Section 6) to the spec on differences between > WebGL and OpenGL ES 2.0; we are going to need to add more subsections > here > - Added a subsection on framebuffer object attachments > > Please comment. > > -Ken > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: callow_mark.vcf Type: text/x-vcard Size: 398 bytes Desc: not available URL: From vla...@ Tue Mar 2 23:48:51 2010 From: vla...@ (Vladimir Vukicevic) Date: Tue, 02 Mar 2010 23:48:51 -0800 Subject: [Public WebGL] A replacement or changing for setInterval? In-Reply-To: <08D30173-45ED-409E-8E98-1724B8FB0B05@apple.com> References: <08D30173-45ED-409E-8E98-1724B8FB0B05@apple.com> Message-ID: <4B8E1463.9070202@mozilla.com> I am in general all for something like this, but as Chris said, it really isn't WebGL-specific. There are many non-webgl use cases where something like this would be desired, so I'd suggest that this suggestion be made as a generic HTML API, and implemented on the toplevel DOM global object. I think it would be a good companion to existing setTimeout/setInterval methods for a wide variety of use cases. - Vlad On 2/15/2010 10:44 AM, Chris Marrin wrote: > On Feb 13, 2010, at 6:40 PM, Gregg Tavares wrote: > > >> I thought I'd bring this up here. It's been brought up in the webapps list before but it doesn't seem like there is any momentum. Given that all the major browser vendors seem to be implementing WebGL (with one notable exception) maybe we can come to a consensus here and together propose it to the webapps group. >> >> The issue is unlike Flash, animated WebGL apps will use CPU even when not visible. >> >> This is because window.setInterval(), the function used to enable animation, doesn't care if the webpage or the canvas element is off screen. There is no info that they are offscreen and so minimizing, putting the page on a back tab, etc will not stop the app from doing all of it's calculations and all of it's rendering. Only the final compositing step is avoided. >> >> You can see this problem with 2D canvas animation >> >> Click this link >> http://mrdoob.com/projects/chromeexperiments/depth_of_field/ >> >> Minimize the window or switch to another tab and notice that it's still taking up a bunch of CPU time. >> >> Or this one >> http://www.ambiera.at/copperlicht/demos/demo_quakelevel_external.html >> >> Conversely, look at this flash page. >> http://www.alissadean.com/ >> >> It may not look like it's doing a lot of work but given that it is software composited there is actually a lot of CPU usage. Notice that unlike the canvas demos, when you minimize that window or put it on a back tab the CPU usage drops to zero. >> >> It seems like we need a way to accomplish the same thing else WebGL apps may kill performance even when not visible. >> >> A few proposals. >> >> #1 Add a window.setIntervalWhenVisible or an option to window.setInterval that lets you specific, call only when visible. >> >> #2 Add a element.setIntervalWhenVisible >> >> This has the advantage over #1 which is that if the element is down the page it won't use any CPU. >> >> #3 Change window.setInterval to have a bool (call only when visible) that defaults to TRUE. >> >> This is the same as #1. It has the disadvantage that it will break some existing apps. >> >> But, it has the advantage that by default your app will not use CPU offscreen unless you specifically request it. The issue is there's a million JavaScript programmers out there that are unlikely to discover methods #1 or #2 so if we want people to do the right thing for users it seems like breaking old behavior might be better than having people dislike WebGL apps and Canvas apps because most of them slow their machines to a crawl. >> >> There's a couple of other proposals in the original thread >> http://lists.w3.org/Archives/Public/public-webapps/2009OctDec/0223.html >> >> You could argue that this is not a WebGL issue but I think WebGL is the tech most likely to bring this issue to the forefront. >> > The proposals you made are not WebGL specific. But you're right that WebGL will make this issue stand out. So maybe a WebGL specific solution would be in order. We could add: > > context.setRenderFunction(renderFunction, targetFramerate); > context.scheduleRender(); > > The first call would be made to setup the callback function and the target framerate. Whenever you want to render a frame you would call scheduleRender() and the callback would be called in the near future. For things like a spinning cube you would call scheduleRender() in your renderFunction. > > This mechanism would do several things that would be hard or impossible with the existing interval timer: > > 1) It would fire only once regardless of the number of times scheduleRender() was called. > > 2) Calls would be throttled to keep framerate at or below targetFramerate. > > 3) Call frequency can be adjusted to keep intervals consistent. This includes both setting a shorter interval to keep up with targetFramerate and moderating the rate when rendering overhead requires a slower interval than targetFramerate. > > 4) Call frequency can be reduced on a browser specific basis to keep WebGL from taking up too much CPU. > > 5) Calls can be stopped when the page is not visible. > > These rendering specific calls give us a lot of opportunity for managing WebGL rendering and I think it would be worth the extra API. > > ----- > ~Chris > cmarrin...@ > > > > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From car...@ Wed Mar 3 03:13:14 2010 From: car...@ (Carl van Heezik) Date: Wed, 3 Mar 2010 12:13:14 +0100 Subject: [Public WebGL] webgl canvas compositing into webpage. In-Reply-To: <4B8D651B.3020805@mozilla.com> References: <4B833D1D.5050108@hicorp.co.jp> <4B8D651B.3020805@mozilla.com> Message-ID: <7437CA81-3AFC-4B18-BFF7-7F3CECEC5DE3@microcan.nl> Chris / Vlad, Compositing is a problem with WebGL. Its discussed before and it is caused by the premultiplied alpha. Previous versions of Minefield had this problem, but the current version seems to work correct. e.g. If you use a canvas with a CSS style background-color:red and gl.clearColor(1.0, 1.0, 1.0, 0.0); and render a green triangle with a black outline, with an alpha of 0.5. You get different results for different browsers. The current version of Minefield gives the result I expect, Webkit gives a complete different (wrong) result. -------------- next part -------------- A non-text attachment was scrubbed... Name: PastedGraphic-9.png Type: image/png Size: 59675 bytes Desc: not available URL: -------------- next part -------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: PastedGraphic-10.png Type: image/png Size: 45468 bytes Desc: not available URL: -------------- next part -------------- If I change to gl.clearColor(1.0, 1.0, 1.0, 1.0, 1.0) I get the following results. -------------- next part -------------- A non-text attachment was scrubbed... Name: PastedGraphic-11.png Type: image/png Size: 60067 bytes Desc: not available URL: -------------- next part -------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: PastedGraphic-12.png Type: image/png Size: 45896 bytes Desc: not available URL: -------------- next part -------------- Another test with a text div and a canvas with a background:none and z-index: 10. The background has color:white and background-color:red z-index:0 -------------- next part -------------- A non-text attachment was scrubbed... Name: PastedGraphic-13.png Type: image/png Size: 200558 bytes Desc: not available URL: -------------- next part -------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: PastedGraphic-14.png Type: image/png Size: 202604 bytes Desc: not available URL: -------------- next part -------------- All tests are done on a iMac, the Minefield browser running under Parallels Windows 7. Please specify the correct behavior and create a conformance test. Best regards, Carl van Heezik Op 2 mrt 2010, om 20:20 heeft Vladimir Vukicevic het volgende geschreven: On 2/23/2010 2:38 PM, Chris Marrin wrote: > On Feb 22, 2010, at 6:27 PM, Mark Callow wrote: > > >> CLAMP_TO_BORDER is not supported on OGL ES. Therefore WebGL needs to >> specified CLAMP_TO_EDGE or you won't be able to implement on top of true >> OpenGL ES. >> > > The spec doesn't require OpenGL, or even an OpenGL-like renderer be used to do page compositing. So GLES constraints are not the issue here. But I agree with Gregg that consistency is important. So maybe we should add some non-normative text that describes the desired behavior of a page compositor? > > Gregg can you come up with some words about that? Hmm, it doesn't seem like this belongs in the WebGL spec -- how compositing of the element is done into the page is entirely within HTML and CSS, not the individual context. As far as the context is concerned, it doesn't know anything about the CSS scaling that's applied, and so can't really talk about what happens under such scaling. - Vlad ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From gil...@ Wed Mar 3 03:39:35 2010 From: gil...@ (Giles Thomas) Date: Wed, 3 Mar 2010 11:39:35 +0000 Subject: [Public WebGL] WebKit nightly builds -- WebGL broken? In-Reply-To: <921bb11003021512g4e139be0ua74e585032ad94d3@mail.gmail.com> References: <921bb11003021512g4e139be0ua74e585032ad94d3@mail.gmail.com> Message-ID: On 2 March 2010 23:12, Kenneth Russell wrote: > On Tue, Mar 2, 2010 at 2:55 PM, Giles Thomas > wrote: > > Someone just wrote to me to say that my WebGL tutorials seem to be broken > in > > the latest WebKit; on a brief check with the current nightly build, it > looks > > like it's not just my stuff that's not working, but also the demos in the > > public repository. Is this a known problem? I checked on a MacBook Air > > running OS X 10.5. > > This is a known issue; see https://bugs.webkit.org/show_bug.cgi?id=35338 . > Thanks, Ken. So, WebKit inside Safari should now only be used on Snow Leopard, and people who are running Leopard should use Chromium or Minefield if they want to try WebGL -- is that right? Regards, Giles -- Giles Thomas giles...@ http://www.gilesthomas.com/ http://learningwebgl.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From exc...@ Wed Mar 3 04:01:02 2010 From: exc...@ (Philip Taylor) Date: Wed, 3 Mar 2010 12:01:02 +0000 Subject: [Public WebGL] WebGL context resize / canvas redraw In-Reply-To: References: <921bb11002251017i389ad9eci51f1f7920d43cf58@mail.gmail.com> <921bb11002251138q6852d424j9769299660ea7e92@mail.gmail.com> <921bb11002251154i7b36abbfla54f768501a33cfc@mail.gmail.com> Message-ID: On Thu, Feb 25, 2010 at 10:32 PM, Gregg Tavares wrote: > On Thu, Feb 25, 2010 at 11:54 AM, Kenneth Russell wrote: >> On Thu, Feb 25, 2010 at 11:38 AM, Kenneth Russell wrote: >> > On Thu, Feb 25, 2010 at 11:06 AM, Philip Taylor >> > wrote: >> >> HTML5 says: >> >> >> >> ?"When the canvas element is created, and subsequently whenever the >> >> width and height attributes are set (whether to a new value or to the >> >> previous value), the bitmap and any associated contexts must be >> >> cleared back to their initial state and reinitialized with the newly >> >> specified coordinate space dimensions." >> >> [...] >> >> Is WebGL compatible with this definition? (I've not looked carefully >> >> but it seems it may not be). If not, and if there's good reasons to be >> >> incompatible, then it'd be good to get HTML5 updated so it allows this >> >> resetting behaviour to be specified by each context. >> > >> > [...] >> >> Gregg pointed out that I misunderstood the HTML5 statement. The >> requirement that the contexts (rather than the backing bitmaps) are >> cleared back to their initial state is incompatible with WebGL. We do >> not want to have to throw away the OpenGL context or otherwise touch >> its state if the canvas is resized. This is effectively the same as >> generating a context lost event and would be traumatic to the app. >> >> I think section 2.2 of the WebGL spec states the behavior pretty >> clearly. Minefield should be changed to follow it. > > I think what Philip was pointing out is that this requires the HTML5 spec to > be updated to state that it's up to the particular type of context whether > or not its state is reset when the size changes. Yes - what HTML5 currently says is only based on experience with the 2d context, so it shouldn't constrain WebGL when different behaviour makes more sense, but the specs ought to become consistent and non-contradictory over time, and I wanted to check if this was one of the currently-contradictory cases. It's not an urgent problem but it'd be good to make sure these issues don't get lost in the cracks. -- Philip Taylor excors...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Wed Mar 3 09:17:26 2010 From: kbr...@ (Kenneth Russell) Date: Wed, 3 Mar 2010 09:17:26 -0800 Subject: [Public WebGL] WebKit nightly builds -- WebGL broken? In-Reply-To: References: <921bb11003021512g4e139be0ua74e585032ad94d3@mail.gmail.com> Message-ID: <921bb11003030917m6faf072cla9bbc523affa5115@mail.gmail.com> On Wed, Mar 3, 2010 at 3:39 AM, Giles Thomas wrote: > On 2 March 2010 23:12, Kenneth Russell wrote: >> >> On Tue, Mar 2, 2010 at 2:55 PM, Giles Thomas >> wrote: >> > Someone just wrote to me to say that my WebGL tutorials seem to be >> > broken in >> > the latest WebKit; on a brief check with the current nightly build, it >> > looks >> > like it's not just my stuff that's not working, but also the demos in >> > the >> > public repository.? Is this a known problem?? I checked on a MacBook Air >> > running OS X 10.5. >> >> This is a known issue; see https://bugs.webkit.org/show_bug.cgi?id=35338 . > > Thanks, Ken.? So, WebKit inside Safari should now only be used on Snow > Leopard, and people who are running Leopard should use Chromium or Minefield > if they want to try WebGL -- is that right? (s/WebKit/WebGL) Yes, that's right, at least for the moment. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Wed Mar 3 10:45:08 2010 From: kbr...@ (Kenneth Russell) Date: Wed, 3 Mar 2010 10:45:08 -0800 Subject: [Public WebGL] WebGL context resize / canvas redraw In-Reply-To: References: <921bb11002251017i389ad9eci51f1f7920d43cf58@mail.gmail.com> <921bb11002251138q6852d424j9769299660ea7e92@mail.gmail.com> <921bb11002251154i7b36abbfla54f768501a33cfc@mail.gmail.com> Message-ID: <921bb11003031045q1d40f8e6v1a795887a66f69a5@mail.gmail.com> On Wed, Mar 3, 2010 at 4:01 AM, Philip Taylor wrote: > On Thu, Feb 25, 2010 at 10:32 PM, Gregg Tavares wrote: >> On Thu, Feb 25, 2010 at 11:54 AM, Kenneth Russell wrote: >>> On Thu, Feb 25, 2010 at 11:38 AM, Kenneth Russell wrote: >>> > On Thu, Feb 25, 2010 at 11:06 AM, Philip Taylor >>> > wrote: >>> >> HTML5 says: >>> >> >>> >> ?"When the canvas element is created, and subsequently whenever the >>> >> width and height attributes are set (whether to a new value or to the >>> >> previous value), the bitmap and any associated contexts must be >>> >> cleared back to their initial state and reinitialized with the newly >>> >> specified coordinate space dimensions." >>> >> [...] >>> >> Is WebGL compatible with this definition? (I've not looked carefully >>> >> but it seems it may not be). If not, and if there's good reasons to be >>> >> incompatible, then it'd be good to get HTML5 updated so it allows this >>> >> resetting behaviour to be specified by each context. >>> > >>> > [...] >>> >>> Gregg pointed out that I misunderstood the HTML5 statement. The >>> requirement that the contexts (rather than the backing bitmaps) are >>> cleared back to their initial state is incompatible with WebGL. We do >>> not want to have to throw away the OpenGL context or otherwise touch >>> its state if the canvas is resized. This is effectively the same as >>> generating a context lost event and would be traumatic to the app. >>> >>> I think section 2.2 of the WebGL spec states the behavior pretty >>> clearly. Minefield should be changed to follow it. >> >> I think what Philip was pointing out is that this requires the HTML5 spec to >> be updated to state that it's up to the particular type of context whether >> or not its state is reset when the size changes. > > Yes - what HTML5 currently says is only based on experience with the > 2d context, so it shouldn't constrain WebGL when different behaviour > makes more sense, but the specs ought to become consistent and > non-contradictory over time, and I wanted to check if this was one of > the currently-contradictory cases. It's not an urgent problem but it'd > be good to make sure these issues don't get lost in the cracks. It would be really helpful if you could file a bug about this on the Khronos Bugzilla instance under WebGL. That is the best way to ensure this is tracked. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Wed Mar 3 10:52:44 2010 From: kbr...@ (Kenneth Russell) Date: Wed, 3 Mar 2010 10:52:44 -0800 Subject: [Public WebGL] Proposal for depth and stencil FBO attachments In-Reply-To: <4B8DFC5E.9010201@hicorp.co.jp> References: <921bb11002251128m66df4d80rab6cd127481edbbf@mail.gmail.com> <97AE520D-CF63-4CCA-9A1E-00EF7B291FE4@apple.com> <921bb11002251954y210844a4r906cac4e35582034@mail.gmail.com> <33072142-40DF-4D4A-BD80-F1FB7B48C6E5@apple.com> <921bb11002261129o4b594e98v117c3fec8ff1f76a@mail.gmail.com> <2A53AB74-3D72-4DF5-BE7F-5F0340246C5E@apple.com> <921bb11003021435o4424a443o1684f5de01ec422@mail.gmail.com> <4B8DFC5E.9010201@hicorp.co.jp> Message-ID: <921bb11003031052q5802db81p978f7d14cc3a9e7e@mail.gmail.com> On Tue, Mar 2, 2010 at 10:06 PM, Mark Callow wrote: > Hi Ken, > > I think it is good. You can remove the last sentence, replacing it with the > word "concurrently" in the sentence before the list of combinations: > > "In WebGL, it is an error to concurrently attach renderbuffers to the > following combinations of attachment points:" Thanks for the suggestion. Updated. -Ken > Regards > > -Mark > > On 03/03/2010 07:35, Kenneth Russell wrote: > > On Mon, Mar 1, 2010 at 2:11 PM, Chris Marrin wrote: > > > On Feb 26, 2010, at 11:29 AM, Kenneth Russell wrote: > > > > ...Ok, then I agree that we should come up with semantics that can be > emulated on all three styles of rendering libraries (OpenGL, GL ES, and > D3D). But do we need to get rid of the stencil enums? Can't we just say that > you can have one and only one of { depth, stencil, depth_stencil }? In other > words, remove your rule 3 and change rule 4 to include STENCIL_ATTACHMENT. > Again, I have no problem with getting rid of bare stencils in the spec, but > only if there is no other way. There will be some implementations that will > be able to optimize memory usage better if they know the author just wants a > stencil buffer. > > > Yes, we could forbid attaching independent depth and stencil > renderbuffers at the same time, and leave in separate stencil. Even if > we take out separate stencil renderbuffers, we will still have to > change the semantics of framebufferRenderbuffer to return an early > INVALID_OPERATION if an attempt is made to set up another attachment > (depth, stencil, depth+stencil) while any of the others is bound. The > reason is that we can not pass through the call to > glFramebufferRenderbuffer(EXT) immediately and there is no good point > to make the call lazily, so we can not simply return the status as > FRAMEBUFFER_INCOMPLETE_UNSUPPORTED from checkFramebufferStatus. > > If this sounds acceptable I'll write it up and send it out for review. > > > Yes, please write it up and let's see how it feels. > > > I've checked in the following changes: > > - Added the DEPTH_STENCIL and DEPTH_STENCIL_ATTACHMENT enums to the > spec and webgl.idl > - Added a section (now Section 6) to the spec on differences between > WebGL and OpenGL ES 2.0; we are going to need to add more subsections > here > - Added a subsection on framebuffer object attachments > > Please comment. > > -Ken > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From gil...@ Wed Mar 3 12:41:11 2010 From: gil...@ (Giles Thomas) Date: Wed, 3 Mar 2010 20:41:11 +0000 Subject: [Public WebGL] WebKit nightly builds -- WebGL broken? In-Reply-To: <921bb11003030917m6faf072cla9bbc523affa5115@mail.gmail.com> References: <921bb11003021512g4e139be0ua74e585032ad94d3@mail.gmail.com> <921bb11003030917m6faf072cla9bbc523affa5115@mail.gmail.com> Message-ID: On 3 March 2010 17:17, Kenneth Russell wrote: > On Wed, Mar 3, 2010 at 3:39 AM, Giles Thomas > wrote: > > Thanks, Ken. So, WebKit inside Safari should now only be used on Snow > > Leopard, and people who are running Leopard should use Chromium or > Minefield > > if they want to try WebGL -- is that right? > > (s/WebKit/WebGL) > > Yes, that's right, at least for the moment. > OK, thanks -- I've updated the "Getting a WebGL Implementation" page on the WebGL Wiki and my own notes on WebKit appropriately. Regards, Giles -- Giles Thomas giles...@ http://www.gilesthomas.com/ http://learningwebgl.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From vla...@ Wed Mar 3 15:22:47 2010 From: vla...@ (Vladimir Vukicevic) Date: Wed, 03 Mar 2010 15:22:47 -0800 Subject: [Public WebGL] WebGLArray slice() spec In-Reply-To: <921bb11003021733neec7927o4a9077619e0e631c@mail.gmail.com> References: <921bb11002241511h20a9bfdcge9cfca8daf3e2e1f@mail.gmail.com> <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> <4B8DBBF2.7060609@mozilla.com> <921bb11003021733neec7927o4a9077619e0e631c@mail.gmail.com> Message-ID: <4B8EEF47.9000007@mozilla.com> On 3/2/2010 5:33 PM, Kenneth Russell wrote: > On Tue, Mar 2, 2010 at 5:31 PM, Vladimir Vukicevic wrote: > >> Thanks Ken -- I forgot to update the original spec when I made the change in >> the typedarray spec. I'm going to check the typed array spec into the webgl >> svn repo for easier tracking/updating; need to add the WebIDL back and to >> add the stream reader bits as an appendix. >> > That's great -- was hoping we could collaborate on editing the typed array spec. > Just checked it in, along with WebIDL added back and a section on the DataSream API. Ken, please update if this isn't the current version of the DataStream proposal -- I took it from your earlier email. https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html - Vlad ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Wed Mar 3 16:02:41 2010 From: kbr...@ (Kenneth Russell) Date: Wed, 3 Mar 2010 16:02:41 -0800 Subject: [Public WebGL] WebGLArray slice() spec In-Reply-To: <4B8EEF47.9000007@mozilla.com> References: <921bb11002241511h20a9bfdcge9cfca8daf3e2e1f@mail.gmail.com> <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> <4B8DBBF2.7060609@mozilla.com> <921bb11003021733neec7927o4a9077619e0e631c@mail.gmail.com> <4B8EEF47.9000007@mozilla.com> Message-ID: <921bb11003031602k348e60d5q48d5b34d9189d3b1@mail.gmail.com> On Wed, Mar 3, 2010 at 3:22 PM, Vladimir Vukicevic wrote: > On 3/2/2010 5:33 PM, Kenneth Russell wrote: >> >> On Tue, Mar 2, 2010 at 5:31 PM, Vladimir Vukicevic >> ?wrote: >> >>> >>> Thanks Ken -- I forgot to update the original spec when I made the change >>> in >>> the typedarray spec. ?I'm going to check the typed array spec into the >>> webgl >>> svn repo for easier tracking/updating; need to add the WebIDL back and to >>> add the stream reader bits as an appendix. >>> >> >> That's great -- was hoping we could collaborate on editing the typed array >> spec. >> > > Just checked it in, along with WebIDL added back and a section on the > DataSream API. ?Ken, please update if this isn't the current version of the > DataStream proposal -- I took it from your earlier email. > > https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html Based on earlier feedback from Chris Marrin, the email I sent to es-discuss had this phrased as a DataArray rather than a DataStream. I've updated the TypedArray spec appropriately. I think we should introduce a base class (TypedArray?) from which the others can derive, and which can hold the read-only attributes for the buffer, length, etc. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From vla...@ Wed Mar 3 16:30:41 2010 From: vla...@ (Vladimir Vukicevic) Date: Wed, 03 Mar 2010 16:30:41 -0800 Subject: [Public WebGL] WebGLArray slice() spec In-Reply-To: <921bb11003031602k348e60d5q48d5b34d9189d3b1@mail.gmail.com> References: <921bb11002241511h20a9bfdcge9cfca8daf3e2e1f@mail.gmail.com> <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> <4B8DBBF2.7060609@mozilla.com> <921bb11003021733neec7927o4a9077619e0e631c@mail.gmail.com> <4B8EEF47.9000007@mozilla.com> <921bb11003031602k348e60d5q48d5b34d9189d3b1@mail.gmail.com> Message-ID: <4B8EFF31.8050006@mozilla.com> On 3/3/2010 4:02 PM, Kenneth Russell wrote: > On Wed, Mar 3, 2010 at 3:22 PM, Vladimir Vukicevic wrote: > >> On 3/2/2010 5:33 PM, Kenneth Russell wrote: >> >>> On Tue, Mar 2, 2010 at 5:31 PM, Vladimir Vukicevic >>> wrote: >>> >>> >>>> Thanks Ken -- I forgot to update the original spec when I made the change >>>> in >>>> the typedarray spec. I'm going to check the typed array spec into the >>>> webgl >>>> svn repo for easier tracking/updating; need to add the WebIDL back and to >>>> add the stream reader bits as an appendix. >>>> >>>> >>> That's great -- was hoping we could collaborate on editing the typed array >>> spec. >>> >>> >> Just checked it in, along with WebIDL added back and a section on the >> DataSream API. Ken, please update if this isn't the current version of the >> DataStream proposal -- I took it from your earlier email. >> >> https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html >> > Based on earlier feedback from Chris Marrin, the email I sent to > es-discuss had this phrased as a DataArray rather than a DataStream. > I've updated the TypedArray spec appropriately. > > I think we should introduce a base class (TypedArray?) from which the > others can derive, and which can hold the read-only attributes for the > buffer, length, etc. > Yeah, I ended up taking that out because without the interfaces/inheritance it didn't really seem make sense to have it -- I was trying to phrase things in purely ecmascript terms. It makes sense to have it for WebIDL though, so I can add it back in. Naming is going to be slightly odd though -- I don't really like "DataArray", because it's not really an array... DataReader might be more appropriate, but that doesn't cover the writing case. The base interface would also be weird as TypedArray if it was shared between the two, but maybe "ArrayBufferView" would cover both cases as the base interface name? - Vlad ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Wed Mar 3 16:38:52 2010 From: kbr...@ (Kenneth Russell) Date: Wed, 3 Mar 2010 16:38:52 -0800 Subject: [Public WebGL] WebGLArray slice() spec In-Reply-To: <4B8EFF31.8050006@mozilla.com> References: <921bb11002241511h20a9bfdcge9cfca8daf3e2e1f@mail.gmail.com> <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> <4B8DBBF2.7060609@mozilla.com> <921bb11003021733neec7927o4a9077619e0e631c@mail.gmail.com> <4B8EEF47.9000007@mozilla.com> <921bb11003031602k348e60d5q48d5b34d9189d3b1@mail.gmail.com> <4B8EFF31.8050006@mozilla.com> Message-ID: <921bb11003031638y44df4ff8wf2028267d7404386@mail.gmail.com> On Wed, Mar 3, 2010 at 4:30 PM, Vladimir Vukicevic wrote: > On 3/3/2010 4:02 PM, Kenneth Russell wrote: >> >> On Wed, Mar 3, 2010 at 3:22 PM, Vladimir Vukicevic >> ?wrote: >> >>> >>> On 3/2/2010 5:33 PM, Kenneth Russell wrote: >>> >>>> >>>> On Tue, Mar 2, 2010 at 5:31 PM, Vladimir Vukicevic >>>> ?wrote: >>>> >>>> >>>>> >>>>> Thanks Ken -- I forgot to update the original spec when I made the >>>>> change >>>>> in >>>>> the typedarray spec. ?I'm going to check the typed array spec into the >>>>> webgl >>>>> svn repo for easier tracking/updating; need to add the WebIDL back and >>>>> to >>>>> add the stream reader bits as an appendix. >>>>> >>>>> >>>> >>>> That's great -- was hoping we could collaborate on editing the typed >>>> array >>>> spec. >>>> >>>> >>> >>> Just checked it in, along with WebIDL added back and a section on the >>> DataSream API. ?Ken, please update if this isn't the current version of >>> the >>> DataStream proposal -- I took it from your earlier email. >>> >>> >>> https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/TypedArray-spec.html >>> >> >> Based on earlier feedback from Chris Marrin, the email I sent to >> es-discuss had this phrased as a DataArray rather than a DataStream. >> I've updated the TypedArray spec appropriately. >> >> I think we should introduce a base class (TypedArray?) from which the >> others can derive, and which can hold the read-only attributes for the >> buffer, length, etc. >> > > Yeah, I ended up taking that out because without the interfaces/inheritance > it didn't really seem make sense to have it -- I was trying to phrase things > in purely ecmascript terms. ?It makes sense to have it for WebIDL though, so > I can add it back in. ?Naming is going to be slightly odd though -- I don't > really like "DataArray", because it's not really an array... DataReader > might be more appropriate, but that doesn't cover the writing case. ?The > base interface would also be weird as TypedArray if it was shared between > the two, but maybe "ArrayBufferView" would cover both cases as the base > interface name? ArrayBufferView sounds fine as the base interface name. I'm open to suggestions for another name for the current DataArray interface, though I think it's reasonable given its semantics and symmetry with the other names. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Wed Mar 3 23:55:41 2010 From: ced...@ (Cedric Vivier) Date: Thu, 4 Mar 2010 15:55:41 +0800 Subject: [Public WebGL] A replacement or changing for setInterval? In-Reply-To: <4B8E1463.9070202@mozilla.com> References: <08D30173-45ED-409E-8E98-1724B8FB0B05@apple.com> <4B8E1463.9070202@mozilla.com> Message-ID: On Wed, Mar 3, 2010 at 3:48 PM, Vladimir Vukicevic wrote: > I am in general all for something like this, but as Chris said, it really > isn't WebGL-specific. There are many non-webgl use cases where something > like this would be desired, so I'd suggest that this suggestion be made as a > generic HTML API, and implemented on the toplevel DOM global object. I > think it would be a good companion to existing setTimeout/setInterval > methods for a wide variety of use cases. > > The more generic the better indeed. You're thinking of something like "bool isElementVisible(Element)" (or isElementShown to avoid confusion CSS visibility only) on HTMLDocument? Which group is most appropriate for such a proposal? Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From joh...@ Thu Mar 4 07:45:50 2010 From: joh...@ (Johannes Behr) Date: Thu, 4 Mar 2010 16:45:50 +0100 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> Message-ID: On 3 Mar 2010, at 00:44, Kenneth Russell wrote: > On Wed, Feb 24, 2010 at 12:06 PM, Chris Marrin wrote: >> >> On Feb 23, 2010, at 5:59 PM, Mark Callow wrote: >> >>> Hi Chris, >>> >>> On 24/02/2010 07:25, Chris Marrin wrote: >>>> On Feb 22, 2010, at 6:21 PM, Mark Callow wrote: >>>> >>>> >>>>> ... >>>>> I agree with Ken that adding support to WebGL for deciphering HTMLImages >>>>> that are PNG files to automatically determine the format to use for >>>>> TexImage2D is an enhancement. A query will clearly need to be part of >>>>> this enhancement. >>>>> >>>> >>>> We don't need queries for this. We simply need to know what the resultant internal format is for each type of image loaded. As I mentioned in other responses, adding a format param would provide this. >>>> >>> >>> "Query will clearly (be) need(ed)" was predicated on "automatically >>> determine the format". If you add a format specifier to the TexImage2D >>> that accepts an HTMLImage then I completely agree a query is not needed. >>> We had the same problem vis-a-vis one-channel luminance vs. alpha when >>> loading PNG files in M3G. We added a format parameter there too. >>> >>> When writing the spec. for this format parameter bear in mind that OGL >>> ES does not support internal format conversions. Therefore perhaps you >>> should throw an exception if, e.g. the app. tries to load a one-channel >>> PNG image as RGB. In other words require that the specified format match >>> the HTMLImage contents. >> >> >> Right, anything we do would have to be done with client side conversion. For instance, we could specify a format of RGB and pass in a 1 channel PNG as long as we convert it to RGB on the client and then send it in. We just have to have a table showing the conversions. > > What is the consensus on what we should do here? As I see it, for > programmer convenience we want to leave the following existing > texImage2D variant: > > void texImage2D(in GLenum target, in GLint level, in > HTMLImageElement image, in optional GLboolean flipY, in optional > GLboolean asPremultipliedAlpha); > > So the most we should do is add the following overloading: > > void texImage2D(in GLenum target, in GLint level, in GLenum > internalformat, in HTMLImageElement image, in optional GLboolean > flipY, in optional GLboolean asPremultipliedAlpha); Even so it would be nice and helpful in general it does not help in our case. We really need to query the "native" format of the image. It's not only needed for the X3D lighting model but we believe that any render system which does sorting for alpha-blending would love to know if e.g. the image has an alpha channel or not. We still are not sure if this should be a WebGL or HTML functionality. But, logically, HTMLImageElement should have this function. regards johannes > > I have some concerns about adding this API at the present time. > > 1. It will have to be well tested, meaning that we will have to write > test cases for loading ALPHA, LUMINANCE, and LUMINANCE_ALPHA textures > from images. > 2. Without a query API on HTMLImageElement to determine the "native" > format for an image it is not clear that it will solve X3D's problem > in particular. > 3. There is already a lot of work that needs to be done to make the > existing WebGL implementations compliant to the current version of the > spec. > > I think we should defer adding this API until the revision of the spec > following 1.0. Does anyone have any comments or feel strongly that it > should be added to version 1.0? If not, then we can file an RFE on the > Khronos Bugzilla to add it later. > > -Ken > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > -- Dr. Johannes Behr Leiter Projektbereich VR Fraunhofer-Institut f?r Graphische Datenverarbeitung IGD Fraunhoferstr. 5 | 64283 Darmstadt | Germany Tel +49 6151 155-510 | Fax +49 6151 155-196 johannes.behr...@ | www.igd.fraunhofer.de ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From gma...@ Thu Mar 4 11:00:58 2010 From: gma...@ (Gregg Tavares) Date: Thu, 4 Mar 2010 11:00:58 -0800 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> Message-ID: On Thu, Mar 4, 2010 at 7:45 AM, Johannes Behr < johannes.behr...@> wrote: > > On 3 Mar 2010, at 00:44, Kenneth Russell wrote: > > > On Wed, Feb 24, 2010 at 12:06 PM, Chris Marrin > wrote: > >> > >> On Feb 23, 2010, at 5:59 PM, Mark Callow wrote: > >> > >>> Hi Chris, > >>> > >>> On 24/02/2010 07:25, Chris Marrin wrote: > >>>> On Feb 22, 2010, at 6:21 PM, Mark Callow wrote: > >>>> > >>>> > >>>>> ... > >>>>> I agree with Ken that adding support to WebGL for deciphering > HTMLImages > >>>>> that are PNG files to automatically determine the format to use for > >>>>> TexImage2D is an enhancement. A query will clearly need to be part of > >>>>> this enhancement. > >>>>> > >>>> > >>>> We don't need queries for this. We simply need to know what the > resultant internal format is for each type of image loaded. As I mentioned > in other responses, adding a format param would provide this. > >>>> > >>> > >>> "Query will clearly (be) need(ed)" was predicated on "automatically > >>> determine the format". If you add a format specifier to the TexImage2D > >>> that accepts an HTMLImage then I completely agree a query is not > needed. > >>> We had the same problem vis-a-vis one-channel luminance vs. alpha when > >>> loading PNG files in M3G. We added a format parameter there too. > >>> > >>> When writing the spec. for this format parameter bear in mind that OGL > >>> ES does not support internal format conversions. Therefore perhaps you > >>> should throw an exception if, e.g. the app. tries to load a one-channel > >>> PNG image as RGB. In other words require that the specified format > match > >>> the HTMLImage contents. > >> > >> > >> Right, anything we do would have to be done with client side conversion. > For instance, we could specify a format of RGB and pass in a 1 channel PNG > as long as we convert it to RGB on the client and then send it in. We just > have to have a table showing the conversions. > > > > What is the consensus on what we should do here? As I see it, for > > programmer convenience we want to leave the following existing > > texImage2D variant: > > > > void texImage2D(in GLenum target, in GLint level, in > > HTMLImageElement image, in optional GLboolean flipY, in optional > > GLboolean asPremultipliedAlpha); > > > > So the most we should do is add the following overloading: > > > > void texImage2D(in GLenum target, in GLint level, in GLenum > > internalformat, in HTMLImageElement image, in optional GLboolean > > flipY, in optional GLboolean asPremultipliedAlpha); > > Even so it would be nice and helpful in general it does not > help in our case. > > We really need to query the "native" format of the image. > > It's not only needed for the X3D lighting model but > we believe that any render system which does sorting > for alpha-blending would love to know if e.g. the image > has an alpha channel or not. > > The format of the image does not tell you how how it's used. Just because I have an RGBA image doesn't mean A is used for alpha or even that R is red. Shaders can use any channel to do anything they want with the data. An alpha only texture might be used as a lightmap, a heightmap, or any number of other things. Even if I know in my pipeline all RGB and RGBA images will be used as colormaps (vs normalmaps or normalmaps with height or gmaps) even that's not enough to decide anything based on if A is there not. For example deciding that I want blending or sorting on if A exists and not if A does not exist doesn't help if my shader multiplies the color by 1,1,1,0.5 Any 3d format that uses the image format to decide how to display something is horribly broken. > We still are not sure if this should be a WebGL or HTML > functionality. > But, logically, HTMLImageElement should have this function. > > regards > johannes > > > > > > > I have some concerns about adding this API at the present time. > > > > 1. It will have to be well tested, meaning that we will have to write > > test cases for loading ALPHA, LUMINANCE, and LUMINANCE_ALPHA textures > > from images. > > 2. Without a query API on HTMLImageElement to determine the "native" > > format for an image it is not clear that it will solve X3D's problem > > in particular. > > 3. There is already a lot of work that needs to be done to make the > > existing WebGL implementations compliant to the current version of the > > spec. > > > > I think we should defer adding this API until the revision of the spec > > following 1.0. Does anyone have any comments or feel strongly that it > > should be added to version 1.0? If not, then we can file an RFE on the > > Khronos Bugzilla to add it later. > > > > -Ken > > > > ----------------------------------------------------------- > > You are currently subscribe to public_webgl...@ > > To unsubscribe, send an email to majordomo...@ with > > the following command in the body of your email: > > > > -- > Dr. Johannes Behr > Leiter Projektbereich VR > > Fraunhofer-Institut f?r Graphische Datenverarbeitung IGD > Fraunhoferstr. 5 | 64283 Darmstadt | Germany > Tel +49 6151 155-510 | Fax +49 6151 155-196 > johannes.behr...@ | www.igd.fraunhofer.de > > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joh...@ Thu Mar 4 12:04:54 2010 From: joh...@ (Johannes Behr) Date: Thu, 4 Mar 2010 21:04:54 +0100 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> Message-ID: On 4 Mar 2010, at 20:00, Gregg Tavares wrote: > > > On Thu, Mar 4, 2010 at 7:45 AM, Johannes Behr wrote: > > On 3 Mar 2010, at 00:44, Kenneth Russell wrote: > > > On Wed, Feb 24, 2010 at 12:06 PM, Chris Marrin wrote: > >> > >> On Feb 23, 2010, at 5:59 PM, Mark Callow wrote: > >> > >>> Hi Chris, > >>> > >>> On 24/02/2010 07:25, Chris Marrin wrote: > >>>> On Feb 22, 2010, at 6:21 PM, Mark Callow wrote: > >>>> > >>>> > >>>>> ... > >>>>> I agree with Ken that adding support to WebGL for deciphering HTMLImages > >>>>> that are PNG files to automatically determine the format to use for > >>>>> TexImage2D is an enhancement. A query will clearly need to be part of > >>>>> this enhancement. > >>>>> > >>>> > >>>> We don't need queries for this. We simply need to know what the resultant internal format is for each type of image loaded. As I mentioned in other responses, adding a format param would provide this. > >>>> > >>> > >>> "Query will clearly (be) need(ed)" was predicated on "automatically > >>> determine the format". If you add a format specifier to the TexImage2D > >>> that accepts an HTMLImage then I completely agree a query is not needed. > >>> We had the same problem vis-a-vis one-channel luminance vs. alpha when > >>> loading PNG files in M3G. We added a format parameter there too. > >>> > >>> When writing the spec. for this format parameter bear in mind that OGL > >>> ES does not support internal format conversions. Therefore perhaps you > >>> should throw an exception if, e.g. the app. tries to load a one-channel > >>> PNG image as RGB. In other words require that the specified format match > >>> the HTMLImage contents. > >> > >> > >> Right, anything we do would have to be done with client side conversion. For instance, we could specify a format of RGB and pass in a 1 channel PNG as long as we convert it to RGB on the client and then send it in. We just have to have a table showing the conversions. > > > > What is the consensus on what we should do here? As I see it, for > > programmer convenience we want to leave the following existing > > texImage2D variant: > > > > void texImage2D(in GLenum target, in GLint level, in > > HTMLImageElement image, in optional GLboolean flipY, in optional > > GLboolean asPremultipliedAlpha); > > > > So the most we should do is add the following overloading: > > > > void texImage2D(in GLenum target, in GLint level, in GLenum > > internalformat, in HTMLImageElement image, in optional GLboolean > > flipY, in optional GLboolean asPremultipliedAlpha); > > Even so it would be nice and helpful in general it does not > help in our case. > > We really need to query the "native" format of the image. > > It's not only needed for the X3D lighting model but > we believe that any render system which does sorting > for alpha-blending would love to know if e.g. the image > has an alpha channel or not. > > > The format of the image does not tell you how how it's used. Just because I have an RGBA image doesn't mean A is used for alpha or even that R is red. Shaders can use any channel to do anything they want with the data. An alpha only texture might be used as a lightmap, a heightmap, or any number of other things. Even if I know in my pipeline all RGB and RGBA images will be used as colormaps (vs normalmaps or normalmaps with height or gmaps) even that's not enough to decide anything based on if A is there not. For example deciding that I want blending or sorting on if A exists and not if A does not exist doesn't help if my shader multiplies the color by 1,1,1,0.5 You are right. No fix-function pipeline and therefore alpha can be your particle-simulation velocity factor or whatever. I just know 2-3 (open and closed) scene-graphs which have some kind of fallback "auto"-mode to get the "transparent" objects. But this is not important at this point. > > Any 3d format that uses the image format to decide how to display something is horribly broken. I agree, that it would be a horrible idee for a complete and expressive scene-graph However, the standard tries to make it "easy for the user" and people at that time thought it should be great if the system would automatically modulate gray-scale images with the diffuse-color. regards johannes > > > We still are not sure if this should be a WebGL or HTML > functionality. > But, logically, HTMLImageElement should have this function. > > regards > johannes > > > > > > > I have some concerns about adding this API at the present time. > > > > 1. It will have to be well tested, meaning that we will have to write > > test cases for loading ALPHA, LUMINANCE, and LUMINANCE_ALPHA textures > > from images. > > 2. Without a query API on HTMLImageElement to determine the "native" > > format for an image it is not clear that it will solve X3D's problem > > in particular. > > 3. There is already a lot of work that needs to be done to make the > > existing WebGL implementations compliant to the current version of the > > spec. > > > > I think we should defer adding this API until the revision of the spec > > following 1.0. Does anyone have any comments or feel strongly that it > > should be added to version 1.0? If not, then we can file an RFE on the > > Khronos Bugzilla to add it later. > > > > -Ken > > > > ----------------------------------------------------------- > > You are currently subscribe to public_webgl...@ > > To unsubscribe, send an email to majordomo...@ with > > the following command in the body of your email: > > > > -- > Dr. Johannes Behr > Leiter Projektbereich VR > > Fraunhofer-Institut f?r Graphische Datenverarbeitung IGD > Fraunhoferstr. 5 | 64283 Darmstadt | Germany > Tel +49 6151 155-510 | Fax +49 6151 155-196 > johannes.behr...@ | www.igd.fraunhofer.de > > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > -------- Dr.-Ing. Johannes Behr tel: +49-6151-155-510 Fraunhoferstr. 5 fax: +49-6151-155-196 D-64283 Darmstadt skype: johannesbehr Germany web: www.igd.fhg.de/www/igd-a4/ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cbu...@ Thu Mar 4 15:42:54 2010 From: cbu...@ (Len Bullard) Date: Thu, 4 Mar 2010 17:42:54 -0600 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: Message-ID: So I understand, please, how does automatic gray-scale modulation with the diffuse-color make it easy for the user? Is the user an author? len -----Original Message----- From: owner-public_webgl...@ [mailto:owner-public_webgl...@] On Behalf Of Johannes Behr Sent: Thursday, March 04, 2010 2:05 PM To: Gregg Tavares Cc: Kenneth Russell; Chris Marrin; public webgl Subject: Re: [Public WebGL] Retrieving number of texture channels However, the standard tries to make it "easy for the user" and people at that time thought it should be great if the system would automatically modulate gray-scale images with the diffuse-color. ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From vla...@ Thu Mar 4 16:58:21 2010 From: vla...@ (Vladimir Vukicevic) Date: Thu, 04 Mar 2010 16:58:21 -0800 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> Message-ID: <4B90572D.7070309@mozilla.com> (I've read through most of this thread, but some comments that are somewhat orthogonal to the discussion.) WebGL relies on the browser for image loading. In theory it's possible to load binary data without this (or at least, will be soon) -- for example, if you were able to directly request foo.tga and obtain its binary bits as an ArrayBuffer, you could parse the TGA header in JS and hand off the bits directly to WebGL. There's a bit of small glue missing to allow this, but this functionality should show up quickly, almost certainly before WebGL ships in a release. That doesn't help for more complex formats like png and jpeg though, because it would be silly to do that when the browser already has native support (though certainly possible). But, in this case, the browser's native support is really geared towards the current use of images in HTML; for example, for PNGs, we expand out all images to 32-bit ARGB with premultiplied alpha because that's what we want as an input format for compositing. Now, there's nothing that prevents us from storing the original format; we just haven't had a need to do that so far. For example, I can see something like: var img = new Image(); img.keepOriginalFormat = true; img.src = "http://..../foo.png"; and then having accessors like img.channelCount, img.channelSize, img.channelFormat, etc. If that image were ever to be rendered directly, we'd could do the conversion at render time. But, as I said, this hasn't been needed on the web so far, but I think we do have a valid use case for it here. I'd rather see a proposal evolve in this direction rather than any conversion at texImage2D time, because doing that will likely require browsers to not optimize for their compositing format for /any/ images, and to understand various formats anyway, without surfacing that data to content script. (And possibly introducing a double conversion if not, e.g. from 1-channel to rgb and back at texImage2D time.) - Vlad ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From yvo...@ Thu Mar 4 22:54:07 2010 From: yvo...@ (Yvonne Jung) Date: Fri, 5 Mar 2010 07:54:07 +0100 (CET) Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: <4B90572D.7070309@mozilla.com> References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> <4B90572D.7070309@mozilla.com> Message-ID: <33380.79.211.98.104.1267772047.squirrel@webmail.igd.fraunhofer.de> Am Fr, 5.03.2010, 01:58, schrieb Vladimir Vukicevic: > (I've read through most of this thread, but some comments that are > somewhat orthogonal to the discussion.) > > WebGL relies on the browser for image loading. In theory it's possible > to load binary data without this (or at least, will be soon) -- for > example, if you were able to directly request foo.tga and obtain its > binary bits as an ArrayBuffer, you could parse the TGA header in JS and > hand off the bits directly to WebGL. There's a bit of small glue > missing to allow this, but this functionality should show up quickly, > almost certainly before WebGL ships in a release. > > That doesn't help for more complex formats like png and jpeg though, > because it would be silly to do that when the browser already has native > support (though certainly possible). But, in this case, the browser's > native support is really geared towards the current use of images in > HTML; for example, for PNGs, we expand out all images to 32-bit ARGB > with premultiplied alpha because that's what we want as an input format > for compositing. > > Now, there's nothing that prevents us from storing the original format; > we just haven't had a need to do that so far. For example, I can see > something like: > > var img = new Image(); > img.keepOriginalFormat = true; > img.src = "http://..../foo.png"; > > and then having accessors like img.channelCount, img.channelSize, > img.channelFormat, etc. If that image were ever to be rendered > directly, we'd could do the conversion at render time. But, as I said, > this hasn't been needed on the web so far, but I think we do have a > valid use case for it here. I'd rather see a proposal evolve in this > direction rather than any conversion at texImage2D time, because doing > that will likely require browsers to not optimize for their compositing > format for /any/ images, and to understand various formats anyway, > without surfacing that data to content script. (And possibly > introducing a double conversion if not, e.g. from 1-channel to rgb and > back at texImage2D time.) Great :-) That is exactly what we were looking for. And I think the proposal is useful not only for our use cases but also when thinking about handling some arbitrary -- and probably also fp precision -- textures, where a conversion to standard 8bit per channel rgba would be simply wrong. Bye Yvonne > > - Vlad > > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > --- Yvonne Jung Fraunhofer-IGD | Tel.: ++49-6151-155-290 Fraunhoferstr. 5 | Fax.: ++49-6151-155-196 64283 Darmstadt | email: yvonne.jung...@ Germany | http://www.igd.fhg.de/igd-a4 ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From joh...@ Thu Mar 4 23:25:27 2010 From: joh...@ (Johannes Behr) Date: Fri, 5 Mar 2010 08:25:27 +0100 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: References: Message-ID: <8963DFFE-1B4F-4042-B542-5D67AC660C51@igd.fraunhofer.de> The user of the standard: The application-developer. regards johannes On 5 Mar 2010, at 00:42, Len Bullard wrote: > So I understand, please, how does automatic gray-scale modulation with the > diffuse-color make it easy for the user? > > Is the user an author? > > len > > -----Original Message----- > From: owner-public_webgl...@ [mailto:owner-public_webgl...@] > On Behalf Of Johannes Behr > Sent: Thursday, March 04, 2010 2:05 PM > To: Gregg Tavares > Cc: Kenneth Russell; Chris Marrin; public webgl > Subject: Re: [Public WebGL] Retrieving number of texture channels > > However, the standard tries to make it "easy for the user" and people at > that time thought it should > be great if the system would automatically modulate gray-scale images with > the diffuse-color. > > -------- Dr.-Ing. Johannes Behr tel: +49-6151-155-510 Fraunhoferstr. 5 fax: +49-6151-155-196 D-64283 Darmstadt skype: johannesbehr Germany web: www.igd.fhg.de/www/igd-a4/ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cbu...@ Fri Mar 5 06:43:01 2010 From: cbu...@ (cbu...@) Date: Fri, 05 Mar 2010 08:43:01 -0600 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: <8963DFFE-1B4F-4042-B542-5D67AC660C51@igd.fraunhofer.de> References: <8963DFFE-1B4F-4042-B542-5D67AC660C51@igd.fraunhofer.de> Message-ID: <20100305084301.21144x44iad0wf3p@webmail.hiwaay.net> Thank you. I am assuming by application developer you mean someone writing an X3D client, for example, instead of someone using the standard to write a scene in X3D. len Quoting "Johannes Behr" : > The user of the standard: The application-developer. > > regards > johannes > > On 5 Mar 2010, at 00:42, Len Bullard wrote: > >> So I understand, please, how does automatic gray-scale modulation with the >> diffuse-color make it easy for the user? >> >> Is the user an author? >> >> len >> >> -----Original Message----- >> From: owner-public_webgl...@ [mailto:owner-public_webgl...@] >> On Behalf Of Johannes Behr >> Sent: Thursday, March 04, 2010 2:05 PM >> To: Gregg Tavares >> Cc: Kenneth Russell; Chris Marrin; public webgl >> Subject: Re: [Public WebGL] Retrieving number of texture channels >> >> However, the standard tries to make it "easy for the user" and people at >> that time thought it should >> be great if the system would automatically modulate gray-scale images with >> the diffuse-color. >> >> > > -------- > Dr.-Ing. Johannes Behr tel: +49-6151-155-510 > Fraunhoferstr. 5 fax: +49-6151-155-196 > D-64283 Darmstadt skype: johannesbehr > Germany web: www.igd.fhg.de/www/igd-a4/ > > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From joh...@ Fri Mar 5 07:54:31 2010 From: joh...@ (Johannes Behr) Date: Fri, 5 Mar 2010 16:54:31 +0100 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: <20100305084301.21144x44iad0wf3p@webmail.hiwaay.net> References: <8963DFFE-1B4F-4042-B542-5D67AC660C51@igd.fraunhofer.de> <20100305084301.21144x44iad0wf3p@webmail.hiwaay.net> Message-ID: <9251E5EE-F85D-42B5-85B7-D0B9563E03FA@igd.fraunhofer.de> Hi, > Thank you. I am assuming by application developer you mean someone writing an X3D client, for example, instead of someone using the standard to write a scene in X3D. No. The other way araound. A application developer uses HTML/X3D to write a actual web-application (e.g. product configurator) using a UA + X3D. best regards johannes > > len > > Quoting "Johannes Behr" : > >> The user of the standard: The application-developer. >> >> regards >> johannes >> >> On 5 Mar 2010, at 00:42, Len Bullard wrote: >> >>> So I understand, please, how does automatic gray-scale modulation with the >>> diffuse-color make it easy for the user? >>> >>> Is the user an author? >>> >>> len >>> >>> -----Original Message----- >>> From: owner-public_webgl...@ [mailto:owner-public_webgl...@] >>> On Behalf Of Johannes Behr >>> Sent: Thursday, March 04, 2010 2:05 PM >>> To: Gregg Tavares >>> Cc: Kenneth Russell; Chris Marrin; public webgl >>> Subject: Re: [Public WebGL] Retrieving number of texture channels >>> >>> However, the standard tries to make it "easy for the user" and people at >>> that time thought it should >>> be great if the system would automatically modulate gray-scale images with >>> the diffuse-color. >>> >>> >> >> -------- >> Dr.-Ing. Johannes Behr tel: +49-6151-155-510 >> Fraunhoferstr. 5 fax: +49-6151-155-196 >> D-64283 Darmstadt skype: johannesbehr >> Germany web: www.igd.fhg.de/www/igd-a4/ >> >> >> ----------------------------------------------------------- >> You are currently subscribe to public_webgl...@ >> To unsubscribe, send an email to majordomo...@ with >> the following command in the body of your email: >> >> >> > -- Dr. Johannes Behr Leiter Projektbereich VR Fraunhofer-Institut f?r Graphische Datenverarbeitung IGD Fraunhoferstr. 5 | 64283 Darmstadt | Germany Tel +49 6151 155-510 | Fax +49 6151 155-196 johannes.behr...@ | www.igd.fraunhofer.de ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cbu...@ Fri Mar 5 08:32:10 2010 From: cbu...@ (cbu...@) Date: Fri, 05 Mar 2010 10:32:10 -0600 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: <9251E5EE-F85D-42B5-85B7-D0B9563E03FA@igd.fraunhofer.de> References: <8963DFFE-1B4F-4042-B542-5D67AC660C51@igd.fraunhofer.de> <20100305084301.21144x44iad0wf3p@webmail.hiwaay.net> <9251E5EE-F85D-42B5-85B7-D0B9563E03FA@igd.fraunhofer.de> Message-ID: <20100305103210.13097zq7eny1mive@webmail.hiwaay.net> Thanks for the clarification. len Quoting "Johannes Behr" : > Hi, > >> Thank you. I am assuming by application developer you mean someone >> writing an X3D client, for example, instead of someone using the >> standard to write a scene in X3D. > > No. The other way araound. > A application developer uses HTML/X3D to write a actual > web-application (e.g. product configurator) using a UA + X3D. > > best regards > johannes > > >> >> len >> >> Quoting "Johannes Behr" : >> >>> The user of the standard: The application-developer. >>> >>> regards >>> johannes >>> >>> On 5 Mar 2010, at 00:42, Len Bullard wrote: >>> >>>> So I understand, please, how does automatic gray-scale modulation with the >>>> diffuse-color make it easy for the user? >>>> >>>> Is the user an author? >>>> >>>> len >>>> >>>> -----Original Message----- >>>> From: owner-public_webgl...@ >>>> [mailto:owner-public_webgl...@] >>>> On Behalf Of Johannes Behr >>>> Sent: Thursday, March 04, 2010 2:05 PM >>>> To: Gregg Tavares >>>> Cc: Kenneth Russell; Chris Marrin; public webgl >>>> Subject: Re: [Public WebGL] Retrieving number of texture channels >>>> >>>> However, the standard tries to make it "easy for the user" and people at >>>> that time thought it should >>>> be great if the system would automatically modulate gray-scale images with >>>> the diffuse-color. >>>> >>>> >>> >>> -------- >>> Dr.-Ing. Johannes Behr tel: +49-6151-155-510 >>> Fraunhoferstr. 5 fax: +49-6151-155-196 >>> D-64283 Darmstadt skype: johannesbehr >>> Germany web: www.igd.fhg.de/www/igd-a4/ >>> >>> >>> ----------------------------------------------------------- >>> You are currently subscribe to public_webgl...@ >>> To unsubscribe, send an email to majordomo...@ with >>> the following command in the body of your email: >>> >>> >>> >> > > -- > Dr. Johannes Behr > Leiter Projektbereich VR > > Fraunhofer-Institut f?r Graphische Datenverarbeitung IGD > Fraunhoferstr. 5 | 64283 Darmstadt | Germany > Tel +49 6151 155-510 | Fax +49 6151 155-196 > johannes.behr...@ | www.igd.fraunhofer.de > > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Fri Mar 5 14:42:03 2010 From: cma...@ (Chris Marrin) Date: Fri, 05 Mar 2010 14:42:03 -0800 Subject: [Public WebGL] Adding types to signatures in detail boxes In-Reply-To: <921bb11003021521i1a6f0ad9ge9a0e357fb5b9d1a@mail.gmail.com> References: <921bb11003021521i1a6f0ad9ge9a0e357fb5b9d1a@mail.gmail.com> Message-ID: On Mar 2, 2010, at 3:21 PM, Kenneth Russell wrote: > Currently the method signatures in the (green) detail boxes throughout > the spec omit the types which are in the IDL snippets in the gray > boxes. > > This seems to have been done to follow the pattern in the Canvas spec, > but I find it annoying. In particular, it makes it very difficult to > document overloaded methods. > > I would like to make a pass through the spec and add the types (and > overloadings) from the gray boxes into the method signatures in the > green boxes. Are there any objections to my doing this? It annoys me, too. But yes it was done to match the Canvas spec (and many other W3C spec styles). If it can be done without adding too much noise, I would be all for adding types. ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Fri Mar 5 14:45:01 2010 From: cma...@ (Chris Marrin) Date: Fri, 05 Mar 2010 14:45:01 -0800 Subject: [Public WebGL] webgl canvas compositing into webpage. In-Reply-To: <7437CA81-3AFC-4B18-BFF7-7F3CECEC5DE3@microcan.nl> References: <4B833D1D.5050108@hicorp.co.jp> <4B8D651B.3020805@mozilla.com> <7437CA81-3AFC-4B18-BFF7-7F3CECEC5DE3@microcan.nl> Message-ID: <12F25AF7-5666-4EDC-AC70-D88CEB138164@apple.com> On Mar 3, 2010, at 3:13 AM, Carl van Heezik wrote: > Chris / Vlad, > > Compositing is a problem with WebGL. Its discussed before and it is caused by the premultiplied alpha. > Previous versions of Minefield had this problem, but the current version seems to work correct. > > e.g. If you use a canvas with a CSS style background-color:red and gl.clearColor(1.0, 1.0, 1.0, 0.0); > and render a green triangle with a black outline, with an alpha of 0.5. > > You get different results for different browsers. The current version of Minefield gives the result I expect, > Webkit gives a complete different (wrong) result. There is a bug on WebKit about this. It has to do with premultiplied alpha. I (or someone) will get to it soon hopefully. FWIW, I think Minefield had some incorrect rendering in this area in some cases as well. But my memory isn't too good on the issue. > > > > If I change to gl.clearColor(1.0, 1.0, 1.0, 1.0, 1.0) I get the following results. > > > > > Another test with a text div and a canvas with a background:none and z-index: 10. > The background has color:white and background-color:red z-index:0 > > > > > All tests are done on a iMac, the Minefield browser running under Parallels Windows 7. > > Please specify the correct behavior and create a conformance test. > > Best regards, > Carl van Heezik > > > > Op 2 mrt 2010, om 20:20 heeft Vladimir Vukicevic het volgende geschreven: > > On 2/23/2010 2:38 PM, Chris Marrin wrote: >> On Feb 22, 2010, at 6:27 PM, Mark Callow wrote: >> >> >>> CLAMP_TO_BORDER is not supported on OGL ES. Therefore WebGL needs to >>> specified CLAMP_TO_EDGE or you won't be able to implement on top of true >>> OpenGL ES. >>> >> >> The spec doesn't require OpenGL, or even an OpenGL-like renderer be used to do page compositing. So GLES constraints are not the issue here. But I agree with Gregg that consistency is important. So maybe we should add some non-normative text that describes the desired behavior of a page compositor? >> >> Gregg can you come up with some words about that? > > Hmm, it doesn't seem like this belongs in the WebGL spec -- how compositing of the element is done into the page is entirely within HTML and CSS, not the individual context. As far as the context is concerned, it doesn't know anything about the CSS scaling that's applied, and so can't really talk about what happens under such scaling. > > - Vlad > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Fri Mar 5 14:46:43 2010 From: cma...@ (Chris Marrin) Date: Fri, 05 Mar 2010 14:46:43 -0800 Subject: [Public WebGL] Proposal for depth and stencil FBO attachments In-Reply-To: <921bb11003031052q5802db81p978f7d14cc3a9e7e@mail.gmail.com> References: <921bb11002251128m66df4d80rab6cd127481edbbf@mail.gmail.com> <97AE520D-CF63-4CCA-9A1E-00EF7B291FE4@apple.com> <921bb11002251954y210844a4r906cac4e35582034@mail.gmail.com> <33072142-40DF-4D4A-BD80-F1FB7B48C6E5@apple.com> <921bb11002261129o4b594e98v117c3fec8ff1f76a@mail.gmail.com> <2A53AB74-3D72-4DF5-BE7F-5F0340246C5E@apple.com> <921bb11003021435o4424a443o1684f5de01ec422@mail.gmail.com> <4B8DFC5E.9010201@hicorp.co.jp> <921bb11003031052q5802db81p978f7d14cc3a9e7e@mail.gmail.com> Message-ID: <1D00192F-02C0-4512-A399-957F9D93A5CD@apple.com> On Mar 3, 2010, at 10:52 AM, Kenneth Russell wrote: > On Tue, Mar 2, 2010 at 10:06 PM, Mark Callow wrote: >> Hi Ken, >> >> I think it is good. You can remove the last sentence, replacing it with the >> word "concurrently" in the sentence before the list of combinations: >> >> "In WebGL, it is an error to concurrently attach renderbuffers to the >> following combinations of attachment points:" > > Thanks for the suggestion. Updated. This all looks really good. I'd like some input from some of the people who raised the issue at the F2F (I don't remember who that was). ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Fri Mar 5 14:52:47 2010 From: cma...@ (Chris Marrin) Date: Fri, 05 Mar 2010 14:52:47 -0800 Subject: [Public WebGL] WebGLArray slice() spec In-Reply-To: <921bb11003031638y44df4ff8wf2028267d7404386@mail.gmail.com> References: <921bb11002241511h20a9bfdcge9cfca8daf3e2e1f@mail.gmail.com> <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> <4B8DBBF2.7060609@mozilla.com> <921bb11003021733neec7927o4a9077619e0e631c@mail.gmail.com> <4B8EEF47.9000007@mozilla.com> <921bb11003031602k348e60d5q48d5b34d9189d3b1@mail.gmail.com> <4B8EFF31.8050006@mozilla.com> <921bb11003031638y44df4ff8wf2028267d7404386@mail.gmail.com> Message-ID: <781E7A19-7AD3-4F72-B58B-CCA6A0E022E1@apple.com> On Mar 3, 2010, at 4:38 PM, Kenneth Russell wrote: >> ...Yeah, I ended up taking that out because without the interfaces/inheritance >> it didn't really seem make sense to have it -- I was trying to phrase things >> in purely ecmascript terms. It makes sense to have it for WebIDL though, so >> I can add it back in. Naming is going to be slightly odd though -- I don't >> really like "DataArray", because it's not really an array... DataReader >> might be more appropriate, but that doesn't cover the writing case. The >> base interface would also be weird as TypedArray if it was shared between >> the two, but maybe "ArrayBufferView" would cover both cases as the base >> interface name? > > ArrayBufferView sounds fine as the base interface name. > > I'm open to suggestions for another name for the current DataArray > interface, though I think it's reasonable given its semantics and > symmetry with the other names. This all sounds good. I'd like to see this spec get polished (add editors, links, and contributors), get a few examples (starting with the one in the WebGL spec?) and get a link to it on the WebGL public page, just so people can start finding it. ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Fri Mar 5 15:04:57 2010 From: cma...@ (Chris Marrin) Date: Fri, 05 Mar 2010 15:04:57 -0800 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> Message-ID: On Mar 4, 2010, at 7:45 AM, Johannes Behr wrote: > > On 3 Mar 2010, at 00:44, Kenneth Russell wrote: > >> On Wed, Feb 24, 2010 at 12:06 PM, Chris Marrin wrote: >>> >>> On Feb 23, 2010, at 5:59 PM, Mark Callow wrote: >>> >>>> Hi Chris, >>>> >>>> On 24/02/2010 07:25, Chris Marrin wrote: >>>>> On Feb 22, 2010, at 6:21 PM, Mark Callow wrote: >>>>> >>>>> >>>>>> ... >>>>>> I agree with Ken that adding support to WebGL for deciphering HTMLImages >>>>>> that are PNG files to automatically determine the format to use for >>>>>> TexImage2D is an enhancement. A query will clearly need to be part of >>>>>> this enhancement. >>>>>> >>>>> >>>>> We don't need queries for this. We simply need to know what the resultant internal format is for each type of image loaded. As I mentioned in other responses, adding a format param would provide this. >>>>> >>>> >>>> "Query will clearly (be) need(ed)" was predicated on "automatically >>>> determine the format". If you add a format specifier to the TexImage2D >>>> that accepts an HTMLImage then I completely agree a query is not needed. >>>> We had the same problem vis-a-vis one-channel luminance vs. alpha when >>>> loading PNG files in M3G. We added a format parameter there too. >>>> >>>> When writing the spec. for this format parameter bear in mind that OGL >>>> ES does not support internal format conversions. Therefore perhaps you >>>> should throw an exception if, e.g. the app. tries to load a one-channel >>>> PNG image as RGB. In other words require that the specified format match >>>> the HTMLImage contents. >>> >>> >>> Right, anything we do would have to be done with client side conversion. For instance, we could specify a format of RGB and pass in a 1 channel PNG as long as we convert it to RGB on the client and then send it in. We just have to have a table showing the conversions. >> >> What is the consensus on what we should do here? As I see it, for >> programmer convenience we want to leave the following existing >> texImage2D variant: >> >> void texImage2D(in GLenum target, in GLint level, in >> HTMLImageElement image, in optional GLboolean flipY, in optional >> GLboolean asPremultipliedAlpha); >> >> So the most we should do is add the following overloading: >> >> void texImage2D(in GLenum target, in GLint level, in GLenum >> internalformat, in HTMLImageElement image, in optional GLboolean >> flipY, in optional GLboolean asPremultipliedAlpha); > > Even so it would be nice and helpful in general it does not > help in our case. > > We really need to query the "native" format of the image. > > It's not only needed for the X3D lighting model but > we believe that any render system which does sorting > for alpha-blending would love to know if e.g. the image > has an alpha channel or not. > > We still are not sure if this should be a WebGL or HTML > functionality. > But, logically, HTMLImageElement should have this function. Yeah, this doesn't look like anything that is WebGL specific. But telling the author whether or not an image has alpha isn't necessarily useful either. I can remember a case from long ago, where we asked if an image had alpha. If so, we would do a more expensive alpha blend. we had a case of an opaque image that was running slowly and sure enough it was an RGBA image with all 1's for alpha. So you have to be careful when relying on such data. It's not ideal, but you can often load an image into a Canvas 2D, do a getImageData and figure out whether or not you have alpha, and whether or not the image is black and white. This will fail if you do a cross-domain access of the image, or if the image is protected. But then you might say that any introspection into an image, even how many channels it has should be disallowed if it is protected. Regardless of X3D's current needs, I still think it's useful to have an internalformat parameter on the texImage2D calls. HTML doesn't necessarily preserve one channel images, and if you need a luminance texture, it could be the only way to do it (other than loading it as raw data). I don't think the testing adds that much burden and it would allow us to avoid browser differences in how they pass around the channels of an image. ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Fri Mar 5 15:07:48 2010 From: cma...@ (Chris Marrin) Date: Fri, 05 Mar 2010 15:07:48 -0800 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> Message-ID: <6612E9C2-4703-4300-B7C7-DEB3190B0901@apple.com> On Mar 4, 2010, at 11:00 AM, Gregg Tavares wrote: > ...The format of the image does not tell you how how it's used. Just because I have an RGBA image doesn't mean A is used for alpha or even that R is red. Shaders can use any channel to do anything they want with the data. An alpha only texture might be used as a lightmap, a heightmap, or any number of other things. Even if I know in my pipeline all RGB and RGBA images will be used as colormaps (vs normalmaps or normalmaps with height or gmaps) even that's not enough to decide anything based on if A is there not. For example deciding that I want blending or sorting on if A exists and not if A does not exist doesn't help if my shader multiplies the color by 1,1,1,0.5 > > Any 3d format that uses the image format to decide how to display something is horribly broken. Right, if we add a texImage2D variant that takes internalformat, the rule should be that the form that doesn't take internalformat behaves like the variant that does with an internalformat of RGB (or some consistent value we agree on). That way you always know what kind of image you are loading independent of the source format. ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Fri Mar 5 15:13:01 2010 From: cma...@ (Chris Marrin) Date: Fri, 05 Mar 2010 15:13:01 -0800 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: <4B90572D.7070309@mozilla.com> References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> <4B90572D.7070309@mozilla.com> Message-ID: <66A65B0A-B6FB-454C-AF77-A0B48F5A53ED@apple.com> On Mar 4, 2010, at 4:58 PM, Vladimir Vukicevic wrote: > (I've read through most of this thread, but some comments that are somewhat orthogonal to the discussion.) > > WebGL relies on the browser for image loading. In theory it's possible to load binary data without this (or at least, will be soon) -- for example, if you were able to directly request foo.tga and obtain its binary bits as an ArrayBuffer, you could parse the TGA header in JS and hand off the bits directly to WebGL. There's a bit of small glue missing to allow this, but this functionality should show up quickly, almost certainly before WebGL ships in a release. > > That doesn't help for more complex formats like png and jpeg though, because it would be silly to do that when the browser already has native support (though certainly possible). But, in this case, the browser's native support is really geared towards the current use of images in HTML; for example, for PNGs, we expand out all images to 32-bit ARGB with premultiplied alpha because that's what we want as an input format for compositing. > > Now, there's nothing that prevents us from storing the original format; we just haven't had a need to do that so far. For example, I can see something like: > > var img = new Image(); > img.keepOriginalFormat = true; > img.src = "http://..../foo.png"; > > and then having accessors like img.channelCount, img.channelSize, img.channelFormat, etc. If that image were ever to be rendered directly, we'd could do the conversion at render time. But, as I said, this hasn't been needed on the web so far, but I think we do have a valid use case for it here. I'd rather see a proposal evolve in this direction rather than any conversion at texImage2D time, because doing that will likely require browsers to not optimize for their compositing format for /any/ images, and to understand various formats anyway, without surfacing that data to content script. (And possibly introducing a double conversion if not, e.g. from 1-channel to rgb and back at texImage2D time.) I don't think the original format is important enough in sufficient cases to make the above API useful. It just so happens that X3D uses the source format to determine what type of texture will be loaded. But I don't think we should follow that technique. It can lead to browser inconsistencies. If you had to pass (implicitly or explicitly) the desired internal format to texImage2D, you'd need a converter to and from each of the supported formats. There aren't that many supported formats in GLES, so the table of conversions is not large. So I think we should do it and never rely on the source format to determine the type of texture we load. ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From joe...@ Sat Mar 6 08:06:49 2010 From: joe...@ (Joe D Williams) Date: Sat, 6 Mar 2010 08:06:49 -0800 Subject: [Public WebGL] colorspace References: <921bb11002241511h20a9bfdcge9cfca8daf3e2e1f@mail.gmail.com> <96819DB5-85EA-45E1-91C7-EADE0462CB12@apple.com> <921bb11003021508o42b9c48dq2f729efe2e0bde96@mail.gmail.com> <4B8DBBF2.7060609@mozilla.com> <921bb11003021733neec7927o4a9077619e0e631c@mail.gmail.com> <4B8EEF47.9000007@mozilla.com> <921bb11003031602k348e60d5q48d5b34d9189d3b1@mail.gmail.com> <4B8EFF31.8050006@mozilla.com> <921bb11003031638y44df4ff8wf2028267d7404386@mail.gmail.com> <781E7A19-7AD3-4F72-B58B-CCA6A0E022E1@apple.com> Message-ID: <2A70E727DD9440CC8BA84BD172FC2031@joe1446a4150a8> Hi Chris and All, What is "colorspace" of WebGL? Thanks and Best Regards, Joe ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Sun Mar 7 10:30:07 2010 From: ced...@ (Cedric Vivier) Date: Mon, 8 Mar 2010 02:30:07 +0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) Message-ID: Hi everyone! As we all know, the less draw calls and render state changes the better the performance, offloading calculations to the GPU is also a big win usually; both former optimizations are particularly true with WebGL where JS<->native calls overhead can be significant and JS math performance is not as good as native code obviously. Geometry instancing is a popular rendering technique that allows very efficient drawing of objects multiple times through the re-use of vertex data with only one draw call as well as enabling easy offloading of per-instance transformations/calculations to vertex shaders. Originally introduced as an OpenGL 2.0+ extension GL_EXT_draw_instanced years ago, instancing support has been added in core OpenGL 3.1+ and D3D9+ has equivalent support. Of course WebGL is largely inspired by OpenGL ES, which does not support instancing (as of 2.0). However when support is not available, it is possible to implement it in software, by looping regular drawArrays/drawElements for each instance after incrementing an uniform instance index (technique known as pseudo instancing). I propose therefore to add two methods to the WebGL context: void drawArraysInstanced(in GLenum mode, in GLint first, in GLsizei count, in GLsizei primcount) void drawElementsInstanced(in GLenum mode, in GLsizei count, in GLenum type, in GLsizeiptr offset, in GLsizei primcount) They have the same signature as drawArrays/drawElements except `primcount' added as last argument. As a proof of concept, I've implemented this proposal on Firefox. Demo and patch available at http://neonux.com/webgl/instancing.html On the simple demo above, with native pseudo instancing we get nice 20% speedup compared to the JS-based pseudo instancing shim, when hardware instancing is available we get a ridiculously awesome _23x speedup_, oh the possibilities! (hello dense forests, crowds, complex particle systems, whatever) Which means: - with no hardware support [as is the case on OpenGL ES 2.0] this enables more complex scenes thanks to faster pseudo instancing implementation than what is possible with JavaScript (no overhead of at least 2x instances JS<->native calls + checks at every instance). - with hardware support, as it is the case on most WebGL-capable laptop/desktop GPUs (and likely in a future version of OpenGL ES or an ES extension?) this addition enables WebGL to render scenes that are _much_ more complex. - in both cases, it provides an easy known API to the developer who does not have to implement its own pseudo-instancing replacement that could never hope to be hardware-accelerated. For the reasons cited above, I believe this addition, though a slight deviation from ES 2.0 (but not from OpenGL in general), would be very valuable to add in WebGL. A short paragraph about it would be added in the "Differences from OpenGL ES 2.0" section. Opinions? Regards, [references] http://en.wikipedia.org/wiki/Geometry_instancing http://www.opengl.org/registry/specs/EXT/draw_instanced.txt OpenGL 3.1 spec (no html doc available on Khronos website?) http://msdn.microsoft.com/en-us/library/ee418549%28VS.85%29.aspx -------------- next part -------------- An HTML attachment was scrubbed... URL: From lee...@ Sun Mar 7 10:47:13 2010 From: lee...@ (Lee Sandberg) Date: Sun, 7 Mar 2010 19:47:13 +0100 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: References: Message-ID: <9372424f1003071047i258edd07v19a3d74939afb2e8@mail.gmail.com> I like it. I have massive crowds stuff that use it in DirectX/OpenGL. So if we can get if for webGL that would be really nice. Stream out and geometry shaders would be nice as well since stream out is used for hardware occlusion for instanced objects... Regards On Sun, Mar 7, 2010 at 7:30 PM, Cedric Vivier wrote: > Hi everyone! > > As we all know, the less draw calls and render state changes the better the > performance, offloading calculations to the GPU is also a big win usually; > both former optimizations are particularly true with WebGL where JS<->native > calls overhead can be significant and JS math performance is not as good as > native code obviously. > > Geometry instancing is a popular rendering technique that allows very > efficient drawing of objects multiple times through the re-use of vertex > data with only one draw call as well as enabling easy offloading of > per-instance transformations/calculations to vertex shaders. > Originally introduced as an OpenGL 2.0+ extension GL_EXT_draw_instanced > years ago, instancing support has been added in core OpenGL 3.1+ and D3D9+ > has equivalent support. > > Of course WebGL is largely inspired by OpenGL ES, which does not support > instancing (as of 2.0). > However when support is not available, it is possible to implement it in > software, by looping regular drawArrays/drawElements for each instance after > incrementing an uniform instance index (technique known as pseudo > instancing). > > I propose therefore to add two methods to the WebGL context: > > void drawArraysInstanced(in GLenum mode, in GLint first, in GLsizei count, > in GLsizei primcount) > void drawElementsInstanced(in GLenum mode, in GLsizei count, in GLenum > type, in GLsizeiptr offset, in GLsizei primcount) > > They have the same signature as drawArrays/drawElements except `primcount' > added as last argument. > > > As a proof of concept, I've implemented this proposal on Firefox. > Demo and patch available at http://neonux.com/webgl/instancing.html > > On the simple demo above, with native pseudo instancing we get nice 20% > speedup compared to the JS-based pseudo instancing shim, when hardware > instancing is available we get a ridiculously awesome _23x speedup_, oh the > possibilities! (hello dense forests, crowds, complex particle systems, > whatever) > > Which means: > - with no hardware support [as is the case on OpenGL ES 2.0] this enables > more complex scenes thanks to faster pseudo instancing implementation than > what is possible with JavaScript (no overhead of at least 2x instances > JS<->native calls + checks at every instance). > - with hardware support, as it is the case on most WebGL-capable > laptop/desktop GPUs (and likely in a future version of OpenGL ES or an ES > extension?) this addition enables WebGL to render scenes that are _much_ > more complex. > - in both cases, it provides an easy known API to the developer who does > not have to implement its own pseudo-instancing replacement that could never > hope to be hardware-accelerated. > > For the reasons cited above, I believe this addition, though a slight > deviation from ES 2.0 (but not from OpenGL in general), would be very > valuable to add in WebGL. > A short paragraph about it would be added in the "Differences from OpenGL > ES 2.0" section. > > Opinions? > > Regards, > > [references] > http://en.wikipedia.org/wiki/Geometry_instancing > http://www.opengl.org/registry/specs/EXT/draw_instanced.txt > OpenGL 3.1 spec (no html doc available on Khronos website?) > http://msdn.microsoft.com/en-us/library/ee418549%28VS.85%29.aspx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joe...@ Sun Mar 7 11:21:07 2010 From: joe...@ (Joe D Williams) Date: Sun, 7 Mar 2010 11:21:07 -0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) References: Message-ID: <96977D0471234C5AB5BAA52B451CDE2E@joe1446a4150a8> > > Opinions? Great! very needed (authoring/delivery opinon). I would understand this to be great hook for abstractions, also. Like X3D DEF/USE structures, at least for geometry (or more?). Thanks and Best Regards, Joe ----- Original Message ----- From: "Cedric Vivier" To: "public webgl" Sent: Sunday, March 07, 2010 10:30 AM Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) > Hi everyone! > > As we all know, the less draw calls and render state changes the > better the > performance, offloading calculations to the GPU is also a big win > usually; > both former optimizations are particularly true with WebGL where > JS<->native > calls overhead can be significant and JS math performance is not as > good as > native code obviously. > > Geometry instancing is a popular rendering technique that allows > very > efficient drawing of objects multiple times through the re-use of > vertex > data with only one draw call as well as enabling easy offloading of > per-instance transformations/calculations to vertex shaders. > Originally introduced as an OpenGL 2.0+ extension > GL_EXT_draw_instanced > years ago, instancing support has been added in core OpenGL 3.1+ and > D3D9+ > has equivalent support. > > Of course WebGL is largely inspired by OpenGL ES, which does not > support > instancing (as of 2.0). > However when support is not available, it is possible to implement > it in > software, by looping regular drawArrays/drawElements for each > instance after > incrementing an uniform instance index (technique known as pseudo > instancing). > > I propose therefore to add two methods to the WebGL context: > > void drawArraysInstanced(in GLenum mode, in GLint first, in GLsizei > count, > in GLsizei primcount) > void drawElementsInstanced(in GLenum mode, in GLsizei count, in > GLenum type, > in GLsizeiptr offset, in GLsizei primcount) > > They have the same signature as drawArrays/drawElements except > `primcount' > added as last argument. > > > As a proof of concept, I've implemented this proposal on Firefox. > Demo and patch available at http://neonux.com/webgl/instancing.html > > On the simple demo above, with native pseudo instancing we get nice > 20% > speedup compared to the JS-based pseudo instancing shim, when > hardware > instancing is available we get a ridiculously awesome _23x speedup_, > oh the > possibilities! (hello dense forests, crowds, complex particle > systems, > whatever) > > Which means: > - with no hardware support [as is the case on OpenGL ES 2.0] this > enables > more complex scenes thanks to faster pseudo instancing > implementation than > what is possible with JavaScript (no overhead of at least 2x > instances > JS<->native calls + checks at every instance). > - with hardware support, as it is the case on most WebGL-capable > laptop/desktop GPUs (and likely in a future version of OpenGL ES or > an ES > extension?) this addition enables WebGL to render scenes that are > _much_ > more complex. > - in both cases, it provides an easy known API to the developer who > does not > have to implement its own pseudo-instancing replacement that could > never > hope to be hardware-accelerated. > > For the reasons cited above, I believe this addition, though a > slight > deviation from ES 2.0 (but not from OpenGL in general), would be > very > valuable to add in WebGL. > A short paragraph about it would be added in the "Differences from > OpenGL ES > 2.0" section. > > Opinions? > > Regards, > > [references] > http://en.wikipedia.org/wiki/Geometry_instancing > http://www.opengl.org/registry/specs/EXT/draw_instanced.txt > OpenGL 3.1 spec (no html doc available on Khronos website?) > http://msdn.microsoft.com/en-us/library/ee418549%28VS.85%29.aspx > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cal...@ Sun Mar 7 19:50:25 2010 From: cal...@ (Mark Callow) Date: Mon, 08 Mar 2010 12:50:25 +0900 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: <66A65B0A-B6FB-454C-AF77-A0B48F5A53ED@apple.com> References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> <4B90572D.7070309@mozilla.com> <66A65B0A-B6FB-454C-AF77-A0B48F5A53ED@apple.com> Message-ID: <4B947401.6040300@hicorp.co.jp> Regards -Mark On 06/03/2010 08:13, Chris Marrin wrote: > On Mar 4, 2010, at 4:58 PM, Vladimir Vukicevic wrote: > > >> ... >> >> That doesn't help for more complex formats like png and jpeg though, because it would be silly to do that when the browser already has native support (though certainly possible). But, in this case, the browser's native support is really geared towards the current use of images in HTML; for example, for PNGs, we expand out all images to 32-bit ARGB with premultiplied alpha because that's what we want as an input format for compositing. >> >> Now, there's nothing that prevents us from storing the original format; we just haven't had a need to do that so far. For example, I can see something like: >> >> var img = new Image(); >> img.keepOriginalFormat = true; >> img.src = "http://..../foo.png"; >> >> and then having accessors like img.channelCount, img.channelSize, img.channelFormat, etc. If that image were ever to be rendered directly, we'd could do the conversion at render time. But, as I said, this hasn't been needed on the web so far, but I think we do have a valid use case for it here. I'd rather see a proposal evolve in this direction rather than any conversion at texImage2D time, because doing that will likely require browsers to not optimize for their compositing format for /any/ images, and to understand various formats anyway, without surfacing that data to content script. (And possibly introducing a double conversion if not, e.g. from 1-channel to rgb and back at texImage2D time.) >> > > I don't think the original format is important enough in sufficient cases to make the above API useful. It just so happens that X3D uses the source format to determine what type of texture will be loaded. But I don't think we should follow that technique. It can lead to browser inconsistencies. If you had to pass (implicitly or explicitly) the desired internal format to texImage2D, you'd need a converter to and from each of the supported formats. There aren't that many supported formats in GLES, so the table of conversions is not large. So I think we should do it and never rely on the source format to determine the type of texture we load. > > I think Vlad's suggestion is very useful. First of all the X3D case is not primarily about deciding which texture format to load, it is used to determine which shader to run (modulate diffuse-color or not). Second it provides a way for applications to use HTMLImageElements for things other than RGB{,A} textures without causing the potential pitfalls and unnecessary data conversions described by Vlad. The application is not deciding anything _from_ the texture format; it is telling you (the implementer) how it intends using the image data, thereby allowing for a much more efficient and faster processing of its images. Regards -Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: callow_mark.vcf Type: text/x-vcard Size: 398 bytes Desc: not available URL: From car...@ Mon Mar 8 04:22:25 2010 From: car...@ (Carl van Heezik) Date: Mon, 8 Mar 2010 13:22:25 +0100 Subject: [Public WebGL] getUniformLocation Message-ID: <7D0FB933-1227-44F2-9227-62B9870EA1E7@microcan.nl> Chris, I already posted this difference between the WebKit and the Minefield implementation of WebGL as a WebKit bug, but I discovered a difference in the OpenGL ES standard and WebGL draft. So I am not sure what is right and what is wrong. If have the following snippet of code in my library. this.modelviewMatrixLocation = gl.getUniformLocation(this.program, "modelviewMatrix"); if (this.modelviewMatrixLocation >= 0) { gl.uniformMatrix4fv(this.modelviewMatrixLocation, true, gl.modelviewMatrix.m); } It checks if uniform location "modelviewMatrix" is supported by the current program and sends the "modelviewMatrix" to the graphics card if. This code works in Minefield. It is compatible with the OpenGL ES 2.0 standard. OpenGL ES 2.0 standard glGetUniformLocation returns an integer that represents the location of a specific uniform variable within a program object. name must be a null terminated string that contains no white space. name must be an active uniform variable name in program that is not a structure, an array of structures, or a subcomponent of a vector or a matrix. This function returns -1 if name does not correspond to an active uniform variable in program or if name starts with the reserved prefix "gl_". WebGL working draft getUniformLocation(program, name) (OpenGL ES 2.0 man page) Return a WebGLUniformLocation object that represents the location of a specific uniform variable within a program object. The return value is null if name does not correspond to an active uniform variable in the passed program. Comment: the link to uniformMatrix4fv in the WebGL draft is broken. In WebKit getUniformLocations returns an object in Minefield it returns an int. What is the reason to leave the OpenGL ES 2.0 standard. I personally use the OpenGL ES 2.0 Programming Guide because it is lying on my desk. I also copy and paste a lot between existing C++ code and javascript. At this time Minefield is following the OpenGL ES standard and WebKit is following the new WebGL draft that abandons the existing OpenGL ES. I vote for keeping the OpenGL ES standard but at least both implementations should work the same. Best regards, Carl van Heezik -------------- next part -------------- An HTML attachment was scrubbed... URL: From car...@ Mon Mar 8 05:11:10 2010 From: car...@ (Carl van Heezik) Date: Mon, 8 Mar 2010 14:11:10 +0100 Subject: [Public WebGL] Native implementation of common Matrix and Vector functions Message-ID: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> LS, As we all know the OpenGL ES 2.0 standard removed the Matrix functions form the API. As a result you must implement your own Matrix functions in javascript. The javascript is likely slower than a native implementation. I implemented the basic matrix functions in javascript but I think it better that these basic matrix and vector functions are developed in the browser in native code making use of SIMD on the CPU or even the GPU. I vote for a standard native implementation in the browser as part / extension of WebGL. Here is our preliminary interface. It is based on the good old OpenGL 1.1 matrix functions. Class WebGL.Matrix4 Defined in: Matrix4.js. Class Summary Constructor Attributes Constructor Name and Description WebGL.Matrix4() Construct a 4x4 matrix. Field Summary Field Attributes Field Name and Description m The float array buffer for WebGL. Method Summary Method Attributes Method Name and Description frustum(left, right, bottom, top, zNear, zFar) Multiply the matrix by a perspective matrix. invert() Compute the inverse of the matrix. loadIdentity() Replace the matrix with the identity matrix. loadMatrix(m) Replace the matrix with an arbitrary matrix. WebGL.Matrix4.multiply(mA, mB, mR) Multiply matrix A times matrix B and store the result in matrix R. multiply(v) Multiply the vector with the matrix. multMatrix(m) Multiply the matrix by an arbitrary matrix. ortho(left, right, bottom, top, zNear, zFar) Multiply the matrix by an orthographic matrix. rotate(angle, x, y, z) Multipy the matrix by a rotation matrix. scale(x, y, z) Multiply the matrix by a general scaling matrix. toString() Convert matrix to string. translate(x, y, z) Multiply the matrix by a translation matrix. transpose() Transpose this matrix. Class Detail WebGL.Matrix4() Construct a 4x4 matrix. Field Detail m The float array buffer for WebGL. Method Detail frustum(left, right, bottom, top, zNear, zFar) Multiply the matrix by a perspective matrix. Parameters: left Specify the coordinate for the left vertical clipping plane. right Specify the coordinate for the right vertical clipping plane. bottom Specify the coordinate for the bottom horizontal clipping plane. top Specify the coordinate for the top horizontal clipping plane. zNear Specify the coordinate for the near depth clipping plane. Must be positive. zFar Specify the coordinate for the far depth clipping plane. Must be positive. invert() Compute the inverse of the matrix. loadIdentity() Replace the matrix with the identity matrix. loadMatrix(m) Replace the matrix with an arbitrary matrix. Parameters: m Specifies a 4x4 matrix, which is used to replace the elements of the matrix. WebGL.Matrix4.multiply(mA, mB, mR) Multiply matrix A times matrix B and store the result in matrix R. Parameters: mA {WebGLFloatArray} matrix A mB {WebGLFloatArray} matrix B mR {WebGLFloatArray} matrix R multiply(v) Multiply the vector with the matrix. Parameters: {WebGL.Vector4} v Returns: The multiplied vector. multMatrix(m) Multiply the matrix by an arbitrary matrix. Parameters: m Specifies a 4x4 matrix that is use to multiply the matrix. ortho(left, right, bottom, top, zNear, zFar) Multiply the matrix by an orthographic matrix. Parameters: left Specify the coordinate for the left vertical clipping plane. right Specify the coordinate for the right vertical clipping plane. bottom Specify the coordinate for the bottom horizontal clipping plane. top Specify the coordinate for the top horizontal clipping plane. zNear Specify the coordinate for the near depth clipping plane. zFar Specify the coordinate for the far depth clipping plane. rotate(angle, x, y, z) Multipy the matrix by a rotation matrix. Parameters: angle Specifies the angle of rotation, in degrees. x The x coordinate of the rotation axis. y The y coordinate of the rotation axis. z The z coordinate of the rotation axis. scale(x, y, z) Multiply the matrix by a general scaling matrix. Parameters: x Specify scale factor along the x axis. y Specify scale factor along the y axis. z Specify scale factor along the z axis. {string} toString() Convert matrix to string. Returns: {string} A string representation of the matrix. translate(x, y, z) Multiply the matrix by a translation matrix. Parameters: x Specify the x coordinate of a translation vector. y Specify the y coordinate of a translation vector. z Specify the z coordinate of a translation vector. transpose() Transpose this matrix. Class WebGL.Vector2 Defined in: Vector2.js. Class Summary Constructor Attributes Constructor Name and Description WebGL.Vector2(x, y) Construct a two dimensional vector. Field Summary Field Attributes Field Name and Description x The x component of the vector. y The y component of the vector. Method Summary Method Attributes Method Name and Description add(vector) Add the components of the vectors. distance(vector) Compute the distance between two vectors. divide(scalar) Divide the components of the vector by a scalar. divideBy(scalar) Divide the components of the vector by a scalar. dot(v) Returns the scalar product of the vectors. length() Returns the length of the vector. multiply(scalar) Multiply the vector by a scalar. multiplyBy(scalar) Multiply the vector by a scalar. normalize() Makes the length of the vector 1. subtract(vector) Subtract the components of the vectors. toString() Convert vector to string. WebGL.Vector2.X_AXIS() Returns a x-axis vector. WebGL.Vector2.Y_AXIS() Returns a y-axis vector. Class Detail WebGL.Vector2(x, y) Construct a two dimensional vector. var vector = new WebGL.Vector2; vector.x = 0.0; vector.y = 1.0; var vector = new WebGL.Vector2(0.0, 1.0); Parameters: x y Field Detail {number} x The x component of the vector. Default Value: 0 {number} y The y component of the vector. Default Value: 0 Method Detail {WebGL.Vector2} add(vector) Add the components of the vectors. Parameters: {WebGL.Vector2} vector Returns: {WebGL.Vector2} The sum of the vectors. {number} distance(vector) Compute the distance between two vectors. Parameters: {WebGL.Vector2} vector Returns: {number} The distance of the vectors. {WebGL.Vector2} divide(scalar) Divide the components of the vector by a scalar. Parameters: {Number} scalar Returns: {WebGL.Vector2} The vector divided by the scalar. divideBy(scalar) Divide the components of the vector by a scalar. Parameters: {Number} scalar {number} dot(v) Returns the scalar product of the vectors. Parameters: {WebGL.Vector2} v Returns: {number} The scalar product of the vectors. {number} length() Returns the length of the vector. i.e. Math.sqrt(x * x + y * y ...). Returns: {number} The length of the vector. {WebGL.Vector2} multiply(scalar) Multiply the vector by a scalar. Parameters: {number} scalar Returns: {WebGL.Vector2} The vector multiplied by the scalar. multiplyBy(scalar) Multiply the vector by a scalar. Parameters: {number} scalar {number} normalize() Makes the length of the vector 1. Returns: {number} The previous length of the vector. {number} subtract(vector) Subtract the components of the vectors. Parameters: {WebGL.Vector2} vector Returns: {number} The difference of the vectors. {string} toString() Convert vector to string. Returns: {string} A string representation of the vector. WebGL.Vector2.X_AXIS() Returns a x-axis vector. Same as new WebGL.Vector2(1.0, 0.0); var vector = WebGL.Vector2.X_AXIS(); WebGL.Vector2.Y_AXIS() Returns a y-axis vector. Same as new WebGL.Vector2(0.0, 1.0); var vector = WebGL.Vector2.Y_AXIS(); Class WebGL.Vector3 Defined in: Vector3.js. Class Summary Constructor Attributes Constructor Name and Description WebGL.Vector3(x, y, z) Construct a three dimensional vector. Field Summary Field Attributes Field Name and Description x The x component of the vector. y The y component of the vector. z The z component of the vector. Method Summary Method Attributes Method Name and Description add(vector) Add the components of the vectors. cross(vector) Returns the vector product of the vectors. distance(vector) Compute the distance between three vectors. divide(scalar) Divide the components of the vector by a scalar. divideBy(scalar) Divide the components of the vector by a scalar. dot(v) Returns the scalar product of the vectors. length() Returns the length of the vector. multiply(scalar) Multiply the vector by a scalar. multiplyBy(scalar) Multiply the vector by a scalar. normalize() Makes the length of the vector 1. subtract(vector) Subtract the components of the vectors. toString() Convert vector to string. WebGL.Vector3.X_AXIS() Returns a x-axis vector. WebGL.Vector3.Y_AXIS() Returns a y-axis vector. WebGL.Vector3.Z_AXIS() Returns a z-axis vector. Class Detail WebGL.Vector3(x, y, z) Construct a three dimensional vector. var vector = new WebGL.Vector3; vector.x = 0.0; vector.y = 1.0; vector.z = 2.0; var vector = new WebGL.Vector3(0.0, 1.0, 3.0); Parameters: x y z Field Detail {number} x The x component of the vector. Default Value: 0 {number} y The y component of the vector. Default Value: 0 {number} z The z component of the vector. Default Value: 0 Method Detail {WebGL.Vector3} add(vector) Add the components of the vectors. Parameters: {WebGL.Vector3} vector Returns: {WebGL.Vector3} The sum of the vectors. cross(vector) Returns the vector product of the vectors. Parameters: vector Returns: The vector product of the vectors. {number} distance(vector) Compute the distance between three vectors. Parameters: {WebGL.Vector3} vector Returns: {number} The distance of the vectors. {WebGL.Vector3} divide(scalar) Divide the components of the vector by a scalar. Parameters: {Number} scalar Returns: {WebGL.Vector3} The vector divided by the scalar. divideBy(scalar) Divide the components of the vector by a scalar. Parameters: {Number} scalar {number} dot(v) Returns the scalar product of the vectors. Parameters: {WebGL.Vector3} v Returns: {number} The scalar product of the vectors. {number} length() Returns the length of the vector. i.e. Math.sqrt(x * x + y * y ...). Returns: {number} The length of the vector. {WebGL.Vector3} multiply(scalar) Multiply the vector by a scalar. Parameters: {number} scalar Returns: {WebGL.Vector3} The vector multiplied by the scalar. multiplyBy(scalar) Multiply the vector by a scalar. Parameters: {number} scalar {number} normalize() Makes the length of the vector 1. Returns: {number} The previous length of the vector. {number} subtract(vector) Subtract the components of the vectors. Parameters: {WebGL.Vector3} vector Returns: {number} The difference of the vectors. {string} toString() Convert vector to string. Returns: {string} A string representation of the vector. WebGL.Vector3.X_AXIS() Returns a x-axis vector. Same as new WebGL.Vector3(1.0, 0.0, 0.0); var vector = WebGL.Vector3.X_AXIS(); WebGL.Vector3.Y_AXIS() Returns a y-axis vector. Same as new WebGL.Vector3(0.0, 1.0, 0.0); var vector = WebGL.Vector3.Y_AXIS(); WebGL.Vector3.Z_AXIS() Returns a z-axis vector. Same as new WebGL.Vector3(0.0, 1.0, 0.0); var vector = WebGL.Vector3.Z_AXIS(); Class WebGL.Vector4 Defined in: Vector4.js. Class Summary Constructor Attributes Constructor Name and Description WebGL.Vector4(x, y, z, w) Construct a four dimensional vector. Field Summary Field Attributes Field Name and Description w The w component of the vector. x The x component of the vector. y The y component of the vector. z The z component of the vector. Method Summary Method Attributes Method Name and Description add(vector) Add the components of the vectors. divide(scalar) Divide the components of the vector by a scalar. divideBy(scalar) Divide the components of the vector by a scalar. dot(v) Returns the scalar product of the vectors. length() Returns the length of the vector. multiply(scalar) Multiply the vector by a scalar. multiplyBy(scalar) Multiply the vector by a scalar. normalize() Makes the length of the vector 1. subtract(vector) Subtract the components of the vectors. toString() Convert vector to string. WebGL.Vector4.X_AXIS() Returns a x-axis vector. WebGL.Vector4.Y_AXIS() Returns a y-axis vector. WebGL.Vector4.Z_AXIS() Returns a z-axis vector. Class Detail WebGL.Vector4(x, y, z, w) Construct a four dimensional vector. var vector = new WebGL.Vector4; vector.x = 0.0; vector.y = 1.0; vector.z = 2.0; vector.w = 2.0; var vector = new WebGL.Vector4(0.0, 1.0, 2.0, 3.0); Parameters: x y z w Field Detail {number} w The w component of the vector. Default Value: 1 {number} x The x component of the vector. Default Value: 0 {number} y The y component of the vector. Default Value: 0 {number} z The z component of the vector. Default Value: 0 Method Detail {WebGL.Vector4} add(vector) Add the components of the vectors. Parameters: {WebGL.Vector4} vector Returns: {WebGL.Vector4} The sum of the vectors. {WebGL.Vector4} divide(scalar) Divide the components of the vector by a scalar. Parameters: {Number} scalar Returns: {WebGL.Vector4} The vector divided by the scalar. divideBy(scalar) Divide the components of the vector by a scalar. Parameters: {Number} scalar {number} dot(v) Returns the scalar product of the vectors. Parameters: {WebGL.Vector4} v Returns: {number} The scalar product of the vectors. {number} length() Returns the length of the vector. i.e. Math.sqrt(x * x + y * y ...). Returns: {number} The length of the vector. {WebGL.Vector4} multiply(scalar) Multiply the vector by a scalar. Parameters: {number} scalar Returns: {WebGL.Vector4} The vector multiplied by the scalar. multiplyBy(scalar) Multiply the vector by a scalar. Parameters: {number} scalar {number} normalize() Makes the length of the vector 1. Returns: {number} The previous length of the vector. {number} subtract(vector) Subtract the components of the vectors. Parameters: {WebGL.Vector4} vector Returns: {number} The difference of the vectors. {string} toString() Convert vector to string. Returns: {string} A string representation of the vector. WebGL.Vector4.X_AXIS() Returns a x-axis vector. Same as new WebGL.Vector4(1.0, 0.0, 0.0, 1.0); var vector = WebGL.Vector4.X_AXIS(); WebGL.Vector4.Y_AXIS() Returns a y-axis vector. Same as new WebGL.Vector4(0.0, 1.0, 0.0, 1.0); var vector = WebGL.Vector4.Y_AXIS(); WebGL.Vector4.Z_AXIS() Returns a z-axis vector. Same as new WebGL.Vector4(0.0, 1.0, 0.0, 1.0); var vector = WebGL.Vector4.Z_AXIS(); -------------- next part -------------- An HTML attachment was scrubbed... URL: From ste...@ Mon Mar 8 05:21:34 2010 From: ste...@ (stephen white) Date: Mon, 8 Mar 2010 23:51:34 +1030 Subject: [Public WebGL] Native implementation of common Matrix and Vector functions In-Reply-To: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> Message-ID: On 08/03/2010, at 11:41 PM, Carl van Heezik wrote: > I think it better that these basic matrix and vector functions are > developed in the browser in native code making use of SIMD on the > CPU or even the GPU. > > I vote for a standard native implementation in the browser as part / > extension of WebGL. I agree with this, even if there's no speed improvement after bridging costs are taken into account. It is a very unfinished feeling to be gap filling such basic functionality with Javascript libraries. -- steve...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Mon Mar 8 05:28:48 2010 From: ced...@ (Cedric Vivier) Date: Mon, 8 Mar 2010 21:28:48 +0800 Subject: [Public WebGL] Native implementation of common Matrix and Vector functions In-Reply-To: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> Message-ID: On Mon, Mar 8, 2010 at 9:11 PM, Carl van Heezik wrote: > I implemented the basic matrix functions in javascript but I think it > better that these basic matrix and vector functions are developed in the > browser in native code making use of SIMD on the CPU or even the GPU. > Would be interesting to benchmark but I doubt that it would really bring much better perfs than Vlad's mjs as the benefits of SIMD might be annihilated by the cost of JS<->native transitions (stack checks, boxing/unboxing, gc etc) at every call. Also there is nothing blocking Javascript runtimes to emit SIMD or GCGPU stuff in the future when they detect SIMD patterns :) Anyways as usual if matrix calculations are the bottleneck one way to make them much faster is to offload such calculations in the shaders wherever possible. Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From car...@ Mon Mar 8 05:58:10 2010 From: car...@ (Carl van Heezik) Date: Mon, 8 Mar 2010 14:58:10 +0100 Subject: [Public WebGL] Native implementation of common Matrix and Vector functions In-Reply-To: References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> Message-ID: <35958F96-4D08-4B96-8603-DDD8C31EF0ED@microcan.nl> I agree that offloading matrix calculations to shaders is in some cases an option. But how would you implement a skinned character with a lot of bones (rotation matrices). You have to setup the rotation matrices somewhere, if you do this in the shader you must implement multiple shaders one for computing the rotation matrices and one that does the skinning. How do you get the matrices from one shader to the other. Regards, Carl Op 8 mrt 2010, om 14:28 heeft Cedric Vivier het volgende geschreven: On Mon, Mar 8, 2010 at 9:11 PM, Carl van Heezik wrote: I implemented the basic matrix functions in javascript but I think it better that these basic matrix and vector functions are developed in the browser in native code making use of SIMD on the CPU or even the GPU. Would be interesting to benchmark but I doubt that it would really bring much better perfs than Vlad's mjs as the benefits of SIMD might be annihilated by the cost of JS<->native transitions (stack checks, boxing/unboxing, gc etc) at every call. Also there is nothing blocking Javascript runtimes to emit SIMD or GCGPU stuff in the future when they detect SIMD patterns :) Anyways as usual if matrix calculations are the bottleneck one way to make them much faster is to offload such calculations in the shaders wherever possible. Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From tu...@ Mon Mar 8 07:59:22 2010 From: tu...@ (Thatcher Ulrich) Date: Mon, 8 Mar 2010 10:59:22 -0500 Subject: [Public WebGL] Native implementation of common Matrix and Vector functions In-Reply-To: References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> Message-ID: <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> On Mon, Mar 8, 2010 at 8:28 AM, Cedric Vivier wrote: > On Mon, Mar 8, 2010 at 9:11 PM, Carl van Heezik wrote: >> >> I implemented the basic matrix functions in javascript but I think it >> better that these basic matrix and vector functions are developed in the >> browser in native code making use of SIMD on the CPU or even the GPU. > > Would be interesting to benchmark but I doubt that it would really bring > much better perfs than Vlad's mjs as the benefits of SIMD might be > annihilated by the cost of JS<->native transitions (stack checks, > boxing/unboxing, gc etc) at every call. > Also there is nothing blocking Javascript runtimes to emit SIMD or GCGPU > stuff in the future when they detect SIMD patterns :) I think JS semantics demand the use of doubles, so that could be an obstacle, if what you really want is maximum speed 32-bit float math. That said, I am not in favor of this proposal -- the performance win seems doubtful because it is too fine grained. I could see a bulk linear-algebra lib based on FloatArrays but I don't think it should be hitched to WebGL. -T > Anyways as usual if matrix calculations are the bottleneck one way to make > them much faster is to offload such calculations in the shaders wherever > possible. > > Regards, > > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Mon Mar 8 08:08:23 2010 From: ced...@ (Cedric Vivier) Date: Tue, 9 Mar 2010 00:08:23 +0800 Subject: [Public WebGL] Native implementation of common Matrix and Vector functions In-Reply-To: <35958F96-4D08-4B96-8603-DDD8C31EF0ED@microcan.nl> References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <35958F96-4D08-4B96-8603-DDD8C31EF0ED@microcan.nl> Message-ID: On Mon, Mar 8, 2010 at 9:58 PM, Carl van Heezik wrote: > I agree that offloading matrix calculations to shaders is in some cases an > option. But how would you implement a skinned character with a lot of bones > (rotation matrices). You have to setup the rotation matrices somewhere, if > you do this in the shader you must implement multiple shaders one for > computing the rotation matrices and one that does the skinning. How do you > get the matrices from one shader to the other. > > I agree you cannot always offload everything to shaders, but it is likely possible to offload the most expensive stuff there. There is plenty of ways to do skinning, including not even using matrices but quaternions for bones, such could be stored in a uniform array updated at each movement etc... I assume it is in part the rationale why matrix manipulation functions have been removed from ES 2.0, the one-matrix-API-fits-all does not really make sense when having a programmable pipeline that enables "optimal" customized solutions. Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From ced...@ Mon Mar 8 08:19:52 2010 From: ced...@ (Cedric Vivier) Date: Tue, 9 Mar 2010 00:19:52 +0800 Subject: [Public WebGL] Native implementation of common Matrix and Vector functions In-Reply-To: <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> Message-ID: On Mon, Mar 8, 2010 at 11:59 PM, Thatcher Ulrich wrote: > On Mon, Mar 8, 2010 at 8:28 AM, Cedric Vivier wrote: > > Also there is nothing blocking Javascript runtimes to emit SIMD or GCGPU > > stuff in the future when they detect SIMD patterns :) > > I think JS semantics demand the use of doubles, so that could be an > obstacle, if what you really want is maximum speed 32-bit float math. > > Hmm indeed, that is a small bump on the road, but nothing too bad hopefully :) We might just need something like "use float" (similar to "use strict" of Ecmascript 5 [1]) to be able to hint clever runtimes that we only need 32-bit precision. [1] : http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From bpd...@ Mon Mar 8 08:24:36 2010 From: bpd...@ (Benjamin DeLillo) Date: Mon, 8 Mar 2010 11:24:36 -0500 Subject: [Public WebGL] Native implementation of common Matrix and Vector functions In-Reply-To: References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <35958F96-4D08-4B96-8603-DDD8C31EF0ED@microcan.nl> Message-ID: <3678bc441003080824r6c76eb13xf95b6610bd363e00@mail.gmail.com> If I may, it seems to me that there are many application level features that WebGL would benefit greatly from but which shouldn't necessarily be part of WebGL, perhaps it's time to look into organizing these, and other, features into their own standard for application oriented (as opposed to web oriented) JavaScript. Pardon me if this has been suggested in the past. -Ben On Mon, Mar 8, 2010 at 11:08 AM, Cedric Vivier wrote: > On Mon, Mar 8, 2010 at 9:58 PM, Carl van Heezik wrote: > >> I agree that offloading matrix calculations to shaders is in some cases an >> option. But how would you implement a skinned character with a lot of bones >> (rotation matrices). You have to setup the rotation matrices somewhere, if >> you do this in the shader you must implement multiple shaders one for >> computing the rotation matrices and one that does the skinning. How do you >> get the matrices from one shader to the other. >> >> > I agree you cannot always offload everything to shaders, but it is likely > possible to offload the most expensive stuff there. > There is plenty of ways to do skinning, including not even using matrices > but quaternions for bones, such could be stored in a uniform array updated > at each movement etc... > I assume it is in part the rationale why matrix manipulation functions have > been removed from ES 2.0, the one-matrix-API-fits-all does not really make > sense when having a programmable pipeline that enables "optimal" customized > solutions. > > Regards, > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vla...@ Mon Mar 8 12:33:22 2010 From: vla...@ (Vladimir Vukicevic) Date: Mon, 08 Mar 2010 12:33:22 -0800 Subject: [Public WebGL] typed array float-to-int conversion Message-ID: <4B955F12.3000009@mozilla.com> The typed array spec currently has no discussion regarding how values are converted from one type to another, especially on assignment. We have language stating that a "C-style cast" is used, but I think that in the case of float-to-int conversion this needs to be defined more fully, at least for the case of NaN/Infinity/etc. JS states that when converting double-to-int (e.g. when doing (1/0)>>0), Nan, +/-Inf, +/-0, and I believe > 2^(32+52) all convert to 0. But beyond that, there are more requirements when the value is >= 2^32 -- it's supposed to be fmod(val, 2^32). I think we should explicitly specify that the conversion is to 0 for NaN, +/-Inf, and > 2^(32+52) because that can be done quickly using an exponent comparison. (This arose because on x86, the SSE cvtsd2si opcode places 0x80000000 in the integer register, and compilers seem to generate the double-to-int conversion differently on Mac compared to Linux and Windows.) Not sure if we need to say anything for the other cases, but maybe for consistency, we need to state that all float to int conversions need to behave as if they were converted to an ECMA int32 or uint32 first, and then converted to a possibly narrower integer type. - Vlad ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From van...@ Mon Mar 8 13:02:53 2010 From: van...@ (Vangelis Kokkevis) Date: Mon, 8 Mar 2010 13:02:53 -0800 Subject: [Public WebGL] getUniformLocation In-Reply-To: <7D0FB933-1227-44F2-9227-62B9870EA1E7@microcan.nl> References: <7D0FB933-1227-44F2-9227-62B9870EA1E7@microcan.nl> Message-ID: <95c509b71003081302h15f0a9d1q4a2df3b50feaa795@mail.gmail.com> On Mon, Mar 8, 2010 at 4:22 AM, Carl van Heezik wrote: > Chris, > > I already posted this difference between the WebKit and the > Minefield implementation of WebGL as a WebKit bug, but I discovered a > difference in the OpenGL ES standard and WebGL draft. So I am not sure what > is right and what is wrong. > > If have the following snippet of code in my library. > > this.modelviewMatrixLocation = gl.getUniformLocation(this.program, > "modelviewMatrix"); > if (this.modelviewMatrixLocation >= 0) > { > gl.uniformMatrix4fv(this.modelviewMatrixLocation, true, > gl.modelviewMatrix.m); > } > > It checks if uniform location "modelviewMatrix" is supported by the current > program and sends the "modelviewMatrix" to the graphics card if. This code > works in Minefield. It is compatible with the OpenGL ES 2.0 standard. > > *OpenGL ES 2.0 standard* > glGetUniformLocation returns an integer that represents the location of a > specific uniform variable within a program object. *name* must be a null > terminated string that contains no white space. *name* must be an active > uniform variable name in *program* that is not a structure, an array of > structures, or a subcomponent of a vector or a matrix. This function returns > -1 if *name* does not correspond to an active uniform variable in *program > * or if *name* starts with the reserved prefix "gl_". > > *WebGL working draft* > getUniformLocation(program, name) (OpenGL ES 2.0 man page)Return > a WebGLUniformLocation object that represents the location of a specific > uniform variable within a program object. The return value is null if name > does not correspond to an active uniform variable in the passed program. > > Comment: the link to uniformMatrix4fv in the WebGL draft is broken. > > In WebKit getUniformLocations returns an object in Minefield it returns an > int. > > What is the reason to leave the OpenGL ES 2.0 standard. I personally use > the OpenGL ES 2.0 Programming Guide because it is lying on my desk. I also > copy and paste a lot between existing C++ code and javascript. At this time > Minefield is following the OpenGL ES standard and WebKit is following the > new WebGL draft that abandons the existing OpenGL ES. I vote for keeping the > OpenGL ES standard but at least both implementations should work the same. > We decided to box uniform locations in WebGL rather than expose them as integers in order to prevent code from making assumptions on how the shader compiler assigns locations to uniforms. Making explicit assumptions about the numbering scheme used by the compiler would lead to code that's not portable between platforms. WebKit has been following the spec on getUniformLocation for a while now. What I did add this week was the provision to return null if the internal call to getUniformLocation returns -1. I didn't want to copy the entire text of the GL ES spec for the situations where -1 is returned but now I realize that I should have been more descriptive. I'll amend the spec. Vangelis > > Best regards, > Carl van Heezik > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Mon Mar 8 15:20:11 2010 From: kbr...@ (Kenneth Russell) Date: Mon, 8 Mar 2010 15:20:11 -0800 Subject: [Public WebGL] typed array float-to-int conversion In-Reply-To: <4B955F12.3000009@mozilla.com> References: <4B955F12.3000009@mozilla.com> Message-ID: <921bb11003081520p4bbb879akf4e1a9fc4d669064@mail.gmail.com> On Mon, Mar 8, 2010 at 12:33 PM, Vladimir Vukicevic wrote: > The typed array spec currently has no discussion regarding how values are > converted from one type to another, especially on assignment. ?We have > language stating that a "C-style cast" is used, but I think that in the case > of float-to-int conversion this needs to be defined more fully, at least for > the case of NaN/Infinity/etc. ?JS states that when converting double-to-int > (e.g. when doing (1/0)>>0), Nan, +/-Inf, +/-0, and I believe > 2^(32+52) all > convert to 0. ?But beyond that, there are more requirements when the value > is >= 2^32 -- it's supposed to be fmod(val, 2^32). > > I think we should explicitly specify that the conversion is to 0 for NaN, > +/-Inf, and > 2^(32+52) because that can be done quickly using an exponent > comparison. ?(This arose because on x86, the SSE cvtsd2si opcode places > 0x80000000 in the integer register, and compilers seem to generate the > double-to-int conversion differently on Mac compared to Linux and Windows.) > ?Not sure if we need to say anything for the other cases, but maybe for > consistency, we need to state that all float to int conversions need to > behave as if they were converted to an ECMA int32 or uint32 first, and then > converted to a possibly narrower integer type. Agree about the conversion rules for these values. These array-like types need to have the right semantics to make loads and stores of values extremely fast. The only question is how to specify them. I think we should change our current text to refer to the ToInt32 and ToUint32 operations in ECMA-262. That will cover NaN and +/-Inf. Then we can specify only the behavioral differences for the additional values we want to cheaply convert quickly to 0. I'm not exactly what values those are. For the unsigned case, are they between 2^32 and 2^52 or something different? I assume we want to avoid any explicit modulo 2^32 operation as in ECMA-262? In a non-normative box we can then describe the rules for all of the values we care about. The intent would be to not duplicate normative text for the core ToInt32 and ToUint32 operations. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Mon Mar 8 15:40:20 2010 From: kbr...@ (Kenneth Russell) Date: Mon, 8 Mar 2010 15:40:20 -0800 Subject: [Public WebGL] getUniformLocation In-Reply-To: <7D0FB933-1227-44F2-9227-62B9870EA1E7@microcan.nl> References: <7D0FB933-1227-44F2-9227-62B9870EA1E7@microcan.nl> Message-ID: <921bb11003081540n656ede90obc7f7bea12ff1db9@mail.gmail.com> On Mon, Mar 8, 2010 at 4:22 AM, Carl van Heezik wrote: > Comment: the link to?uniformMatrix4fv in the WebGL draft is broken. There were several broken and incorrect links to the OpenGL ES man pages in the spec. I think I've fixed all of them; please post if you find any more. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From vla...@ Mon Mar 8 17:14:30 2010 From: vla...@ (Vladimir Vukicevic) Date: Mon, 08 Mar 2010 17:14:30 -0800 Subject: [Public WebGL] getUniformLocation In-Reply-To: <7D0FB933-1227-44F2-9227-62B9870EA1E7@microcan.nl> References: <7D0FB933-1227-44F2-9227-62B9870EA1E7@microcan.nl> Message-ID: <4B95A0F6.6050701@mozilla.com> On 3/8/2010 4:22 AM, Carl van Heezik wrote: > > In WebKit getUniformLocations returns an object in Minefield it > returns an int. > This is a bug in Gecko I haven't had a chance to fix yet. It's been somewhat low priority because, in theory, programs that use things correctly shouldn't see a difference. But the 0 vs. null issue is there, and I'd forgotten about that. Will get to it soon. - Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Mon Mar 8 18:15:50 2010 From: kbr...@ (Kenneth Russell) Date: Mon, 8 Mar 2010 18:15:50 -0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: References: Message-ID: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> On Sun, Mar 7, 2010 at 10:30 AM, Cedric Vivier wrote: > Hi everyone! > > As we all know, the less draw calls and render state changes the better the > performance, offloading calculations to the GPU is also a big win usually; > both former optimizations are particularly true with WebGL where JS<->native > calls overhead can be significant and JS math performance is not as good as > native code obviously. > > Geometry instancing is a popular rendering technique that allows very > efficient drawing of objects multiple times through the re-use of vertex > data with only one draw call as well as enabling easy offloading of > per-instance transformations/calculations to vertex shaders. > Originally introduced as an OpenGL 2.0+ extension GL_EXT_draw_instanced > years ago, instancing support has been added in core OpenGL 3.1+ and D3D9+ > has equivalent support. > > Of course WebGL is largely inspired by OpenGL ES, which does not support > instancing (as of 2.0). > However when support is not available, it is possible to implement it in > software, by looping regular drawArrays/drawElements for each instance after > incrementing an uniform instance index (technique known as pseudo > instancing). > > I propose therefore to add two methods to the WebGL context: > > void drawArraysInstanced(in GLenum mode, in GLint first, in GLsizei count, > in GLsizei primcount) > void drawElementsInstanced(in GLenum mode, in GLsizei count, in GLenum type, > in GLsizeiptr offset, in GLsizei primcount) > > They have the same signature as drawArrays/drawElements except `primcount' > added as last argument. > > > As a proof of concept, I've implemented this proposal on Firefox. > Demo and patch available at http://neonux.com/webgl/instancing.html > > On the simple demo above, with native pseudo instancing we get nice 20% > speedup compared to the JS-based pseudo instancing shim, when hardware > instancing is available we get a ridiculously awesome _23x speedup_, oh the > possibilities! (hello dense forests, crowds, complex particle systems, > whatever) > > Which means: > - with no hardware support [as is the case on OpenGL ES 2.0] this enables > more complex scenes thanks to faster pseudo instancing implementation than > what is possible with JavaScript (no overhead of at least 2x instances > JS<->native calls + checks at every instance). > - with hardware support, as it is the case on most WebGL-capable > laptop/desktop GPUs (and likely in a future version of OpenGL ES or an ES > extension?) this addition enables WebGL to render scenes that are _much_ > more complex. > - in both cases, it provides an easy known API to the developer who does not > have to implement its own pseudo-instancing replacement that could never > hope to be hardware-accelerated. > > For the reasons cited above, I believe this addition, though a slight > deviation from ES 2.0 (but not from OpenGL in general), would be very > valuable to add in WebGL. > A short paragraph about it would be added in the "Differences from OpenGL ES > 2.0" section. > > Opinions? > > Regards, > > [references] > http://en.wikipedia.org/wiki/Geometry_instancing > http://www.opengl.org/registry/specs/EXT/draw_instanced.txt > OpenGL 3.1 spec (no html doc available on Khronos website?) > http://msdn.microsoft.com/en-us/library/ee418549%28VS.85%29.aspx This is a good idea in general, and kudos for prototyping it. One comment on your prototype, which is that it is illegal according to the GLSL (and GLSL ES) semantics to use any identifier starting with "gl_". In order for your prototype to be semantically correct, then when you synthesize the InstanceID uniform variable, you would need to choose a different prefix; and when hardware instancing is not supported, you would need to rename any uses of "gl_InstanceID" in the shaders to your new variable name. This isn't quite as simple as a search and replace, since if your variable name is "_webgl_InstanceID" then you shouldn't rename any user identifier called for example "my_webgl_InstanceID". Right now the various browser vendors have a lot of work in the coming months to make the various implementations compliant to the existing spec, so I don't think we should add this to version 1.0 of the spec but add it in for example a version 1.1. However, if you would be willing to push ahead the implementation for say both Firefox and WebKit, it would make adding this entry point to the spec earlier a much easier decision to make. Regardless, it would be great if you would file a bug / RFE (request for enhancement) against WebGL on the Khronos Bugzilla instance, http://www.khronos.org/bugzilla/ . -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Mon Mar 8 18:29:49 2010 From: ced...@ (Cedric Vivier) Date: Tue, 9 Mar 2010 10:29:49 +0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> Message-ID: Hi Kenneth, On Tue, Mar 9, 2010 at 10:15 AM, Kenneth Russell wrote: > This is a good idea in general, and kudos for prototyping it. One > comment on your prototype, which is that it is illegal according to > the GLSL (and GLSL ES) semantics to use any identifier starting with > "gl_". In order for your prototype to be semantically correct, then > when you synthesize the InstanceID uniform variable, you would need to > choose a different prefix; > Oh yeah indeed, I changed this in the JS-based shim (which uses "webgl_InstanceID") but forgot to update the native pseudo-instancing implementation (which works on recent NVidia drivers, maybe should file a bug there). Of course this is just quick prototyping, a "production" version would use a smarter replace algorithm (just a nice regexp might do the trick though). > > Right now the various browser vendors have a lot of work in the coming > months to make the various implementations compliant to the existing > spec, so I don't think we should add this to version 1.0 of the spec > but add it in for example a version 1.1. However, if you would be > willing to push ahead the implementation for say both Firefox and > WebKit, I'm willing to do it once consensus is reached :) With regards to GLSL ES compliance checking we'll somehow need shader source parser/transformation code and thus the point above would be trivial to resolve I assume? Also, is there an effort/plan for a common "glsles2glsl" code that could be shared by "WebGL on desktop OpenGL" implementations? > it would make adding this entry point to the spec earlier a > much easier decision to make. Regardless, it would be great if you > would file a bug / RFE (request for enhancement) against WebGL on the > Khronos Bugzilla instance, http://www.khronos.org/bugzilla/ . > > Will do :) Cheers, -------------- next part -------------- An HTML attachment was scrubbed... URL: From car...@ Tue Mar 9 00:18:55 2010 From: car...@ (Carl van Heezik) Date: Tue, 9 Mar 2010 09:18:55 +0100 Subject: [Public WebGL] Re: Native implementation of common Matrix and Vector functions In-Reply-To: <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> Message-ID: I do not agree that you can't write code that is much faster than javascript. If the JS<--> native transitions (stack checks, boxing/unboxing) are a big overhead slowing things down these are the first ones to remove. If you make an optimized version you have everything in your own hands except for the few parameters that are passed to the routine. When the matrix is created you allocate memory that fits both worlds. Then you skip all overhead because it is really not needed (that why its called overhead) and do the math the fastest way possible. If you implement the same function in javascript however all these optimizations are not possible because the developer (you don't know) is allowed to do all kinds of crazy stuff. Comment: I see matrix / vector manipulation in every 3D application and think this justifies a high speed implementation. The fact that in OpenGL ES 2.0 you do not have to use them doesn't mean nobody uses them anymore. If anybody knows better ways to transform vertices without the use of matrices please let me know. Best regards, Carl vanHeezik Op 8 mrt 2010, om 16:59 heeft Thatcher Ulrich het volgende geschreven: On Mon, Mar 8, 2010 at 8:28 AM, Cedric Vivier wrote: > On Mon, Mar 8, 2010 at 9:11 PM, Carl van Heezik wrote: >> >> I implemented the basic matrix functions in javascript but I think it >> better that these basic matrix and vector functions are developed in the >> browser in native code making use of SIMD on the CPU or even the GPU. > > Would be interesting to benchmark but I doubt that it would really bring > much better perfs than Vlad's mjs as the benefits of SIMD might be > annihilated by the cost of JS<->native transitions (stack checks, > boxing/unboxing, gc etc) at every call. > Also there is nothing blocking Javascript runtimes to emit SIMD or GCGPU > stuff in the future when they detect SIMD patterns :) I think JS semantics demand the use of doubles, so that could be an obstacle, if what you really want is maximum speed 32-bit float math. That said, I am not in favor of this proposal -- the performance win seems doubtful because it is too fine grained. I could see a bulk linear-algebra lib based on FloatArrays but I don't think it should be hitched to WebGL. -T > Anyways as usual if matrix calculations are the bottleneck one way to make > them much faster is to offload such calculations in the shaders wherever > possible. > > Regards, > > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From car...@ Tue Mar 9 02:18:18 2010 From: car...@ (Carl van Heezik) Date: Tue, 9 Mar 2010 11:18:18 +0100 Subject: [Public WebGL] getParameter, getAttribLocation Message-ID: Vlad / Chris, I understand that getUniformLocation is boxed for a good reason. I expect that getAttribLocation is boxed as well for the same reason. It is more natural for me if they are handled the same way, so everywhere boxed or everywhere plain integers. I have the following code snippet. var program = gl.getParameter(gl.CURRENT_PROGRAM); this.vertexLocation = gl.getAttribLocation(program, 'vertex'); this.normalLocation = gl.getAttribLocation(program, 'normal'); this.colorLocation = gl.getAttribLocation(program, 'color'); In Minefield getParameter returns an int so this code doesn't run there. I believe boxing was decide after implementation in Minefield so you have to check all boxed integer parameters / return values. You bind the attribute locations and use integers there. I use the following code snippet. // Bind attributes for (var i in this.attributes) { gl.bindAttribLocation (this.program, i, this.attributes[i]); } It would have been logical if OpenGL ES 2.0 had a similar function gl.bindUniformLocation but its not. Its nice that you like to protect the programmer by boxing the uniform location but in my opinion WebGL is a low level API. A low level API comes with responsibility. There are many other reasons why programs do not run. So I still vote to remove the boxes en give us the plain integers. If you can't box getAttribLocation, because of bindAttribLocation, you should not box getUniformLocation. Maybe there are other reasons to do boxing, like performance gain, but I can not judge these. Best regards, Carl van Heezik -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Tue Mar 9 10:06:29 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 9 Mar 2010 10:06:29 -0800 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: References: Message-ID: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> On Tue, Mar 9, 2010 at 2:18 AM, Carl van Heezik wrote: > Vlad / Chris, > I understand that getUniformLocation is boxed for a good reason. I expect > that getAttribLocation is boxed as well for the same reason. > It is more natural for me if they are handled the same way, so everywhere > boxed or everywhere plain integers. I have the following code snippet. > ??var program = gl.getParameter(gl.CURRENT_PROGRAM); > ? this.vertexLocation = gl.getAttribLocation(program, 'vertex'); > ? this.normalLocation = gl.getAttribLocation(program, 'normal'); > ? this.colorLocation? = gl.getAttribLocation(program, 'color'); > > In Minefield getParameter returns an int so this code doesn't run there. I > believe boxing was decide after implementation in Minefield > so you have to check all boxed integer parameters / return values. > You bind the attribute locations and use integers there. I use the following > code snippet. > ??// Bind attributes > ? for (var i in this.attributes) > ? { > ? ? gl.bindAttribLocation (this.program, i, this.attributes[i]); > ? } > It would have been logical if OpenGL ES 2.0 had a similar function > gl.bindUniformLocation but its not. Its nice that you like to protect the > programmer by boxing the uniform location but in my opinion WebGL is a low > level API. A low level API comes with responsibility. There are many other > reasons why programs do not run. So I still vote to remove the boxes en give > us the plain integers. If you can't box getAttribLocation, because of > bindAttribLocation, ?you should not box getUniformLocation. Maybe there are > other reasons to do boxing, like performance gain, but I can not judge > these. getAttributeLocation is not boxed because attribute locations don't work the same way as uniform locations. Uniform locations are conceptually associated with a particular program object, while attribute locations can be used with many program objects (if they are set up via bindAttributeLocation). We had many long discussions about whether to box attribute locations in the working group, and I did an extensive prototype in WebKit, and doing so just doesn't work. On the other hand, boxing uniform locations has no semantic impact on correctly written WebGL code. It only prevents incorrect code from running and has no other adverse side effects. The bugs you point out, for example in getParameter(CURRENT_PROGRAM), should be fixed. I don't think we should change the spec in response to them. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Tue Mar 9 10:29:10 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 9 Mar 2010 10:29:10 -0800 Subject: [Public WebGL] Re: Native implementation of common Matrix and Vector functions In-Reply-To: References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> Message-ID: <921bb11003091029j122bd8cdw5c740dcda18d132b@mail.gmail.com> On Tue, Mar 9, 2010 at 12:18 AM, Carl van Heezik wrote: > I do not agree that you can't write code that is much faster than javascript. > If the JS<--> native transitions (stack checks, boxing/unboxing) are a big > overhead slowing things down these are the first ones to remove. > > If you make an optimized version you have everything in your own hands except > for the few parameters that are passed to the routine. When the matrix is created > you allocate memory that fits both worlds. Then you skip all overhead because it > is really not needed (that why its called overhead) and do the math the fastest way > possible. > > If you implement the same function in javascript however all these optimizations > are not possible because the developer (you don't know) is allowed to do all kinds > of crazy stuff. > > Comment: I see matrix / vector manipulation in every 3D application and think this > justifies a high speed implementation. The fact that in OpenGL ES 2.0 you do not > have to use them doesn't mean nobody uses them anymore. If anybody knows > better ways to transform vertices without the use of matrices please let me know. I also do not support baking a linear algebra library in to the WebGL specification, at least not at this point. First, one size does not fit all. Second, implementing these operations in C/C++ with inlined assembly will prevent the JavaScript engine and JIT from seeing and optimizing all of the surrounding operations. Third, your proposed library is structured in such a way that it allocates objects during each call (e.g. Vector2.add(Vector2)), which will eliminate any performance benefit due to increased GC costs. I think the right direction to go is to let apps and libraries built using WebGL settle for a while, see what linear algebra libraries evolve, and implement general numeric, loop and allocation optimizations in the various JavaScript engines so that code generally goes faster. -Ken > Best regards, > Carl vanHeezik > > > > Op 8 mrt 2010, om 16:59 heeft Thatcher Ulrich het volgende geschreven: > > On Mon, Mar 8, 2010 at 8:28 AM, Cedric Vivier wrote: >> On Mon, Mar 8, 2010 at 9:11 PM, Carl van Heezik wrote: >>> >>> I implemented the basic matrix functions in javascript but I think it >>> better that these basic matrix and vector functions are developed in the >>> browser in native code making use of SIMD on the CPU or even the GPU. >> >> Would be interesting to benchmark but I doubt that it would really bring >> much better perfs than Vlad's mjs as the benefits of SIMD might be >> annihilated by the cost of JS<->native transitions (stack checks, >> boxing/unboxing, gc etc) at every call. >> Also there is nothing blocking Javascript runtimes to emit SIMD or GCGPU >> stuff in the future when they detect SIMD patterns :) > > I think JS semantics demand the use of doubles, so that could be an > obstacle, if what you really want is maximum speed 32-bit float math. > > That said, I am not in favor of this proposal -- the performance win > seems doubtful because it is too fine grained. ?I could see a bulk > linear-algebra lib based on FloatArrays but I don't think it should be > hitched to WebGL. > > -T > >> Anyways as usual if matrix calculations are the bottleneck one way to make >> them much faster is to offload such calculations in the shaders wherever >> possible. >> >> Regards, >> >> > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From kbr...@ Tue Mar 9 10:54:46 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 9 Mar 2010 10:54:46 -0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> Message-ID: <921bb11003091054g61d63434m174389e17465d6a2@mail.gmail.com> On Mon, Mar 8, 2010 at 6:29 PM, Cedric Vivier wrote: > Hi Kenneth, > > On Tue, Mar 9, 2010 at 10:15 AM, Kenneth Russell wrote: >> >> This is a good idea in general, and kudos for prototyping it. One >> comment on your prototype, which is that it is illegal according to >> the GLSL (and GLSL ES) semantics to use any identifier starting with >> "gl_". In order for your prototype to be semantically correct, then >> when you synthesize the InstanceID uniform variable, you would need to >> choose a different prefix; > > Oh yeah indeed, I changed this in the JS-based shim (which uses > "webgl_InstanceID") but forgot to update the native pseudo-instancing > implementation (which works on recent NVidia drivers, maybe should file a > bug there). > Of course this is just quick prototyping, a "production" version would use a > smarter replace algorithm (just a nice regexp might do the trick though). > > >> >> Right now the various browser vendors have a lot of work in the coming >> months to make the various implementations compliant to the existing >> spec, so I don't think we should add this to version 1.0 of the spec >> but add it in for example a version 1.1. However, if you would be >> willing to push ahead the implementation for say both Firefox and >> WebKit, > > I'm willing to do it once consensus is reached :) > With regards to GLSL ES compliance checking we'll somehow need shader source > parser/transformation code and thus the point above would be trivial to > resolve I assume? Yes, a parser and translator will definitely be needed, and having one would make this task easier. However, because the transformations you need to do are relatively simple, you could probably encapsulate them in a simple class that could be used by the various WebGL implementations. > Also, is there an effort/plan for a common "glsles2glsl" code that could be > shared by "WebGL on desktop OpenGL" implementations? A teammate at Google, Alok Priyadarshi, is actively investigating a GLSL ES validator and converter to GLSL. The hope is that this can be a separate library used by all WebGL implementations on the desktop. -Ken >> it would make adding this entry point to the spec earlier a >> much easier decision to make. Regardless, it would be great if you >> would file a bug / RFE (request for enhancement) against WebGL on the >> Khronos Bugzilla instance, http://www.khronos.org/bugzilla/ . >> > > Will do :) > > > Cheers, > > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Tue Mar 9 17:49:50 2010 From: ced...@ (Cedric Vivier) Date: Wed, 10 Mar 2010 09:49:50 +0800 Subject: [Public WebGL] Reserve "webgl_" prefix in shaders Message-ID: Hi, In section 4.4 "Supported GLSL constructs", I propose to append: Identifiers starting with ?webgl_? are reserved for use by WebGL, and may not be declared in a shader as either a variable or a function. This ensures implementations and/or extensions can use such prefixed identifiers without conflicts with user code. Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Tue Mar 9 18:15:08 2010 From: kbr...@ (Kenneth Russell) Date: Tue, 9 Mar 2010 18:15:08 -0800 Subject: [Public WebGL] Reserve "webgl_" prefix in shaders In-Reply-To: References: Message-ID: <921bb11003091815t431e510em4e9585c2435a0851@mail.gmail.com> On Tue, Mar 9, 2010 at 5:49 PM, Cedric Vivier wrote: > Hi, > > In section 4.4 "Supported GLSL constructs", I propose to append: > > Identifiers starting with ?webgl_? are reserved for use by WebGL, and may > not be declared in a shader as > either a variable or a function. > > > This ensures implementations and/or extensions can use such prefixed > identifiers without conflicts with user code. What would you think about using "_webgl_" instead? Is your intent that user code can refer to these identifiers? I would hope that WebGL would preserve GLSL / GLSL ES semantics and therefore not introduce publicly visible identifiers starting with "webgl_". -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Tue Mar 9 18:37:49 2010 From: ced...@ (Cedric Vivier) Date: Wed, 10 Mar 2010 10:37:49 +0800 Subject: [Public WebGL] Reserve "webgl_" prefix in shaders In-Reply-To: <921bb11003091815t431e510em4e9585c2435a0851@mail.gmail.com> References: <921bb11003091815t431e510em4e9585c2435a0851@mail.gmail.com> Message-ID: On Wed, Mar 10, 2010 at 10:15 AM, Kenneth Russell wrote: > What would you think about using "_webgl_" instead? Is your intent > that user code can refer to these identifiers? My intent is primarily for potential internal use by WebGL implementations so in that case "_webgl_" prefix may indeed sound better. However it might be useful for future WebGL-specific extensions to introduce identifiers that are to be referred to by user code, so we should not close the door on that imho. I suggest we either reserve both "_webgl_" and "webgl_" prefixes or only the latter. Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim...@ Wed Mar 10 00:05:39 2010 From: tim...@ (Tim Johansson) Date: Wed, 10 Mar 2010 09:05:39 +0100 Subject: [Public WebGL] Proposal for depth and stencil FBO attachments In-Reply-To: <1D00192F-02C0-4512-A399-957F9D93A5CD@apple.com> References: <921bb11002251128m66df4d80rab6cd127481edbbf@mail.gmail.com> <97AE520D-CF63-4CCA-9A1E-00EF7B291FE4@apple.com> <921bb11002251954y210844a4r906cac4e35582034@mail.gmail.com> <33072142-40DF-4D4A-BD80-F1FB7B48C6E5@apple.com> <921bb11002261129o4b594e98v117c3fec8ff1f76a@mail.gmail.com> <2A53AB74-3D72-4DF5-BE7F-5F0340246C5E@apple.com> <921bb11003021435o4424a443o1684f5de01ec422@mail.gmail.com> <4B8DFC5E.9010201@hicorp.co.jp> <921bb11003031052q5802db81p978f7d14cc3a9e7e@mail.gmail.com> <1D00192F-02C0-4512-A399-957F9D93A5CD@apple.com> Message-ID: <4B9752D3.3010100@opera.com> On 2010-03-05 23:46, Chris Marrin wrote: > On Mar 3, 2010, at 10:52 AM, Kenneth Russell wrote: > > >> On Tue, Mar 2, 2010 at 10:06 PM, Mark Callow wrote: >> >>> Hi Ken, >>> >>> I think it is good. You can remove the last sentence, replacing it with the >>> word "concurrently" in the sentence before the list of combinations: >>> >>> "In WebGL, it is an error to concurrently attach renderbuffers to the >>> following combinations of attachment points:" >>> >> Thanks for the suggestion. Updated. >> > > This all looks really good. I'd like some input from some of the people who raised the issue at the F2F (I don't remember who that was). > > That was me. The current specified behavior looks very good to me, as does the spec text. //Tim ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From car...@ Wed Mar 10 00:23:07 2010 From: car...@ (Carl van Heezik) Date: Wed, 10 Mar 2010 09:23:07 +0100 Subject: [Public WebGL] Re: Native implementation of common Matrix and Vector functions In-Reply-To: <921bb11003091029j122bd8cdw5c740dcda18d132b@mail.gmail.com> References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> <921bb11003091029j122bd8cdw5c740dcda18d132b@mail.gmail.com> Message-ID: Ken, I am surprised that you state that one size doesn't fit all for basic stuff as matrix and vector operations. Constructs like Vector2.add(Vector2) are only needed because of the limitations of javascript. Javascript does not support operator overloading. In the original C++ library I used operator overloading so I can use constructs like (for vector, quaternions, etc): d = a + b * c; They are fully optimized by the compiler in registers and SIMD. I do not use assembly. What I would like is matrices and vectors as primitive types in javascript. They have not changed in the past 12 years for me and it is not likely that they will in the near future. They are generic enough to be part of the OpenGL ES shading language so in my opinion they are also good enough to include in javascript. I don't see how any serious 3D application can do without matrix and vector operations. The big difference between implementing a library inside the browser and in a javascript is that the script must be transmitted over the internet many times. You can also prevent object allocation for simple operations as adding vectors. Ken although I disagree with you, I respect your opinion, if you have ways that better fit javascript / WebGL I like to know. Best regards, Carl van Heezik Op 9 mrt 2010, om 19:29 heeft Kenneth Russell het volgende geschreven: On Tue, Mar 9, 2010 at 12:18 AM, Carl van Heezik wrote: > I do not agree that you can't write code that is much faster than javascript. > If the JS<--> native transitions (stack checks, boxing/unboxing) are a big > overhead slowing things down these are the first ones to remove. > > If you make an optimized version you have everything in your own hands except > for the few parameters that are passed to the routine. When the matrix is created > you allocate memory that fits both worlds. Then you skip all overhead because it > is really not needed (that why its called overhead) and do the math the fastest way > possible. > > If you implement the same function in javascript however all these optimizations > are not possible because the developer (you don't know) is allowed to do all kinds > of crazy stuff. > > Comment: I see matrix / vector manipulation in every 3D application and think this > justifies a high speed implementation. The fact that in OpenGL ES 2.0 you do not > have to use them doesn't mean nobody uses them anymore. If anybody knows > better ways to transform vertices without the use of matrices please let me know. I also do not support baking a linear algebra library in to the WebGL specification, at least not at this point. First, one size does not fit all. Second, implementing these operations in C/C++ with inlined assembly will prevent the JavaScript engine and JIT from seeing and optimizing all of the surrounding operations. Third, your proposed library is structured in such a way that it allocates objects during each call (e.g. Vector2.add(Vector2)), which will eliminate any performance benefit due to increased GC costs. I think the right direction to go is to let apps and libraries built using WebGL settle for a while, see what linear algebra libraries evolve, and implement general numeric, loop and allocation optimizations in the various JavaScript engines so that code generally goes faster. -Ken > Best regards, > Carl vanHeezik > > > > Op 8 mrt 2010, om 16:59 heeft Thatcher Ulrich het volgende geschreven: > > On Mon, Mar 8, 2010 at 8:28 AM, Cedric Vivier wrote: >> On Mon, Mar 8, 2010 at 9:11 PM, Carl van Heezik wrote: >>> >>> I implemented the basic matrix functions in javascript but I think it >>> better that these basic matrix and vector functions are developed in the >>> browser in native code making use of SIMD on the CPU or even the GPU. >> >> Would be interesting to benchmark but I doubt that it would really bring >> much better perfs than Vlad's mjs as the benefits of SIMD might be >> annihilated by the cost of JS<->native transitions (stack checks, >> boxing/unboxing, gc etc) at every call. >> Also there is nothing blocking Javascript runtimes to emit SIMD or GCGPU >> stuff in the future when they detect SIMD patterns :) > > I think JS semantics demand the use of doubles, so that could be an > obstacle, if what you really want is maximum speed 32-bit float math. > > That said, I am not in favor of this proposal -- the performance win > seems doubtful because it is too fine grained. I could see a bulk > linear-algebra lib based on FloatArrays but I don't think it should be > hitched to WebGL. > > -T > >> Anyways as usual if matrix calculations are the bottleneck one way to make >> them much faster is to offload such calculations in the shaders wherever >> possible. >> >> Regards, >> >> > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > > > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From car...@ Wed Mar 10 02:05:55 2010 From: car...@ (Carl van Heezik) Date: Wed, 10 Mar 2010 11:05:55 +0100 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> References: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> Message-ID: <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> Ken, Attribute locations are also associated to a particular program object, the same way as uniform locations are. Look at the syntax of bindAttribLocation: void glBindAttribLocation( GLuint program, GLuint index, const GLchar *name); As you can see the binding is done to a program object. Attribute bindings go into effect if link the program and remain fixed until you link the program again. There is no way you can setup attribute locations once and use them in multiple programs. I think boxing should be removed from the getUniformLocation. 1. Without boxing the API is the same as the OpenGL ES 2.0 standard 2. Without boxing the API is consistent with getAttribLocation 3. Boxing does not add any value for the programmer Current WebGL working draft has inconsistent return values: this.colorLocation = gl.getUniformLocation(program, "color"); if (this.colorLocation != null) { gl.uniform4fv(this.colorLocation, this.color); } this.vertexLocation = gl.getAttribLocation(program, "vertex"); if (this.vertexLocation >= 0) { // Load the vertex data gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); gl.vertexAttribPointer(this.vertexLocation, 2, gl.FLOAT, false, 0, 0); gl.enableVertexAttribArray(this.vertexLocation); } An inconsistent API will lead to more errors than the error you try to prevent by boxing the attribute location. The difference between the two if statements is so small its very difficult to find. Boxing has impact on correctly written code, this was working code in C++ OpenGL ES 2.0, it worked in Minefield but did not work in WebKit. It took me a long time to find out that the OpenGL ES standard was not used by WebGL. I had to change the if statement from if (this.colorLocation >= 0) to if (this.colorLocation != null) Of course this little change prevents it from working in Minefield. Remove the boxes and keep things according to the OpenGL ES 2.0 standard. Comment: Nothing in this email is against any person of the working group. I just like the WebGL API as consistent as possible. Best regards, Carl van Heezik Op 9 mrt 2010, om 19:06 heeft Kenneth Russell het volgende geschreven: On Tue, Mar 9, 2010 at 2:18 AM, Carl van Heezik wrote: > Vlad / Chris, > I understand that getUniformLocation is boxed for a good reason. I expect > that getAttribLocation is boxed as well for the same reason. > It is more natural for me if they are handled the same way, so everywhere > boxed or everywhere plain integers. I have the following code snippet. > var program = gl.getParameter(gl.CURRENT_PROGRAM); > this.vertexLocation = gl.getAttribLocation(program, 'vertex'); > this.normalLocation = gl.getAttribLocation(program, 'normal'); > this.colorLocation = gl.getAttribLocation(program, 'color'); > > In Minefield getParameter returns an int so this code doesn't run there. I > believe boxing was decide after implementation in Minefield > so you have to check all boxed integer parameters / return values. > You bind the attribute locations and use integers there. I use the following > code snippet. > // Bind attributes > for (var i in this.attributes) > { > gl.bindAttribLocation (this.program, i, this.attributes[i]); > } > It would have been logical if OpenGL ES 2.0 had a similar function > gl.bindUniformLocation but its not. Its nice that you like to protect the > programmer by boxing the uniform location but in my opinion WebGL is a low > level API. A low level API comes with responsibility. There are many other > reasons why programs do not run. So I still vote to remove the boxes en give > us the plain integers. If you can't box getAttribLocation, because of > bindAttribLocation, you should not box getUniformLocation. Maybe there are > other reasons to do boxing, like performance gain, but I can not judge > these. getAttributeLocation is not boxed because attribute locations don't work the same way as uniform locations. Uniform locations are conceptually associated with a particular program object, while attribute locations can be used with many program objects (if they are set up via bindAttributeLocation). We had many long discussions about whether to box attribute locations in the working group, and I did an extensive prototype in WebKit, and doing so just doesn't work. On the other hand, boxing uniform locations has no semantic impact on correctly written WebGL code. It only prevents incorrect code from running and has no other adverse side effects. The bugs you point out, for example in getParameter(CURRENT_PROGRAM), should be fixed. I don't think we should change the spec in response to them. -Ken -------------- next part -------------- An HTML attachment was scrubbed... URL: From oli...@ Wed Mar 10 10:17:02 2010 From: oli...@ (Oliver Hunt) Date: Wed, 10 Mar 2010 10:17:02 -0800 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> References: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> Message-ID: <26B17A64-F35A-4417-B057-509E4CF1AA5B@apple.com> On Mar 10, 2010, at 2:05 AM, Carl van Heezik wrote: > Ken, > > Attribute locations are also associated to a particular program object, the same > way as uniform locations are. Look at the syntax of bindAttribLocation: > > void glBindAttribLocation( GLuint program, > GLuint index, > const GLchar *name); > > As you can see the binding is done to a program object. Attribute bindings go > into effect if link the program and remain fixed until you link the program again. > There is no way you can setup attribute locations once and use them in multiple > programs. > > I think boxing should be removed from the getUniformLocation. > > 1. Without boxing the API is the same as the OpenGL ES 2.0 standard > 2. Without boxing the API is consistent with getAttribLocation > 3. Boxing does not add any value for the programmer There's a difference between adding value to the programmer and adding semantics needed to ensure consistent and safe behaviour in the implementation. You have to remember that the spec has to be written defensively: code on the web is inherently unsafe, and the spec cannot define unsafe behaviour, instead it must define behaviour that can be made safe without large numbers of convoluted rules. In the very brief period where integer uniforms were allowed there were quite a few demos created that didn't run on different platforms than that of the creator because the moment you use an integer people can make behavioural assumptions that may be fine on some platforms, but fail on others. Something that you must keep in mind while looking at the WebGL spec is that there must be the minimum possible exposure of hardware variance. The sad fact of life is that any web-centric spec cannot leave behaviour undefined or it will have to be subsequently defined as whatever is the most popular platform -- in this case it would end up requiring all implementations going to significant effort to ensure that the same integer identifiers mapped to the same uniforms on all platforms, on all devices -- eg. internally all implementations would need to effectively have their own glsl compiler so that they could work out which uniforms should be dropped (because some drivers will optimize unused out of the code) and what other uniforms should go where, and then map those integers through to the what the underlying platform has actually done. If memory serves we did try to make glBindAttribLocation also return an object reference, but there was some reason it ended up not being possible in the end -- i can't recall the exact reason but if it's any comfort we spent a large amount of time deciding what to do about location information and a reasonable amount happened on the mailing lists so i presume is archived somewhere. --Oliver -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Wed Mar 10 11:38:44 2010 From: kbr...@ (Kenneth Russell) Date: Wed, 10 Mar 2010 11:38:44 -0800 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> References: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> Message-ID: <921bb11003101138l2b363d4dq1841a07d6c46b589@mail.gmail.com> On Wed, Mar 10, 2010 at 2:05 AM, Carl van Heezik wrote: > Ken, > > Attribute locations are also associated to a particular program object, the > same > way as uniform locations are. Look at the syntax of bindAttribLocation: > > void *glBindAttribLocation*(GLuint program, GLuint index, const GLchar * > name); > As you can see the binding is done to a program object. Attribute bindings > go > into effect if link the program and remain fixed until you link the program > again. > There is no way you can setup attribute locations once and use them in > multiple > programs. > True, but consider trying to box these attribute locations, which was what the working group considered earlier. There are two programs where you want to assign the same location to two attributes (which might have the same name, or might not). Since simple integers can no longer be passed in as attribute locations, a new API is needed to "create" a boxed attribute location which can be used in bindAttributeLocation calls to the two programs. The same attribute location object needs to be used later when calling glVertexAttribPointer, and validation needs to occur to ensure that the attribute location object is legal to use with the currently bound program during draw calls. It quickly becomes a mess which is why the decision was made to leave attribute locations as simple integers. I think *boxing should be removed* from the getUniformLocation. > > 1. Without boxing the API is the same as the OpenGL ES 2.0 standard > 2. Without boxing the API is consistent with getAttribLocation > 3. Boxing does not add any value for the programmer > A major motivation for adding the boxing was a skinning example developed against one of the early WebGL prototypes. The developer made assumptions about the layouts of uniform locations (i.e., whether adjacent uniform locations were incremented by 1 or by 4) which were legal on one graphics card and illegal on another. Boxing adds a measure of safety and improves portability. See Oliver's other email for more discussion about why the boxing was added. I personally think we should retain the boxing of uniforms. Effort is needed to port C++ code to JavaScript anyway and this is a relatively minor change that is needed. If you have a suggestion about additions to the specification to make this difference in behavior clearer, please post. -Ken Current WebGL working draft has inconsistent return values: > > this.colorLocation = gl.getUniformLocation(program, "color"); > if (this.colorLocation != null) > { > gl.uniform4fv(this.colorLocation, this.color); > } > this.vertexLocation = gl.getAttribLocation(program, "vertex"); > if (this.vertexLocation >= 0) > { > // Load the vertex data > gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); > gl.vertexAttribPointer(this.vertexLocation, 2, gl.FLOAT, false, 0, > 0); > gl.enableVertexAttribArray(this.vertexLocation); > } > > An inconsistent API will lead to more errors than the error you try to > prevent > by boxing the attribute location. The difference between the two ifstatements > is so small its very difficult to find. > > Boxing has impact on correctly written code, this was working code in C++ > OpenGL ES 2.0, it worked in Minefield but did not work in WebKit. It took > me > a long time to find out that the OpenGL ES standard was not used by WebGL. > I had to change the if statement from > > if (this.colorLocation >= 0) > > to > > if (this.colorLocation != null) > > Of course this little change prevents it from working in Minefield. Remove > the boxes > and keep things according to the OpenGL ES 2.0 standard. > > Comment: Nothing in this email is against any person of the working group. > I just > like the WebGL API as consistent as possible. > > Best regards, > Carl van Heezik > > > > > > > > > Op 9 mrt 2010, om 19:06 heeft Kenneth Russell het volgende geschreven: > > On Tue, Mar 9, 2010 at 2:18 AM, Carl van Heezik wrote: > > Vlad / Chris, > > I understand that getUniformLocation is boxed for a good reason. I expect > > that getAttribLocation is boxed as well for the same reason. > > It is more natural for me if they are handled the same way, so everywhere > > boxed or everywhere plain integers. I have the following code snippet. > > var program = gl.getParameter(gl.CURRENT_PROGRAM); > > this.vertexLocation = gl.getAttribLocation(program, 'vertex'); > > this.normalLocation = gl.getAttribLocation(program, 'normal'); > > this.colorLocation = gl.getAttribLocation(program, 'color'); > > > In Minefield getParameter returns an int so this code doesn't run there. I > > believe boxing was decide after implementation in Minefield > > so you have to check all boxed integer parameters / return values. > > You bind the attribute locations and use integers there. I use the > following > > code snippet. > > // Bind attributes > > for (var i in this.attributes) > > { > > gl.bindAttribLocation (this.program, i, this.attributes[i]); > > } > > It would have been logical if OpenGL ES 2.0 had a similar function > > gl.bindUniformLocation but its not. Its nice that you like to protect the > > programmer by boxing the uniform location but in my opinion WebGL is a low > > level API. A low level API comes with responsibility. There are many other > > reasons why programs do not run. So I still vote to remove the boxes en > give > > us the plain integers. If you can't box getAttribLocation, because of > > bindAttribLocation, you should not box getUniformLocation. Maybe there are > > other reasons to do boxing, like performance gain, but I can not judge > > these. > > > getAttributeLocation is not boxed because attribute locations don't > work the same way as uniform locations. Uniform locations are > conceptually associated with a particular program object, while > attribute locations can be used with many program objects (if they are > set up via bindAttributeLocation). We had many long discussions about > whether to box attribute locations in the working group, and I did an > extensive prototype in WebKit, and doing so just doesn't work. > > On the other hand, boxing uniform locations has no semantic impact on > correctly written WebGL code. It only prevents incorrect code from > running and has no other adverse side effects. > > The bugs you point out, for example in getParameter(CURRENT_PROGRAM), > should be fixed. I don't think we should change the spec in response > to them. > > -Ken > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Wed Mar 10 14:21:13 2010 From: kbr...@ (Kenneth Russell) Date: Wed, 10 Mar 2010 14:21:13 -0800 Subject: [Public WebGL] Re: Native implementation of common Matrix and Vector functions In-Reply-To: References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> <921bb11003091029j122bd8cdw5c740dcda18d132b@mail.gmail.com> Message-ID: <921bb11003101421g1d43fbden5a66ff1263b97da5@mail.gmail.com> On Wed, Mar 10, 2010 at 12:23 AM, Carl van Heezik wrote: > Ken, > I am surprised that you state that one size doesn't fit all for basic stuff > as matrix > and vector operations. Constructs like Vector2.add(Vector2) are only needed > because of the limitations of javascript. Javascript does not support > operator > overloading.?In the original C++ library I used operator overloading so I > can use > constructs like (for vector, quaternions, etc): > ??d = a + b * c; > They are fully optimized by the compiler in registers and SIMD. I do not use > assembly.?What I would like?is matrices?and vectors as primitive types in > javascript. > They have not changed in the?past 12?years for me and it is not likely that > they?will > in the near future. They are?generic enough to be part of the OpenGL ES > shading > language so in my opinion?they are also good enough to include in > javascript. I don't > see how any serious?3D application can do without matrix and vector > operations. > The big difference between implementing a library inside the browser and > in a javascript is that the script must be transmitted over the internet > many times. > You can also prevent object allocation for simple operations as adding > vectors. > Ken although I disagree with you, I respect your opinion, if you have ways > that > better fit javascript / WebGL I like to know. The simplest and most general way to get the desired performance is to keep all of the linear algebra code in pure JavaScript, and improve the current JITs to perform escape analysis and do to better numeric and loop optimizations. If you can come up with a good use case, publicize it so that the various browser vendors start to pay attention to improving numerical performance. There are many technical reasons why adding these classes to the WebGL spec and thereby the DOM bindings would be extremely detrimental to performance, and require extensive amounts of handwritten assembly to optimize them in any way. -Ken > Best regards, > Carl van Heezik > > > Op 9 mrt 2010, om 19:29 heeft Kenneth Russell het volgende geschreven: > On Tue, Mar 9, 2010 at 12:18 AM, Carl van Heezik wrote: > > I do not agree that you can't write code that is much faster than > javascript. > > If the JS<--> native transitions (stack checks, boxing/unboxing) are a big > > overhead slowing things down these are the first ones to remove. > > If you make an optimized version you have everything in your own hands > except > > for the few parameters that are passed to the routine. When the matrix is > created > > you allocate memory that fits both worlds. Then you skip all overhead > because it > > is really not needed (that why its called overhead) and do the math the > fastest way > > possible. > > If you implement the same function in javascript however all these > optimizations > > are not possible because the developer (you don't know) is allowed to do all > kinds > > of crazy stuff. > > Comment: I see matrix / vector manipulation in every 3D application and > think this > > justifies a high speed implementation. The fact that in OpenGL ES 2.0 you do > not > > have to use them doesn't mean nobody uses them anymore. If anybody knows > > better ways to transform vertices without the use of matrices please let me > know. > > I also do not support baking a linear algebra library in to the WebGL > specification, at least not at this point. First, one size does not > fit all. Second, implementing these operations in C/C++ with inlined > assembly will prevent the JavaScript engine and JIT from seeing and > optimizing all of the surrounding operations. Third, your proposed > library is structured in such a way that it allocates objects during > each call (e.g. Vector2.add(Vector2)), which will eliminate any > performance benefit due to increased GC costs. > > I think the right direction to go is to let apps and libraries built > using WebGL settle for a while, see what linear algebra libraries > evolve, and implement general numeric, loop and allocation > optimizations in the various JavaScript engines so that code generally > goes faster. > > -Ken > > Best regards, > > Carl vanHeezik > > > > Op 8 mrt 2010, om 16:59 heeft Thatcher Ulrich het volgende geschreven: > > On Mon, Mar 8, 2010 at 8:28 AM, Cedric Vivier wrote: > > On Mon, Mar 8, 2010 at 9:11 PM, Carl van Heezik wrote: > > I implemented the basic matrix functions in javascript but I think it > > better that these basic matrix and vector functions are developed in the > > browser in native code making use of SIMD on the CPU or even the GPU. > > Would be interesting to benchmark but I doubt that it would really bring > > much better perfs than Vlad's mjs as the benefits of SIMD might be > > annihilated by the cost of JS<->native transitions (stack checks, > > boxing/unboxing, gc etc) at every call. > > Also there is nothing blocking Javascript runtimes to emit SIMD or GCGPU > > stuff in the future when they detect SIMD patterns :) > > I think JS semantics demand the use of doubles, so that could be an > > obstacle, if what you really want is maximum speed 32-bit float math. > > That said, I am not in favor of this proposal -- the performance win > > seems doubtful because it is too fine grained. ?I could see a bulk > > linear-algebra lib based on FloatArrays but I don't think it should be > > hitched to WebGL. > > -T > > Anyways as usual if matrix calculations are the bottleneck one way to make > > them much faster is to offload such calculations in the shaders wherever > > possible. > > Regards, > > > ----------------------------------------------------------- > > You are currently subscribe to public_webgl...@ > > To unsubscribe, send an email to majordomo...@ with > > the following command in the body of your email: > > > > ----------------------------------------------------------- > > You are currently subscribe to public_webgl...@ > > To unsubscribe, send an email to majordomo...@ with > > the following command in the body of your email: > > > > ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From gma...@ Wed Mar 10 15:33:55 2010 From: gma...@ (Gregg Tavares) Date: Wed, 10 Mar 2010 15:33:55 -0800 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: <921bb11003101138l2b363d4dq1841a07d6c46b589@mail.gmail.com> References: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> <921bb11003101138l2b363d4dq1841a07d6c46b589@mail.gmail.com> Message-ID: On Wed, Mar 10, 2010 at 11:38 AM, Kenneth Russell wrote: > On Wed, Mar 10, 2010 at 2:05 AM, Carl van Heezik wrote: > >> Ken, >> >> Attribute locations are also associated to a particular program object, >> the same >> way as uniform locations are. Look at the syntax of bindAttribLocation: >> >> void *glBindAttribLocation*( GLuint program, GLuint index, const GLchar >> *name); >> As you can see the binding is done to a program object. Attribute bindings >> go >> into effect if link the program and remain fixed until you link the >> program again. >> There is no way you can setup attribute locations once and use them in >> multiple >> programs. >> > > True, but consider trying to box these attribute locations, which was what > the working group considered earlier. There are two programs where you want > to assign the same location to two attributes (which might have the same > name, or might not). Since simple integers can no longer be passed in as > attribute locations, a new API is needed to "create" a boxed attribute > location which can be used in bindAttributeLocation calls to the two > programs. The same attribute location object needs to be used later when > calling glVertexAttribPointer, and validation needs to occur to ensure that > the attribute location object is legal to use with the currently bound > program during draw calls. It quickly becomes a mess which is why the > decision was made to leave attribute locations as simple integers. > > I think *boxing should be removed* from the getUniformLocation. >> >> 1. Without boxing the API is the same as the OpenGL ES 2.0 standard >> 2. Without boxing the API is consistent with getAttribLocation >> 3. Boxing does not add any value for the programmer >> > > A major motivation for adding the boxing was a skinning example developed > against one of the early WebGL prototypes. The developer made assumptions > about the layouts of uniform locations (i.e., whether adjacent uniform > locations were incremented by 1 or by 4) which were legal on one graphics > card and illegal on another. Boxing adds a measure of safety and improves > portability. > I didn't see this test but looking at the OpenGL ES 2.0 spec this sounds like maybe it had something to do with the fact that some implementation of WebGL was built on top of OpenGL and was not enforcing OpenGL ES 2.0 compliance. The OpenGL ES 2.0 spec says that for example that array elements are at location + element index. That means if you have a shader with a uniform uniform mat4 skinMats[12]; then you should be able to do this. loc = ctx.getUniformLocation(program, "skinMats"); // Set each matrix individually for (var ii = 0; ii < 12; ++ii) { ctx.uniformMatrix4fv(loc + ii, 1, false, someMatrices[ii]); } If in some older WebGL implementation that wasn't working then it wasn't OpenGL ES 2.0 compliant. In the current WebGL spec you can't do that at all since "loc + ii" has no meaning. You have to set the matrices as an array ctx.uniformMatrix4fv(loc, *12*, false, someMatrices); Or you have to query the location of each element // Set each matrix individually for (var ii = 0; ii < 12; ++ii) { loc = ctx.getUniformLocation(program, "skinMats[" + ii + "]); ctx.uniformMatrix4fv(loc, 1, false, someMatrices[ii]); } I don't personally have a problem with the boxing. I think it makes things safer. But if the only reason for it is based on a false assumption that's not good. > > See Oliver's other email for more discussion about why the boxing was > added. > > I personally think we should retain the boxing of uniforms. Effort is > needed to port C++ code to JavaScript anyway and this is a relatively minor > change that is needed. > > If you have a suggestion about additions to the specification to make this > difference in behavior clearer, please post. > > -Ken > > Current WebGL working draft has inconsistent return values: >> >> this.colorLocation = gl.getUniformLocation(program, "color"); >> if (this.colorLocation != null) >> { >> gl.uniform4fv(this.colorLocation, this.color); >> } >> this.vertexLocation = gl.getAttribLocation(program, "vertex"); >> if (this.vertexLocation >= 0) >> { >> // Load the vertex data >> gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); >> gl.vertexAttribPointer(this.vertexLocation, 2, gl.FLOAT, false, 0, >> 0); >> gl.enableVertexAttribArray(this.vertexLocation); >> } >> >> An inconsistent API will lead to more errors than the error you try to >> prevent >> by boxing the attribute location. The difference between the two ifstatements >> is so small its very difficult to find. >> >> Boxing has impact on correctly written code, this was working code in C++ >> OpenGL ES 2.0, it worked in Minefield but did not work in WebKit. It took >> me >> a long time to find out that the OpenGL ES standard was not used by >> WebGL. >> I had to change the if statement from >> >> if (this.colorLocation >= 0) >> >> to >> >> if (this.colorLocation != null) >> >> Of course this little change prevents it from working in Minefield. Remove >> the boxes >> and keep things according to the OpenGL ES 2.0 standard. >> >> Comment: Nothing in this email is against any person of the working group. >> I just >> like the WebGL API as consistent as possible. >> >> Best regards, >> Carl van Heezik >> >> >> >> >> >> >> >> >> Op 9 mrt 2010, om 19:06 heeft Kenneth Russell het volgende geschreven: >> >> On Tue, Mar 9, 2010 at 2:18 AM, Carl van Heezik wrote: >> >> Vlad / Chris, >> >> I understand that getUniformLocation is boxed for a good reason. I expect >> >> that getAttribLocation is boxed as well for the same reason. >> >> It is more natural for me if they are handled the same way, so everywhere >> >> boxed or everywhere plain integers. I have the following code snippet. >> >> var program = gl.getParameter(gl.CURRENT_PROGRAM); >> >> this.vertexLocation = gl.getAttribLocation(program, 'vertex'); >> >> this.normalLocation = gl.getAttribLocation(program, 'normal'); >> >> this.colorLocation = gl.getAttribLocation(program, 'color'); >> >> >> In Minefield getParameter returns an int so this code doesn't run there. I >> >> believe boxing was decide after implementation in Minefield >> >> so you have to check all boxed integer parameters / return values. >> >> You bind the attribute locations and use integers there. I use the >> following >> >> code snippet. >> >> // Bind attributes >> >> for (var i in this.attributes) >> >> { >> >> gl.bindAttribLocation (this.program, i, this.attributes[i]); >> >> } >> >> It would have been logical if OpenGL ES 2.0 had a similar function >> >> gl.bindUniformLocation but its not. Its nice that you like to protect the >> >> programmer by boxing the uniform location but in my opinion WebGL is a low >> >> level API. A low level API comes with responsibility. There are many other >> >> reasons why programs do not run. So I still vote to remove the boxes en >> give >> >> us the plain integers. If you can't box getAttribLocation, because of >> >> bindAttribLocation, you should not box getUniformLocation. Maybe there >> are >> >> other reasons to do boxing, like performance gain, but I can not judge >> >> these. >> >> >> getAttributeLocation is not boxed because attribute locations don't >> work the same way as uniform locations. Uniform locations are >> conceptually associated with a particular program object, while >> attribute locations can be used with many program objects (if they are >> set up via bindAttributeLocation). We had many long discussions about >> whether to box attribute locations in the working group, and I did an >> extensive prototype in WebKit, and doing so just doesn't work. >> >> On the other hand, boxing uniform locations has no semantic impact on >> correctly written WebGL code. It only prevents incorrect code from >> running and has no other adverse side effects. >> >> The bugs you point out, for example in getParameter(CURRENT_PROGRAM), >> should be fixed. I don't think we should change the spec in response >> to them. >> >> -Ken >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Wed Mar 10 16:04:12 2010 From: kbr...@ (Kenneth Russell) Date: Wed, 10 Mar 2010 16:04:12 -0800 Subject: [Public WebGL] Reserve "webgl_" prefix in shaders In-Reply-To: References: <921bb11003091815t431e510em4e9585c2435a0851@mail.gmail.com> Message-ID: <921bb11003101604w5703f64dle5abd953b04fe287@mail.gmail.com> On Tue, Mar 9, 2010 at 6:37 PM, Cedric Vivier wrote: > On Wed, Mar 10, 2010 at 10:15 AM, Kenneth Russell wrote: >> >> What would you think about using "_webgl_" instead? Is your intent >> that user code can refer to these identifiers? > > My intent is primarily for potential internal use by WebGL implementations > so in that case "_webgl_" prefix may indeed sound better. > However it might be useful for future WebGL-specific extensions to introduce > identifiers that are to be referred to by user code, so we should not close > the door on that imho. > > I suggest we either reserve both "_webgl_" and "webgl_" prefixes or only the > latter. OK, let's reserve both prefixes. I've committed spec changes. Please comment. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From gma...@ Wed Mar 10 16:32:19 2010 From: gma...@ (Gregg Tavares) Date: Wed, 10 Mar 2010 16:32:19 -0800 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: References: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> <921bb11003101138l2b363d4dq1841a07d6c46b589@mail.gmail.com> Message-ID: On Wed, Mar 10, 2010 at 3:33 PM, Gregg Tavares wrote: > > > On Wed, Mar 10, 2010 at 11:38 AM, Kenneth Russell wrote: > >> On Wed, Mar 10, 2010 at 2:05 AM, Carl van Heezik wrote: >> >>> Ken, >>> >>> Attribute locations are also associated to a particular program object, >>> the same >>> way as uniform locations are. Look at the syntax of bindAttribLocation: >>> >>> void *glBindAttribLocation*( GLuint program, GLuint index, const >>> GLchar *name); >>> As you can see the binding is done to a program object. Attribute >>> bindings go >>> into effect if link the program and remain fixed until you link the >>> program again. >>> There is no way you can setup attribute locations once and use them in >>> multiple >>> programs. >>> >> >> True, but consider trying to box these attribute locations, which was what >> the working group considered earlier. There are two programs where you want >> to assign the same location to two attributes (which might have the same >> name, or might not). Since simple integers can no longer be passed in as >> attribute locations, a new API is needed to "create" a boxed attribute >> location which can be used in bindAttributeLocation calls to the two >> programs. The same attribute location object needs to be used later when >> calling glVertexAttribPointer, and validation needs to occur to ensure that >> the attribute location object is legal to use with the currently bound >> program during draw calls. It quickly becomes a mess which is why the >> decision was made to leave attribute locations as simple integers. >> >> I think *boxing should be removed* from the getUniformLocation. >>> >>> 1. Without boxing the API is the same as the OpenGL ES 2.0 standard >>> 2. Without boxing the API is consistent with getAttribLocation >>> 3. Boxing does not add any value for the programmer >>> >> >> A major motivation for adding the boxing was a skinning example developed >> against one of the early WebGL prototypes. The developer made assumptions >> about the layouts of uniform locations (i.e., whether adjacent uniform >> locations were incremented by 1 or by 4) which were legal on one graphics >> card and illegal on another. Boxing adds a measure of safety and improves >> portability. >> > > I didn't see this test but looking at the OpenGL ES 2.0 spec this sounds > like maybe it had something to do with the fact that some implementation of > WebGL was built on top of OpenGL and was not enforcing OpenGL ES 2.0 > compliance. > > The OpenGL ES 2.0 spec says that for example that array elements are at > location + element index. That means if you have a shader with a uniform > Sorry, I've spent the last hour searching for this in the spec and I can't find where I read it. I must have dreamed it. Please ignore my previous comment. > > uniform mat4 skinMats[12]; > > then you should be able to do this. > > loc = ctx.getUniformLocation(program, "skinMats"); > // Set each matrix individually > for (var ii = 0; ii < 12; ++ii) { > ctx.uniformMatrix4fv(loc + ii, 1, false, someMatrices[ii]); > } > > If in some older WebGL implementation that wasn't working then it wasn't > OpenGL ES 2.0 compliant. > > In the current WebGL spec you can't do that at all since "loc + ii" has no > meaning. You have to set the matrices as an array > > ctx.uniformMatrix4fv(loc, *12*, false, someMatrices); > > Or you have to query the location of each element > > > // Set each matrix individually > for (var ii = 0; ii < 12; ++ii) { > loc = ctx.getUniformLocation(program, "skinMats[" + ii + "]); > ctx.uniformMatrix4fv(loc, 1, false, someMatrices[ii]); > } > > > I don't personally have a problem with the boxing. I think it makes things > safer. But if the only reason for it is based on a false assumption that's > not good. > > > > >> >> See Oliver's other email for more discussion about why the boxing was >> added. >> >> I personally think we should retain the boxing of uniforms. Effort is >> needed to port C++ code to JavaScript anyway and this is a relatively minor >> change that is needed. >> >> If you have a suggestion about additions to the specification to make this >> difference in behavior clearer, please post. >> >> -Ken >> >> Current WebGL working draft has inconsistent return values: >>> >>> this.colorLocation = gl.getUniformLocation(program, "color"); >>> if (this.colorLocation != null) >>> { >>> gl.uniform4fv(this.colorLocation, this.color); >>> } >>> this.vertexLocation = gl.getAttribLocation(program, "vertex"); >>> if (this.vertexLocation >= 0) >>> { >>> // Load the vertex data >>> gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); >>> gl.vertexAttribPointer(this.vertexLocation, 2, gl.FLOAT, false, 0, >>> 0); >>> gl.enableVertexAttribArray(this.vertexLocation); >>> } >>> >>> An inconsistent API will lead to more errors than the error you try to >>> prevent >>> by boxing the attribute location. The difference between the two ifstatements >>> is so small its very difficult to find. >>> >>> Boxing has impact on correctly written code, this was working code in >>> C++ >>> OpenGL ES 2.0, it worked in Minefield but did not work in WebKit. It took >>> me >>> a long time to find out that the OpenGL ES standard was not used by >>> WebGL. >>> I had to change the if statement from >>> >>> if (this.colorLocation >= 0) >>> >>> to >>> >>> if (this.colorLocation != null) >>> >>> Of course this little change prevents it from working in Minefield. >>> Remove the boxes >>> and keep things according to the OpenGL ES 2.0 standard. >>> >>> Comment: Nothing in this email is against any person of the working >>> group. I just >>> like the WebGL API as consistent as possible. >>> >>> Best regards, >>> Carl van Heezik >>> >>> >>> >>> >>> >>> >>> >>> >>> Op 9 mrt 2010, om 19:06 heeft Kenneth Russell het volgende geschreven: >>> >>> On Tue, Mar 9, 2010 at 2:18 AM, Carl van Heezik >>> wrote: >>> >>> Vlad / Chris, >>> >>> I understand that getUniformLocation is boxed for a good reason. I expect >>> >>> that getAttribLocation is boxed as well for the same reason. >>> >>> It is more natural for me if they are handled the same way, so everywhere >>> >>> boxed or everywhere plain integers. I have the following code snippet. >>> >>> var program = gl.getParameter(gl.CURRENT_PROGRAM); >>> >>> this.vertexLocation = gl.getAttribLocation(program, 'vertex'); >>> >>> this.normalLocation = gl.getAttribLocation(program, 'normal'); >>> >>> this.colorLocation = gl.getAttribLocation(program, 'color'); >>> >>> >>> In Minefield getParameter returns an int so this code doesn't run there. >>> I >>> >>> believe boxing was decide after implementation in Minefield >>> >>> so you have to check all boxed integer parameters / return values. >>> >>> You bind the attribute locations and use integers there. I use the >>> following >>> >>> code snippet. >>> >>> // Bind attributes >>> >>> for (var i in this.attributes) >>> >>> { >>> >>> gl.bindAttribLocation (this.program, i, this.attributes[i]); >>> >>> } >>> >>> It would have been logical if OpenGL ES 2.0 had a similar function >>> >>> gl.bindUniformLocation but its not. Its nice that you like to protect the >>> >>> programmer by boxing the uniform location but in my opinion WebGL is a >>> low >>> >>> level API. A low level API comes with responsibility. There are many >>> other >>> >>> reasons why programs do not run. So I still vote to remove the boxes en >>> give >>> >>> us the plain integers. If you can't box getAttribLocation, because of >>> >>> bindAttribLocation, you should not box getUniformLocation. Maybe there >>> are >>> >>> other reasons to do boxing, like performance gain, but I can not judge >>> >>> these. >>> >>> >>> getAttributeLocation is not boxed because attribute locations don't >>> work the same way as uniform locations. Uniform locations are >>> conceptually associated with a particular program object, while >>> attribute locations can be used with many program objects (if they are >>> set up via bindAttributeLocation). We had many long discussions about >>> whether to box attribute locations in the working group, and I did an >>> extensive prototype in WebKit, and doing so just doesn't work. >>> >>> On the other hand, boxing uniform locations has no semantic impact on >>> correctly written WebGL code. It only prevents incorrect code from >>> running and has no other adverse side effects. >>> >>> The bugs you point out, for example in getParameter(CURRENT_PROGRAM), >>> should be fixed. I don't think we should change the spec in response >>> to them. >>> >>> -Ken >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From oli...@ Wed Mar 10 16:36:14 2010 From: oli...@ (Oliver Hunt) Date: Wed, 10 Mar 2010 16:36:14 -0800 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: References: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> <921bb11003101138l2b363d4dq1841a07d6c46b589@mail.gmail.com> Message-ID: On Mar 10, 2010, at 4:32 PM, Gregg Tavares wrote: > On Wed, Mar 10, 2010 at 3:33 PM, Gregg Tavares wrote: > I didn't see this test but looking at the OpenGL ES 2.0 spec this sounds like maybe it had something to do with the fact that some implementation of WebGL was built on top of OpenGL and was not enforcing OpenGL ES 2.0 compliance. > > The OpenGL ES 2.0 spec says that for example that array elements are at location + element index. That means if you have a shader with a uniform > > Sorry, I've spent the last hour searching for this in the spec and I can't find where I read it. I must have dreamed it. Please ignore my previous comment. I was wondering about that statement as this issue was with a recent ATI card incrementing location by 4 rather than by 1. Or possibly the other way round :D --Oliver -------------- next part -------------- An HTML attachment was scrubbed... URL: From ced...@ Wed Mar 10 19:45:36 2010 From: ced...@ (Cedric Vivier) Date: Thu, 11 Mar 2010 11:45:36 +0800 Subject: [Public WebGL] Re: Geometry instancing support (ie. draw*Instanced) In-Reply-To: References: Message-ID: New geometry instancing demo featuring skeleton animation (courtesy of @pl4n3) : http://neonux.com/webgl/instancing2.html This demo is using an improved Javascript shim (that fixes the issues pointed out by Kenneth) : http://neonux.com/webgl/webgl-instancing.js This demo is more CPU/JS-bound than the previous one that was mostly about shader usage (which is a realistic use case anyways e.g for particle systems), however the performance figures are still interesting; on a Atom N270 netbook with Geforce 9300M, hardware instancing gives a ~40% speedup over JS pseudo-instancing, native pseudo-instancing (when no hardware/driver support) instancing gives ~12% speedup. Regards, On Mon, Mar 8, 2010 at 2:30 AM, Cedric Vivier wrote: > Hi everyone! > ... > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lee...@ Wed Mar 10 22:35:27 2010 From: lee...@ (Lee Sandberg) Date: Thu, 11 Mar 2010 07:35:27 +0100 Subject: [Public WebGL] Is there C# bindings to WebGL? Message-ID: <9372424f1003102235p4f2bedb4md33ec3dc406b4e90@mail.gmail.com> Hi Is there C# bindings to WebGL? Regards, Lee Sandberg -------------- next part -------------- An HTML attachment was scrubbed... URL: From car...@ Thu Mar 11 01:21:56 2010 From: car...@ (Carl van Heezik) Date: Thu, 11 Mar 2010 10:21:56 +0100 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: References: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> <921bb11003101138l2b363d4dq1841a07d6c46b589@mail.gmail.com> Message-ID: I am surprised that you changed the spec because of one faulty WebGL demo. It would have been more logical to correct the demo. uniform mat4 skinMats[12]; then you are able to do this. var location = gl.getUniformLocation(program, "skinMats"); gl.uniformMatrix4fv(location, 12, false, skinMats); I still think that changing the API to use boxing is going to haunt us for rest the life of WebGL and OpenGL 2.0 ES. Stick to the original OpenGL 2.0 ES API and remove the boxes. The OpenGL 2.0 ES Programming Guide is very clear that the return value from glGetUniformLocation is an integer index NOT a handle! When you google for "getUniformLocation" you already get a few thousand hits. There are a lot examples that use code similar to this: GLint location = glGetUniformLocation(program, uniform); if (location == -1) { // handle the error / throw an exception } Please correct the WebGL Draft spec. I don't see that using an object is safer that using an integer. In both cases you have to validate the input parameter. Boxing is not faster nor safer than using integers. For example you can still do the following: gl.useProgram(programA); var location = gl.getUniformLocation(programA, uniformName); gl.useProgram(programB); gl.Uniform1f(location, uniformValue); location = new Rubbish; gl.Uniform1f(location, uniformValue); With boxing the medicine is worse than the disease. Best regards, Carl van Heezik Op 11 mrt 2010, om 00:33 heeft Gregg Tavares het volgende geschreven: On Wed, Mar 10, 2010 at 11:38 AM, Kenneth Russell wrote: On Wed, Mar 10, 2010 at 2:05 AM, Carl van Heezik wrote: Ken, Attribute locations are also associated to a particular program object, the same way as uniform locations are. Look at the syntax of bindAttribLocation: void glBindAttribLocation( GLuint program, GLuint index, const GLchar *name); As you can see the binding is done to a program object. Attribute bindings go into effect if link the program and remain fixed until you link the program again. There is no way you can setup attribute locations once and use them in multiple programs. True, but consider trying to box these attribute locations, which was what the working group considered earlier. There are two programs where you want to assign the same location to two attributes (which might have the same name, or might not). Since simple integers can no longer be passed in as attribute locations, a new API is needed to "create" a boxed attribute location which can be used in bindAttributeLocation calls to the two programs. The same attribute location object needs to be used later when calling glVertexAttribPointer, and validation needs to occur to ensure that the attribute location object is legal to use with the currently bound program during draw calls. It quickly becomes a mess which is why the decision was made to leave attribute locations as simple integers. I think boxing should be removed from the getUniformLocation. 1. Without boxing the API is the same as the OpenGL ES 2.0 standard 2. Without boxing the API is consistent with getAttribLocation 3. Boxing does not add any value for the programmer A major motivation for adding the boxing was a skinning example developed against one of the early WebGL prototypes. The developer made assumptions about the layouts of uniform locations (i.e., whether adjacent uniform locations were incremented by 1 or by 4) which were legal on one graphics card and illegal on another. Boxing adds a measure of safety and improves portability. I didn't see this test but looking at the OpenGL ES 2.0 spec this sounds like maybe it had something to do with the fact that some implementation of WebGL was built on top of OpenGL and was not enforcing OpenGL ES 2.0 compliance. The OpenGL ES 2.0 spec says that for example that array elements are at location + element index. That means if you have a shader with a uniform uniform mat4 skinMats[12]; then you should be able to do this. loc = ctx.getUniformLocation(program, "skinMats"); // Set each matrix individually for (var ii = 0; ii < 12; ++ii) { ctx.uniformMatrix4fv(loc + ii, 1, false, someMatrices[ii]); } If in some older WebGL implementation that wasn't working then it wasn't OpenGL ES 2.0 compliant. In the current WebGL spec you can't do that at all since "loc + ii" has no meaning. You have to set the matrices as an array ctx.uniformMatrix4fv(loc, 12, false, someMatrices); Or you have to query the location of each element // Set each matrix individually for (var ii = 0; ii < 12; ++ii) { loc = ctx.getUniformLocation(program, "skinMats[" + ii + "]); ctx.uniformMatrix4fv(loc, 1, false, someMatrices[ii]); } I don't personally have a problem with the boxing. I think it makes things safer. But if the only reason for it is based on a false assumption that's not good. See Oliver's other email for more discussion about why the boxing was added. I personally think we should retain the boxing of uniforms. Effort is needed to port C++ code to JavaScript anyway and this is a relatively minor change that is needed. If you have a suggestion about additions to the specification to make this difference in behavior clearer, please post. -Ken Current WebGL working draft has inconsistent return values: this.colorLocation = gl.getUniformLocation(program, "color"); if (this.colorLocation != null) { gl.uniform4fv(this.colorLocation, this.color); } this.vertexLocation = gl.getAttribLocation(program, "vertex"); if (this.vertexLocation >= 0) { // Load the vertex data gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexBuffer); gl.vertexAttribPointer(this.vertexLocation, 2, gl.FLOAT, false, 0, 0); gl.enableVertexAttribArray(this.vertexLocation); } An inconsistent API will lead to more errors than the error you try to prevent by boxing the attribute location. The difference between the two if statements is so small its very difficult to find. Boxing has impact on correctly written code, this was working code in C++ OpenGL ES 2.0, it worked in Minefield but did not work in WebKit. It took me a long time to find out that the OpenGL ES standard was not used by WebGL. I had to change the if statement from if (this.colorLocation >= 0) to if (this.colorLocation != null) Of course this little change prevents it from working in Minefield. Remove the boxes and keep things according to the OpenGL ES 2.0 standard. Comment: Nothing in this email is against any person of the working group. I just like the WebGL API as consistent as possible. Best regards, Carl van Heezik Op 9 mrt 2010, om 19:06 heeft Kenneth Russell het volgende geschreven: On Tue, Mar 9, 2010 at 2:18 AM, Carl van Heezik wrote: > Vlad / Chris, > I understand that getUniformLocation is boxed for a good reason. I expect > that getAttribLocation is boxed as well for the same reason. > It is more natural for me if they are handled the same way, so everywhere > boxed or everywhere plain integers. I have the following code snippet. > var program = gl.getParameter(gl.CURRENT_PROGRAM); > this.vertexLocation = gl.getAttribLocation(program, 'vertex'); > this.normalLocation = gl.getAttribLocation(program, 'normal'); > this.colorLocation = gl.getAttribLocation(program, 'color'); > > In Minefield getParameter returns an int so this code doesn't run there. I > believe boxing was decide after implementation in Minefield > so you have to check all boxed integer parameters / return values. > You bind the attribute locations and use integers there. I use the following > code snippet. > // Bind attributes > for (var i in this.attributes) > { > gl.bindAttribLocation (this.program, i, this.attributes[i]); > } > It would have been logical if OpenGL ES 2.0 had a similar function > gl.bindUniformLocation but its not. Its nice that you like to protect the > programmer by boxing the uniform location but in my opinion WebGL is a low > level API. A low level API comes with responsibility. There are many other > reasons why programs do not run. So I still vote to remove the boxes en give > us the plain integers. If you can't box getAttribLocation, because of > bindAttribLocation, you should not box getUniformLocation. Maybe there are > other reasons to do boxing, like performance gain, but I can not judge > these. getAttributeLocation is not boxed because attribute locations don't work the same way as uniform locations. Uniform locations are conceptually associated with a particular program object, while attribute locations can be used with many program objects (if they are set up via bindAttributeLocation). We had many long discussions about whether to box attribute locations in the working group, and I did an extensive prototype in WebKit, and doing so just doesn't work. On the other hand, boxing uniform locations has no semantic impact on correctly written WebGL code. It only prevents incorrect code from running and has no other adverse side effects. The bugs you point out, for example in getParameter(CURRENT_PROGRAM), should be fixed. I don't think we should change the spec in response to them. -Ken -------------- next part -------------- An HTML attachment was scrubbed... URL: From ste...@ Thu Mar 11 01:47:29 2010 From: ste...@ (stephen white) Date: Thu, 11 Mar 2010 20:17:29 +1030 Subject: [Public WebGL] getParameter, getAttribLocation References: Message-ID: On 11/03/2010, at 6:08 AM, Kenneth Russell wrote: > A major motivation for adding the boxing was a skinning example > developed against one of the early WebGL prototypes. The developer > made assumptions about the layouts of uniform locations (i.e., > whether adjacent uniform locations were incremented by 1 or by 4) > which were legal on one graphics card and illegal on another. Boxing > adds a measure of safety and improves portability. That sounds like the developer needs to fix it, not the specification. The boxing does not entirely address this issue, and creates new issues which will be much more likely to impact the developer. I think the badly written demo is a very small and minor reason, which has resulted in WebGL not matching the OpenGL ES specification... and this boxing should be reversed out of the specification. For example, I've been reading messages about this boxing... and yet if you asked me I would not be able to tell you which one you were supposed to do >= instead of null, or which one was the boxed one. Consistency is so much more valuable. -- steve...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From oli...@ Thu Mar 11 01:54:56 2010 From: oli...@ (Oliver Hunt) Date: Thu, 11 Mar 2010 01:54:56 -0800 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: References: <921bb11003091006g71aeed43y952dba203e99e56f@mail.gmail.com> <7EE68102-FEB0-4991-82F9-52F07167E8B3@microcan.nl> <921bb11003101138l2b363d4dq1841a07d6c46b589@mail.gmail.com> Message-ID: <20391D20-6F05-4226-AEFC-EC91E48494CB@apple.com> On Mar 11, 2010, at 1:21 AM, Carl van Heezik wrote: > I am surprised that you changed the spec because of one faulty WebGL demo. > It would have been more logical to correct the demo. We didn't, we had already been discussing the problems of a purely integer based system, and this reinforced one of the existing issues: You _cannot_ leave behaviour undefined. If you wanted WebGL to return integers the spec would have to define the exact algorithm for allocating integer ids to uniform locations, which would require that every implementation maintain its own internal mapping from the API provided locations to the actual implementation provided locations, and then would have to correctly manage the lifetime and error cases for all of those. > Please correct the WebGL Draft spec. I don't see that using an object is safer > that using an integer. In both cases you have to validate the input parameter. > Boxing is not faster nor safer than using integers. For example you can still do > the following: > > gl.useProgram(programA); > var location = gl.getUniformLocation(programA, uniformName); > > gl.useProgram(programB); > gl.Uniform1f(location, uniformValue); > > location = new Rubbish; > gl.Uniform1f(location, uniformValue); > > > With boxing the medicine is worse than the disease. In your example what makes boxing worse than raw integers? What would happen with integer locations (we know this because it took mere weeks for it to happen with WebGL, and has repeatedly happened in every other specification that has similar undefined-ness) is that people will develop there application, then they will test their application across all the browsers that they care about (assuming a good developer and not someone who only tests one browser) and then will release it. At that point they get told that their application doesn't work in some browser that they already tested. So they get their user to try another browser, and it doesn't work their, and eventually after many blind changes they get it to work or maybe they don't and just give up. It turns out that they had made an incorrect assumption about the ordering of uniform locations, yes you can say "that's the developers fault" but a) they have no way of testing other hardware, and b) browser would have to make it work, leading to yet another case where they eventually have to implement vastly complex systems in order to ensure matching behaviour in spite of platform differences. You may want to disagree with what this decisions, but this is the reality of development on the web. We spent many weeks discussing this specific issue, it was in fact one of the more time consuming issues out of the entire first draft and we concluded that this is necessary in order to provide a consistent platform for developers. --Oliver -------------- next part -------------- An HTML attachment was scrubbed... URL: From ste...@ Thu Mar 11 02:09:43 2010 From: ste...@ (stephen white) Date: Thu, 11 Mar 2010 20:39:43 +1030 Subject: [Public WebGL] WebGL specification is for web developers Message-ID: Given that the specification is willing to be changed for the web environment, I really think we need to look at the bigger picture of who this is for and why this is being done. For example, I'm quite involved in WebGL and yet I haven't seen an analysis of security risks. With direct access to the hardware, including uploading arbitrary code, what level of security exists and what damage could be done by malicious code? Can graphics cards be virtualised to sandbox malicious code, or will allowing WebGL result in opening large holes? Part of the reason for OpenGL's success is due to its obsolete and slow path of issuing simple instructions and watching things happen. Without this, OpenGL would not have acquired anywhere near as many users and would have quickly died on launch. OpenGL ES has removed these functions and the absence can be _compensated_ by using other API. Even with my background in OpenGL, I have found OpenGL ES to be painfully formidable in the way that it has deprived me of some approaches I liked. I agree that there are valid technical reasons for keeping the matrix calculations in Javascript. In that case, please implement the same API in Javascript instead of native code. The difference that is worth achieving is the assurance that this code has been implemented with best practice and matches OpenGL 1.1 documentation. For example, look at the following: http://code.google.com/p/ewgl-matrices/issues/detail?id=20 Yet I can't just use this library, because I would need to investigate how it achieves this speed (even faster than Vlad's code, and yet Vlad is one of the WebGL originators - so which is more official?). Why doesn't it use a standard construction function? Why does it use a normal array with "elements", instead of updating a WebGLArray? Those extra considerations are what I would avoid if the standard functions for OpenGL were implemented in WebGL. I would just use those functions and get on with things instead of having to search for libraries and go into pros and cons analysis of whatever I find, including needing to check communities and mailing lists. There's a great deal of documentation for OpenGL 1.1, and sitting there in a web browser typing in stuff from books and seeing it work is going to be a hell of a big boost to WebGL. The simple interface and the immediate feedback is going to make a lot of people happy. Writing it in Javascript instead of native code is fine, as long as it isn't a plug-in or something to load. Make it standard! -- steve...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Thu Mar 11 02:42:48 2010 From: ced...@ (Cedric Vivier) Date: Thu, 11 Mar 2010 18:42:48 +0800 Subject: [Public WebGL] WebGL specification is for web developers In-Reply-To: References: Message-ID: Hi Stephen, On Thu, Mar 11, 2010 at 6:09 PM, stephen white wrote: > Yet I can't just use this library, because I would need to investigate how > it achieves this speed (even faster than Vlad's code, and yet Vlad is one of > the WebGL originators - so which is more official?). > Does it need to be "official"? Use the library that fits your app the best, there is plenty, there will be more. Maybe you can even avoid to do full matrix multiplications in the first place in many situations (such as constrained rotations around an axis etc), using quaternions, offloading to shaders, etc. If those approaches are not workable for you then you can just use one of the JS-based libraries, speed is not that bad (less than twice slower than native code last time I checked) and will get better as JS engines improve. If you can present a demo that is JS-bound I'm sure Javascript implementors would be interested to use it as a testcase for optimization. > Those extra considerations are what I would avoid if the standard functions > for OpenGL were implemented in WebGL. > Those are obsoleted functions in modern OpenGL and I think even removed from core profile in 3.2 ... they also never have been standard OpenGL ES 2.0 functions anyways. You can think of these functions as ruins from a lost world ;-) (the pre-programmable pipeline world). There's a great deal of documentation for OpenGL 1.1, and sitting there in a > web browser typing in stuff from books and seeing it work is going to be a > hell of a big boost to WebGL. There is also documentation for writing modern OpenGL (and OpenGL ES 2.0) code. There will be more and more documentation about WebGL, early adopters of any new technology have to bear with a perceived lack of documentation for some time. By that analogy we would all be writing Cobol or Fortran ;-) Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From cal...@ Thu Mar 11 02:44:19 2010 From: cal...@ (Mark Callow) Date: Thu, 11 Mar 2010 19:44:19 +0900 Subject: [Public WebGL] Is there C# bindings to WebGL? In-Reply-To: <9372424f1003102235p4f2bedb4md33ec3dc406b4e90@mail.gmail.com> References: <9372424f1003102235p4f2bedb4md33ec3dc406b4e90@mail.gmail.com> Message-ID: <4B98C983.9060605@hicorp.co.jp> Given that WebGL is Javascript bindings to OpenGL ES, the proper question to ask is "Are there C# bindings to OpenGL ES." The answer is no. Regards -Mark On 11/03/2010 15:35, Lee Sandberg wrote: > Hi > > Is there C# bindings to WebGL? > > Regards, > > Lee Sandberg > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: callow_mark.vcf Type: text/x-vcard Size: 398 bytes Desc: not available URL: From lee...@ Thu Mar 11 02:53:37 2010 From: lee...@ (Lee Sandberg) Date: Thu, 11 Mar 2010 11:53:37 +0100 Subject: [Public WebGL] Is there C# bindings to WebGL? In-Reply-To: <4B98C983.9060605@hicorp.co.jp> References: <9372424f1003102235p4f2bedb4md33ec3dc406b4e90@mail.gmail.com> <4B98C983.9060605@hicorp.co.jp> Message-ID: <9372424f1003110253q705d3c14q4df3426b5cfc9656@mail.gmail.com> Hi I thought WebGL was browser Open ES access in general not just for Javascript. Lee On Thu, Mar 11, 2010 at 11:44 AM, Mark Callow wrote: > Given that WebGL is Javascript bindings to OpenGL ES, the proper question > to ask is "Are there C# bindings to OpenGL ES." The answer is no. > > Regards > > -Mark > > > > On 11/03/2010 15:35, Lee Sandberg wrote: > > Hi > > Is there C# bindings to WebGL? > > Regards, > > Lee Sandberg > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Thu Mar 11 06:52:25 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 06:52:25 -0800 Subject: [Public WebGL] Extension mechanism language added to spec Message-ID: I've added the agreed upon language for the extension mechanism - section 5.15.14. Please review. ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Thu Mar 11 07:01:00 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 07:01:00 -0800 Subject: [Public WebGL] Reserve "webgl_" prefix in shaders In-Reply-To: <921bb11003101604w5703f64dle5abd953b04fe287@mail.gmail.com> References: <921bb11003091815t431e510em4e9585c2435a0851@mail.gmail.com> <921bb11003101604w5703f64dle5abd953b04fe287@mail.gmail.com> Message-ID: On Mar 10, 2010, at 4:04 PM, Kenneth Russell wrote: > On Tue, Mar 9, 2010 at 6:37 PM, Cedric Vivier wrote: >> On Wed, Mar 10, 2010 at 10:15 AM, Kenneth Russell wrote: >>> >>> What would you think about using "_webgl_" instead? Is your intent >>> that user code can refer to these identifiers? >> >> My intent is primarily for potential internal use by WebGL implementations >> so in that case "_webgl_" prefix may indeed sound better. >> However it might be useful for future WebGL-specific extensions to introduce >> identifiers that are to be referred to by user code, so we should not close >> the door on that imho. >> >> I suggest we either reserve both "_webgl_" and "webgl_" prefixes or only the >> latter. > > OK, let's reserve both prefixes. I've committed spec changes. Please comment. > I have no problem with this definition. But the words in the spec aren't quite right. Is this a hard requirement? If so, it has to say "shall" or "must" and has to state the consequences of using these prefixes. If it is just a recommendation, it should say "should not" or the equivalent. We should probably make it a requirement, just to avoid browser inconsistency. So maybe the words should be: "In addition to the reserved identifiers in the aforementioned specification, identifiers starting with "webgl_" and "_webgl_" are reserved for use by WebGL. A shader which has user-defined identifiers starting with these prefixes must not be allowed to load." ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Thu Mar 11 07:09:15 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 07:09:15 -0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> Message-ID: <6EF5FD0D-96E1-4F64-92ED-4A12FFDC3333@apple.com> On Mar 8, 2010, at 6:15 PM, Kenneth Russell wrote: > On Sun, Mar 7, 2010 at 10:30 AM, Cedric Vivier wrote: >> Hi everyone! >> >> As we all know, the less draw calls and render state changes the better the >> performance, offloading calculations to the GPU is also a big win usually; >> both former optimizations are particularly true with WebGL where JS<->native >> calls overhead can be significant and JS math performance is not as good as >> native code obviously. >> >> Geometry instancing is a popular rendering technique that allows very >> efficient drawing of objects multiple times through the re-use of vertex >> data with only one draw call as well as enabling easy offloading of >> per-instance transformations/calculations to vertex shaders. >> Originally introduced as an OpenGL 2.0+ extension GL_EXT_draw_instanced >> years ago, instancing support has been added in core OpenGL 3.1+ and D3D9+ >> has equivalent support. >> >> Of course WebGL is largely inspired by OpenGL ES, which does not support >> instancing (as of 2.0). >> However when support is not available, it is possible to implement it in >> software, by looping regular drawArrays/drawElements for each instance after >> incrementing an uniform instance index (technique known as pseudo >> instancing). >> >> I propose therefore to add two methods to the WebGL context: >> >> void drawArraysInstanced(in GLenum mode, in GLint first, in GLsizei count, >> in GLsizei primcount) >> void drawElementsInstanced(in GLenum mode, in GLsizei count, in GLenum type, >> in GLsizeiptr offset, in GLsizei primcount) >> >> They have the same signature as drawArrays/drawElements except `primcount' >> added as last argument. >> >> >> As a proof of concept, I've implemented this proposal on Firefox. >> Demo and patch available at http://neonux.com/webgl/instancing.html >> >> On the simple demo above, with native pseudo instancing we get nice 20% >> speedup compared to the JS-based pseudo instancing shim, when hardware >> instancing is available we get a ridiculously awesome _23x speedup_, oh the >> possibilities! (hello dense forests, crowds, complex particle systems, >> whatever) >> >> Which means: >> - with no hardware support [as is the case on OpenGL ES 2.0] this enables >> more complex scenes thanks to faster pseudo instancing implementation than >> what is possible with JavaScript (no overhead of at least 2x instances >> JS<->native calls + checks at every instance). >> - with hardware support, as it is the case on most WebGL-capable >> laptop/desktop GPUs (and likely in a future version of OpenGL ES or an ES >> extension?) this addition enables WebGL to render scenes that are _much_ >> more complex. >> - in both cases, it provides an easy known API to the developer who does not >> have to implement its own pseudo-instancing replacement that could never >> hope to be hardware-accelerated. >> >> For the reasons cited above, I believe this addition, though a slight >> deviation from ES 2.0 (but not from OpenGL in general), would be very >> valuable to add in WebGL. >> A short paragraph about it would be added in the "Differences from OpenGL ES >> 2.0" section. >> >> Opinions? I really like the idea of this functionality. Seems like a total win, even on systems that do not support the extension. Taking into consideration Ken's comments below, I think we should add it. Can we talk about it at today's conf call? >> >> Regards, >> >> [references] >> http://en.wikipedia.org/wiki/Geometry_instancing >> http://www.opengl.org/registry/specs/EXT/draw_instanced.txt >> OpenGL 3.1 spec (no html doc available on Khronos website?) >> http://msdn.microsoft.com/en-us/library/ee418549%28VS.85%29.aspx > > This is a good idea in general, and kudos for prototyping it. One > comment on your prototype, which is that it is illegal according to > the GLSL (and GLSL ES) semantics to use any identifier starting with > "gl_". In order for your prototype to be semantically correct, then > when you synthesize the InstanceID uniform variable, you would need to > choose a different prefix; and when hardware instancing is not > supported, you would need to rename any uses of "gl_InstanceID" in the > shaders to your new variable name. This isn't quite as simple as a > search and replace, since if your variable name is "_webgl_InstanceID" > then you shouldn't rename any user identifier called for example > "my_webgl_InstanceID". > > Right now the various browser vendors have a lot of work in the coming > months to make the various implementations compliant to the existing > spec, so I don't think we should add this to version 1.0 of the spec > but add it in for example a version 1.1. However, if you would be > willing to push ahead the implementation for say both Firefox and > WebKit, it would make adding this entry point to the spec earlier a > much easier decision to make. Regardless, it would be great if you > would file a bug / RFE (request for enhancement) against WebGL on the > Khronos Bugzilla instance, http://www.khronos.org/bugzilla/ . > > -Ken > ----------------------------------------------------------- > You are currently subscribe to public_webgl...@ > To unsubscribe, send an email to majordomo...@ with > the following command in the body of your email: > ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Thu Mar 11 07:15:36 2010 From: ced...@ (Cedric Vivier) Date: Thu, 11 Mar 2010 23:15:36 +0800 Subject: [Public WebGL] Extension mechanism language added to spec In-Reply-To: References: Message-ID: Hi Chris, On Thu, Mar 11, 2010 at 10:52 PM, Chris Marrin wrote: > I've added the agreed upon language for the extension mechanism - section > 5.15.14. Please review. > Didn't we agree on the list to s/getExtensionList/getSupportedExtensions ?;-) Cheers, -------------- next part -------------- An HTML attachment was scrubbed... URL: From ced...@ Thu Mar 11 07:20:36 2010 From: ced...@ (Cedric Vivier) Date: Thu, 11 Mar 2010 23:20:36 +0800 Subject: [Public WebGL] Reserve "webgl_" prefix in shaders In-Reply-To: References: <921bb11003091815t431e510em4e9585c2435a0851@mail.gmail.com> <921bb11003101604w5703f64dle5abd953b04fe287@mail.gmail.com> Message-ID: On Thu, Mar 11, 2010 at 11:01 PM, Chris Marrin wrote: > > We should probably make it a requirement, just to avoid browser > inconsistency. So maybe the words should be: > > "In addition to the reserved identifiers in the aforementioned > specification, identifiers starting with "webgl_" and "_webgl_" > are reserved for use by WebGL. A shader which has user-defined > identifiers starting with these prefixes must not be allowed > to load." > +1 I think the second sentence would be clearer as: "A shader which declares a function or a variable starting with these prefixes must not be allowed to load." Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Thu Mar 11 07:24:12 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 07:24:12 -0800 Subject: [Public WebGL] Retrieving number of texture channels In-Reply-To: <4B947401.6040300@hicorp.co.jp> References: <4B82C1D3.6040708@igd.fraunhofer.de> <921bb11002221136i400c512br408c7af30a8831ba@mail.gmail.com> <4B833BA5.7050300@hicorp.co.jp> <43EA0253-2188-4060-AAF3-1A86DE569A0A@apple.com> <4B8487F7.9000201@hicorp.co.jp> <559D1295-9606-469C-9148-4DB7F477C1CA@apple.com> <921bb11003021544y20547d64u77c162bd6de455ce@mail.gmail.com> <4B90572D.7070309@mozilla.com> <66A65B0A-B6FB-454C-AF77-A0B48F5A53ED@apple.com> <4B947401.6040300@hicorp.co.jp> Message-ID: <0CFDAC20-A4EE-44CA-9CBD-3761B22D3218@apple.com> On Mar 7, 2010, at 7:50 PM, Mark Callow wrote: > > Regards > > -Mark > > > > On 06/03/2010 08:13, Chris Marrin wrote: >> >> On Mar 4, 2010, at 4:58 PM, Vladimir Vukicevic wrote: >> >> >>> ... >>> >>> That doesn't help for more complex formats like png and jpeg though, because it would be silly to do that when the browser already has native support (though certainly possible). But, in this case, the browser's native support is really geared towards the current use of images in HTML; for example, for PNGs, we expand out all images to 32-bit ARGB with premultiplied alpha because that's what we want as an input format for compositing. >>> >>> Now, there's nothing that prevents us from storing the original format; we just haven't had a need to do that so far. For example, I can see something like: >>> >>> var img = new Image(); >>> img.keepOriginalFormat = true; >>> img.src = "http://..../foo.png"; >>> >>> and then having accessors like img.channelCount, img.channelSize, img.channelFormat, etc. If that image were ever to be rendered directly, we'd could do the conversion at render time. But, as I said, this hasn't been needed on the web so far, but I think we do have a valid use case for it here. I'd rather see a proposal evolve in this direction rather than any conversion at texImage2D time, because doing that will likely require browsers to not optimize for their compositing format for /any/ images, and to understand various formats anyway, without surfacing that data to content script. (And possibly introducing a double conversion if not, e.g. from 1-channel to rgb and back at texImage2D time.) >>> >> I don't think the original format is important enough in sufficient cases to make the above API useful. It just so happens that X3D uses the source format to determine what type of texture will be loaded. But I don't think we should follow that technique. It can lead to browser inconsistencies. If you had to pass (implicitly or explicitly) the desired internal format to texImage2D, you'd need a converter to and from each of the supported formats. There aren't that many supported formats in GLES, so the table of conversions is not large. So I think we should do it and never rely on the source format to determine the type of texture we load. >> >> > I think Vlad's suggestion is very useful. First of all the X3D case is not primarily about deciding which texture format to load, it is used to determine which shader to run (modulate diffuse-color or not). Second it provides a way for applications to use HTMLImageElements for things other than RGB{,A} textures without causing the potential pitfalls and unnecessary data conversions described by Vlad. The application is not deciding anything from the texture format; it is telling you (the implementer) how it intends using the image data, thereby allowing for a much more efficient and faster processing of its images. The problem is that some browsers may not keep this information around and it might be extremely difficult to change the implementation to provide it. As far as using incoming textures to hold data other that color is fraught with problems. What if an implementation stores all images in 16 bit 565 format for efficiency and because that's all their 2D renderer needs. Even if we expand that image back to 24 bits for loading into the texture, the data loss would make it impossible to use this image as data. I don't think we can or should require maintaining the original image format of an HTMLImageElement. We have to accept that all HTMLImageElements (and HTMLVideoElements and HTMLCanvasElements) are conceptually 32 bit RGBA regardless of their original source format. If we add an internalformat parameter and an implementation can avoid some conversion by knowing that the original image was single channel and the texImage2D call is asking for a single channel image, then that's an optimization. I believe the spec should be in terms of converting RGBA to the desired internalformat. We certainly need the ability to load non-color texture data. But for now I think that has to be done with the TypedArray variant of texImage2D and probably less than optimal techniques for loading that TypedArray. ----- ~Chris cmarrin...@ -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Thu Mar 11 07:34:18 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 07:34:18 -0800 Subject: [Public WebGL] Native implementation of common Matrix and Vector functions In-Reply-To: References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <35958F96-4D08-4B96-8603-DDD8C31EF0ED@microcan.nl> Message-ID: On Mar 8, 2010, at 8:08 AM, Cedric Vivier wrote: > On Mon, Mar 8, 2010 at 9:58 PM, Carl van Heezik wrote: > I agree that offloading matrix calculations to shaders is in some cases an option. But how would you implement a skinned character with a lot of bones (rotation matrices). You have to setup the rotation matrices somewhere, if you do this in the shader you must implement multiple shaders one for computing the rotation matrices and one that does the skinning. How do you get the matrices from one shader to the other. > > > I agree you cannot always offload everything to shaders, but it is likely possible to offload the most expensive stuff there. > There is plenty of ways to do skinning, including not even using matrices but quaternions for bones, such could be stored in a uniform array updated at each movement etc... > I assume it is in part the rationale why matrix manipulation functions have been removed from ES 2.0, the one-matrix-API-fits-all does not really make sense when having a programmable pipeline that enables "optimal" customized solutions. This was discussed long ago (on the private list) and it was decided not to do it for the first release. But this is a good discussion to have on this list. I was the proponent of the proposal at the time, and I did some informal performance tests. I made my own implementation of a 4x4 matrix class (which is in the public repo) and compared it with a native implementation we have in WebKit already. The difference was not enough to make me want to champion it any more. About the comments of doing the heavy lifting in the shader. It's true that you have to setup the initial matrices to do character animation in the CPU. But that setup is insignificant compared to the per-frame cost of doing the matrix morphing in the GPU. One thing I thing we will need eventually is a way to efficiently get a CSSMatrix into WebGL. CSSMatrix is part of the CSS Transform spec my team is shepherding through HTML 5 right now. It allows for animation of the matrices which would be very useful to leverage in WebGL. But today it is pretty inefficient to get that matrix into WebGL. But that sort of work can come later. ----- ~Chris cmarrin...@ -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Thu Mar 11 09:14:47 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 09:14:47 -0800 Subject: [Public WebGL] getParameter, getAttribLocation In-Reply-To: References: Message-ID: <6A253DE2-64AC-440C-9F10-2C4EE902C5F9@apple.com> On Mar 11, 2010, at 1:47 AM, stephen white wrote: > On 11/03/2010, at 6:08 AM, Kenneth Russell wrote: >> A major motivation for adding the boxing was a skinning example developed against one of the early WebGL prototypes. The developer made assumptions about the layouts of uniform locations (i.e., whether adjacent uniform locations were incremented by 1 or by 4) which were legal on one graphics card and illegal on another. Boxing adds a measure of safety and improves portability. > > That sounds like the developer needs to fix it, not the specification. The boxing does not entirely address this issue, and creates new issues which will be much more likely to impact the developer. > > I think the badly written demo is a very small and minor reason, which has resulted in WebGL not matching the OpenGL ES specification... and this boxing should be reversed out of the specification. > > For example, I've been reading messages about this boxing... and yet if you asked me I would not be able to tell you which one you were supposed to do >= instead of null, or which one was the boxed one. > > Consistency is so much more valuable. Boxing Uniforms actually makes the spec more consistent. I am not an expert on the topic, but I remember the original discussion that led to us boxing uniforms. We had good input from people like Jon Leech, who is an expert on the topic. The argument goes something like this: Uniforms and Vertex Attribs are fundamentally different things. Vertex Attribs are part of the GL state, Uniforms are part of a shader program. It is legal in GL to get a vertex attrib location index (using one of the two legal methods of doing so) and then perform addition on that index to obtain the index of other vertex attribs. This is not legal for uniforms and that is the source of the problem that raised this issue in the first place. An author created (for example) two uniforms, one after the other, and then got the index of the first, added 1 to it and expected to get the index of the second. That is often, but not always true, and that is what caused us to box the uniforms. I still think that is a valid decision. We did in fact try to box attribs. But with the requirement of being able to offset returned indexes, it because too unwieldy to do so. We decided that, since you can perform arithmetic on attrib indexes, they are true numeric indexes and should remain as such. Uniform "names" on the other hand, do not have any of the characteristics of numeric indexes. They are actually more similar to the integer names used to refer to textures and VBOs in OpenGL. Since we box those (for good reason), we decided that it made sense to box uniforms. As I said before, I stand behind that decision. ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Thu Mar 11 09:27:20 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 09:27:20 -0800 Subject: [Public WebGL] WebGL specification is for web developers In-Reply-To: References: Message-ID: On Mar 11, 2010, at 2:09 AM, stephen white wrote: > Given that the specification is willing to be changed for the web environment, I really think we need to look at the bigger picture of who this is for and why this is being done. For example, I'm quite involved in WebGL and yet I haven't seen an analysis of security risks. With direct access to the hardware, including uploading arbitrary code, what level of security exists and what damage could be done by malicious code? Can graphics cards be virtualised to sandbox malicious code, or will allowing WebGL result in opening large holes? > > Part of the reason for OpenGL's success is due to its obsolete and slow path of issuing simple instructions and watching things happen. Without this, OpenGL would not have acquired anywhere near as many users and would have quickly died on launch. OpenGL ES has removed these functions and the absence can be _compensated_ by using other API. Even with my background in OpenGL, I have found OpenGL ES to be painfully formidable in the way that it has deprived me of some approaches I liked. > > I agree that there are valid technical reasons for keeping the matrix calculations in Javascript. In that case, please implement the same API in Javascript instead of native code. The difference that is worth achieving is the assurance that this code has been implemented with best practice and matches OpenGL 1.1 documentation. For example, look at the following: > > http://code.google.com/p/ewgl-matrices/issues/detail?id=20 > > Yet I can't just use this library, because I would need to investigate how it achieves this speed (even faster than Vlad's code, and yet Vlad is one of the WebGL originators - so which is more official?). Why doesn't it use a standard construction function? Why does it use a normal array with "elements", instead of updating a WebGLArray? I'm not sure what you're asking for here. I don't think Vlad would claim that his matrix library is "official". There are at least 6 such matrix libraries in existence. Many are derived from each other and optimize for different tasks. It would be very interesting to see the performance metrics of a matrix library that used a WebGLFloatArray. It would be fast in loading the matrix into WebGL, but maybe slower in the actual computations. But in the future some browsers (like WebKit) will probably add optimizations to the TypedArrays to make them even faster than the Array class. All of these things are possible and people should and are doing them. One of those people could be you :-) > > Those extra considerations are what I would avoid if the standard functions for OpenGL were implemented in WebGL. I would just use those functions and get on with things instead of having to search for libraries and go into pros and cons analysis of whatever I find, including needing to check communities and mailing lists. > > There's a great deal of documentation for OpenGL 1.1, and sitting there in a web browser typing in stuff from books and seeing it work is going to be a hell of a big boost to WebGL. The simple interface and the immediate feedback is going to make a lot of people happy. Writing it in Javascript instead of native code is fine, as long as it isn't a plug-in or something to load. Make it standard! It would be really hard to make a complete OpenGL ES 1.1 library for WebGL. It would have to deal with all combinations of all features of the API, which means it would probably have to generate shaders and the like. And doing that might not be the best approach. It would be easy to make an JS API that had some of the characteristics of OpenGL ES 1.1, or even the API models of older versions of desktop OpenGL. Such things will no doubt have value and will eventually exist. It's the early days. You are a pioneer. You have to be willing to cut down trees and build log cabins and clear the fields before the place is livable. Or are you one of them city slickers who need yer indoor plumbin' and yer hot water and yer 500 channel cable TV set? :-) ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Thu Mar 11 09:30:53 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 09:30:53 -0800 Subject: [Public WebGL] Is there C# bindings to WebGL? In-Reply-To: <9372424f1003110253q705d3c14q4df3426b5cfc9656@mail.gmail.com> References: <9372424f1003102235p4f2bedb4md33ec3dc406b4e90@mail.gmail.com> <4B98C983.9060605@hicorp.co.jp> <9372424f1003110253q705d3c14q4df3426b5cfc9656@mail.gmail.com> Message-ID: On Mar 11, 2010, at 2:53 AM, Lee Sandberg wrote: > Hi > > I thought WebGL was browser Open ES access in general not just for Javascript. Right. The better question to ask would actually be "are there C# bindings to the DOM in Web Browsers. The answer there is "it depends". WebKit provides Objective C bindings to the DOM for embedding apps. And there is a fairly robust binding capability built into WebKit. I'm sure the same is true of other browsers. So it's conceivable that someone could write a C# binding for some browser's DOM. I just don't know if any. ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Thu Mar 11 09:33:54 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 09:33:54 -0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: <96977D0471234C5AB5BAA52B451CDE2E@joe1446a4150a8> References: <96977D0471234C5AB5BAA52B451CDE2E@joe1446a4150a8> Message-ID: <9FD6680F-8D29-4ABC-A4A8-262BC542977D@apple.com> On Mar 7, 2010, at 11:21 AM, Joe D Williams wrote: >> > Opinions? > > Great! very needed (authoring/delivery opinon). > I would understand this to be great hook for abstractions, also. > Like X3D DEF/USE structures, at least for geometry (or more?). I think this is much more. The semantics of DEF/USE limit its ability to benefit from geometry instancing, which is very constrained and therefore subject to lots of performance optimizations. In fact, those optimizations are really limited only by the efficiency of your shader and its ability to do interesting things with gl_InstanceID (or whatever we would end up calling it). ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Thu Mar 11 09:35:28 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 09:35:28 -0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> Message-ID: On Mar 8, 2010, at 6:29 PM, Cedric Vivier wrote: > Hi Kenneth, > > On Tue, Mar 9, 2010 at 10:15 AM, Kenneth Russell wrote: > This is a good idea in general, and kudos for prototyping it. One > comment on your prototype, which is that it is illegal according to > the GLSL (and GLSL ES) semantics to use any identifier starting with > "gl_". In order for your prototype to be semantically correct, then > when you synthesize the InstanceID uniform variable, you would need to > choose a different prefix; > > Oh yeah indeed, I changed this in the JS-based shim (which uses "webgl_InstanceID") but forgot to update the native pseudo-instancing implementation (which works on recent NVidia drivers, maybe should file a bug there). > Of course this is just quick prototyping, a "production" version would use a smarter replace algorithm (just a nice regexp might do the trick though). But doesn't it have to be called gl_InstanceID to be able to take advantage of a native implementation of the geometry instancing extension? -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Thu Mar 11 09:37:35 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 09:37:35 -0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: <921bb11003091054g61d63434m174389e17465d6a2@mail.gmail.com> References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> <921bb11003091054g61d63434m174389e17465d6a2@mail.gmail.com> Message-ID: <4231566F-0690-48B7-B9BB-7FD43B860546@apple.com> On Mar 9, 2010, at 10:54 AM, Kenneth Russell wrote: > On Mon, Mar 8, 2010 at 6:29 PM, Cedric Vivier wrote: >> Hi Kenneth, >> >> On Tue, Mar 9, 2010 at 10:15 AM, Kenneth Russell wrote: >>> >>> This is a good idea in general, and kudos for prototyping it. One >>> comment on your prototype, which is that it is illegal according to >>> the GLSL (and GLSL ES) semantics to use any identifier starting with >>> "gl_". In order for your prototype to be semantically correct, then >>> when you synthesize the InstanceID uniform variable, you would need to >>> choose a different prefix; >> >> Oh yeah indeed, I changed this in the JS-based shim (which uses >> "webgl_InstanceID") but forgot to update the native pseudo-instancing >> implementation (which works on recent NVidia drivers, maybe should file a >> bug there). >> Of course this is just quick prototyping, a "production" version would use a >> smarter replace algorithm (just a nice regexp might do the trick though). >> >> >>> >>> Right now the various browser vendors have a lot of work in the coming >>> months to make the various implementations compliant to the existing >>> spec, so I don't think we should add this to version 1.0 of the spec >>> but add it in for example a version 1.1. However, if you would be >>> willing to push ahead the implementation for say both Firefox and >>> WebKit, >> >> I'm willing to do it once consensus is reached :) >> With regards to GLSL ES compliance checking we'll somehow need shader source >> parser/transformation code and thus the point above would be trivial to >> resolve I assume? > > Yes, a parser and translator will definitely be needed, and having one > would make this task easier. However, because the transformations you > need to do are relatively simple, you could probably encapsulate them > in a simple class that could be used by the various WebGL > implementations. Ah, so then the intent would be that if we called the instancing variable webgl_InstanceID, the translator would look for that and change it to gl_InstanceID in implementations supporting it? That would probably work. ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Thu Mar 11 09:51:53 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 09:51:53 -0800 Subject: [Public WebGL] Re: Geometry instancing support (ie. draw*Instanced) In-Reply-To: References: Message-ID: <220863C6-AB9B-42AE-A79E-13FFC10755F0@apple.com> On Mar 10, 2010, at 7:45 PM, Cedric Vivier wrote: > New geometry instancing demo featuring skeleton animation (courtesy of @pl4n3) : > http://neonux.com/webgl/instancing2.html > > This demo is using an improved Javascript shim (that fixes the issues pointed out by Kenneth) : > http://neonux.com/webgl/webgl-instancing.js > > This demo is more CPU/JS-bound than the previous one that was mostly about shader usage (which is a realistic use case anyways e.g for particle systems), however the performance figures are still interesting; on a Atom N270 netbook with Geforce 9300M, hardware instancing gives a ~40% speedup over JS pseudo-instancing, native pseudo-instancing (when no hardware/driver support) instancing gives ~12% speedup. This is extremely cool and a compelling motivator for adding this feature. I'm ready to add this to the spec and do an implementation in WebKit. Who's with me? :-) This is extremely cool and a compelling motivator for adding this feature. I think we should seriously consider it for 1.0. This is not to say that we should be adding a bunch of new features to WebGL at this point. I am fully committed to buttoning up the spec so we can get to 1.0. But given the clear win of this technique, the useful applications it has in the field, and the fact that it is easily emulated in software, I think it should make it in. If we don't want to hold up 1.0 for this, it could be a good first test of the new extension mechanism. We could do an experimental implementation as "webkit_draw_instanced". The returned object would have the two new calls. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ced...@ Thu Mar 11 09:56:01 2010 From: ced...@ (Cedric Vivier) Date: Fri, 12 Mar 2010 01:56:01 +0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: <4231566F-0690-48B7-B9BB-7FD43B860546@apple.com> References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> <921bb11003091054g61d63434m174389e17465d6a2@mail.gmail.com> <4231566F-0690-48B7-B9BB-7FD43B860546@apple.com> Message-ID: On Fri, Mar 12, 2010 at 1:37 AM, Chris Marrin wrote: > Ah, so then the intent would be that if we called the instancing variable > webgl_InstanceID, the translator would look for that and change it to > gl_InstanceID in implementations supporting it? That would probably work. > Hmm I think it makes more sense to do it the other way around as in the prototype: - it keeps WebGL compatible with related existing specs and shaders - forward-compatibility; whenever a future version of OpenGL ES supports instancing it is likely that it will use gl_InstanceID like its desktop counterpart. If support is not available, WebGL would replace gl_InstanceID with reserved _webgl_InstanceID, in a similar way that the JS-based implementation does here http://neonux.com/webgl/webgl-instancing.js ; native implementation can be smarter as it has access to some state JS cannot see, as well as a proper parser/validator as Kenneth discussed. Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Thu Mar 11 09:56:29 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 09:56:29 -0800 Subject: [Public WebGL] Reserve "webgl_" prefix in shaders In-Reply-To: References: <921bb11003091815t431e510em4e9585c2435a0851@mail.gmail.com> <921bb11003101604w5703f64dle5abd953b04fe287@mail.gmail.com> Message-ID: On Mar 11, 2010, at 7:20 AM, Cedric Vivier wrote: > On Thu, Mar 11, 2010 at 11:01 PM, Chris Marrin wrote: > > We should probably make it a requirement, just to avoid browser inconsistency. So maybe the words should be: > > "In addition to the reserved identifiers in the aforementioned specification, identifiers starting with "webgl_" and "_webgl_" > are reserved for use by WebGL. A shader which has user-defined identifiers starting with these prefixes must not be allowed > to load." > > +1 > > I think the second sentence would be clearer as: > "A shader which declares a function or a variable starting with these prefixes must not be allowed to load." That is more clear. But I'm concerned about making it specific. Does "variable" mean local variable? What about constants, varyings, uniform and vertex attrib names? Does the OpenGL spec use "variable" to mean all of these things? I want to make sure we are clear about not using this prefix anywhere in the shader. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Thu Mar 11 09:59:47 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 09:59:47 -0800 Subject: [Public WebGL] Re: Native implementation of common Matrix and Vector functions In-Reply-To: References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> Message-ID: <8CBDB2C9-D45B-4183-B9B2-1F3C4FEEC498@apple.com> On Mar 9, 2010, at 12:18 AM, Carl van Heezik wrote: > I do not agree that you can't write code that is much faster than javascript. > If the JS<--> native transitions (stack checks, boxing/unboxing) are a big > overhead slowing things down these are the first ones to remove. > > If you make an optimized version you have everything in your own hands except > for the few parameters that are passed to the routine. When the matrix is created > you allocate memory that fits both worlds. Then you skip all overhead because it > is really not needed (that why its called overhead) and do the math the fastest way > possible. > > If you implement the same function in javascript however all these optimizations > are not possible because the developer (you don't know) is allowed to do all kinds > of crazy stuff. > > Comment: I see matrix / vector manipulation in every 3D application and think this > justifies a high speed implementation. The fact that in OpenGL ES 2.0 you do not > have to use them doesn't mean nobody uses them anymore. If anybody knows > better ways to transform vertices without the use of matrices please let me know. But do you have evidence that this is a bottleneck? Just because the code exists in all apps doesn't mean it's a performance problem. I did such an evaluation (with admittedly simple examples) and didn't find matrix manipulation to be much of a problem. And I was once a big proponent of doing a native matrix. ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Thu Mar 11 10:02:54 2010 From: ced...@ (Cedric Vivier) Date: Fri, 12 Mar 2010 02:02:54 +0800 Subject: [Public WebGL] Reserve "webgl_" prefix in shaders In-Reply-To: References: <921bb11003091815t431e510em4e9585c2435a0851@mail.gmail.com> <921bb11003101604w5703f64dle5abd953b04fe287@mail.gmail.com> Message-ID: On Fri, Mar 12, 2010 at 1:56 AM, Chris Marrin wrote: > That is more clear. But I'm concerned about making it specific. Does > "variable" mean local variable? What about constants, varyings, uniform and > vertex attrib names? Does the OpenGL spec use "variable" to mean all of > these things? > To my understanding GLSL ES spec defines as "variables" all of these, const/varyings/uniform/... are storage qualifiers (eg. section 4.3). Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Thu Mar 11 10:03:50 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 10:03:50 -0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> <921bb11003091054g61d63434m174389e17465d6a2@mail.gmail.com> <4231566F-0690-48B7-B9BB-7FD43B860546@apple.com> Message-ID: <9E5FC525-3DA4-4483-BC53-FE0582D9E550@apple.com> On Mar 11, 2010, at 9:56 AM, Cedric Vivier wrote: > On Fri, Mar 12, 2010 at 1:37 AM, Chris Marrin wrote: > Ah, so then the intent would be that if we called the instancing variable webgl_InstanceID, the translator would look for that and change it to gl_InstanceID in implementations supporting it? That would probably work. > > > Hmm I think it makes more sense to do it the other way around as in the prototype: > - it keeps WebGL compatible with related existing specs and shaders > - forward-compatibility; whenever a future version of OpenGL ES supports instancing it is likely that it will use gl_InstanceID like its desktop counterpart. > > If support is not available, WebGL would replace gl_InstanceID with reserved _webgl_InstanceID, in a similar way that the JS-based implementation does here http://neonux.com/webgl/webgl-instancing.js ; native implementation can be smarter as it has access to some state JS cannot see, as well as a proper parser/validator as Kenneth discussed. So you're saying you think authors should use gl_InstanceID in their shaders? I think that would be a mistake and violates the GL shader rules, I think. -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma...@ Thu Mar 11 10:04:38 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 10:04:38 -0800 Subject: [Public WebGL] Reserve "webgl_" prefix in shaders In-Reply-To: References: <921bb11003091815t431e510em4e9585c2435a0851@mail.gmail.com> <921bb11003101604w5703f64dle5abd953b04fe287@mail.gmail.com> Message-ID: <4E05438B-FA26-4091-8798-B84A022B9694@apple.com> On Mar 11, 2010, at 10:02 AM, Cedric Vivier wrote: > On Fri, Mar 12, 2010 at 1:56 AM, Chris Marrin wrote: > That is more clear. But I'm concerned about making it specific. Does "variable" mean local variable? What about constants, varyings, uniform and vertex attrib names? Does the OpenGL spec use "variable" to mean all of these things? > > To my understanding GLSL ES spec defines as "variables" all of these, const/varyings/uniform/... are storage qualifiers (eg. section 4.3). Ok, fair enough. I will make this change. -------------- next part -------------- An HTML attachment was scrubbed... URL: From car...@ Thu Mar 11 10:10:45 2010 From: car...@ (Carl van Heezik) Date: Thu, 11 Mar 2010 19:10:45 +0100 Subject: [Public WebGL] Re: Native implementation of common Matrix and Vector functions In-Reply-To: <8CBDB2C9-D45B-4183-B9B2-1F3C4FEEC498@apple.com> References: <66C21BAB-09ED-407A-B0D1-F3708787BAAE@microcan.nl> <1512ad791003080759l5ce173c9td51f9263d6580bea@mail.gmail.com> <8CBDB2C9-D45B-4183-B9B2-1F3C4FEEC498@apple.com> Message-ID: <2E66C93E-2C38-4669-8221-083C3B9CA1EF@microcan.nl> Chris, What I like is that standard things like matrices and vertices are standard types in the language. If everybody is using their own implementation of matrices and vertices its unlikely that you can easily use code from others without a rewrite. Best regards, Carl Op 11 mrt 2010, om 18:59 heeft Chris Marrin het volgende geschreven: On Mar 9, 2010, at 12:18 AM, Carl van Heezik wrote: > I do not agree that you can't write code that is much faster than javascript. > If the JS<--> native transitions (stack checks, boxing/unboxing) are a big > overhead slowing things down these are the first ones to remove. > > If you make an optimized version you have everything in your own hands except > for the few parameters that are passed to the routine. When the matrix is created > you allocate memory that fits both worlds. Then you skip all overhead because it > is really not needed (that why its called overhead) and do the math the fastest way > possible. > > If you implement the same function in javascript however all these optimizations > are not possible because the developer (you don't know) is allowed to do all kinds > of crazy stuff. > > Comment: I see matrix / vector manipulation in every 3D application and think this > justifies a high speed implementation. The fact that in OpenGL ES 2.0 you do not > have to use them doesn't mean nobody uses them anymore. If anybody knows > better ways to transform vertices without the use of matrices please let me know. But do you have evidence that this is a bottleneck? Just because the code exists in all apps doesn't mean it's a performance problem. I did such an evaluation (with admittedly simple examples) and didn't find matrix manipulation to be much of a problem. And I was once a big proponent of doing a native matrix. ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From cma...@ Thu Mar 11 10:20:32 2010 From: cma...@ (Chris Marrin) Date: Thu, 11 Mar 2010 10:20:32 -0800 Subject: [Public WebGL] Spec updates and contributors list needs update? Message-ID: <26A9EA29-D244-4B08-8D5D-113033E1CC9B@apple.com> I've added updates to the spec for extensions and the "_webgl_" wording. Both of these suggestions came from Cedric Vivier, so his name has been added to the contributors list. 2 things: 1) Cedric, I need to know what company affiliation (if any) you want with your name 2) Arun, we should probably go through and amend the list. I think there are several names of recent contributors that are missing. I would do it, but I don't feel I have your political alacrity :-) ----- ~Chris cmarrin...@ ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Thu Mar 11 10:21:48 2010 From: ced...@ (Cedric Vivier) Date: Fri, 12 Mar 2010 02:21:48 +0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: <9E5FC525-3DA4-4483-BC53-FE0582D9E550@apple.com> References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> <921bb11003091054g61d63434m174389e17465d6a2@mail.gmail.com> <4231566F-0690-48B7-B9BB-7FD43B860546@apple.com> <9E5FC525-3DA4-4483-BC53-FE0582D9E550@apple.com> Message-ID: On Fri, Mar 12, 2010 at 2:03 AM, Chris Marrin wrote: > So you're saying you think authors should use gl_InstanceID in their > shaders? I think that would be a mistake and violates the GL shader rules, I > think. > Hmm? People using EXT_draw_instanced and/or OpenGL 3.1+ are using "gl_InstanceID" ;-) If by violating GL shader rules you mean violating GLSL ES shader spec, it does not imo since we do not declare it, we just use it. Though this variable does not exist in ES or older OpenGL, the WebGL implementation ensures there is no violation (as in usage of an undeclared variable) since it transforms it before feeding it to the underlying graphics library. The addition of the possible usage of gl_InstanceID in shaders would be a paragraph in the "Differences between WebGL and OpenGL ES 2.0" section. Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: From vla...@ Thu Mar 11 10:26:38 2010 From: vla...@ (Vladimir Vukicevic) Date: Thu, 11 Mar 2010 10:26:38 -0800 (PST) Subject: [Public WebGL] Re: Native implementation of common Matrix and Vector functions In-Reply-To: <2E66C93E-2C38-4669-8221-083C3B9CA1EF@microcan.nl> Message-ID: <1013376430.45863.1268331998277.JavaMail.root@cm-mail03.mozilla.org> I don't know that I would say unlikely -- if that's a clear win some interop rules will be decided on. At the lowest level, it's possible to interop by passing around Float/etc. arrays. It's unfortunately not possible to have matrices/vectors as "standard types" in the language, because JS doesn't really support operator overloading or any of the functionality that would make these things be useful types... so until we can do that, I think it's better to let people roll their own, and experiment with domain-specific optimizations and other advantages. Plus, as Ken said, any native ops will likely be slower than JS ops just due to the overhead of going between JS and native code, whereas keeping things in JS allows the JS optimizers full reign. We (Firefox) already do a bunch of optimizations with typed arrrays in JS, and in the future we want to look at taking advantage of SIMD as well if available, all transparently to the user. These things would all be harder and of less benefit if these things were native and baked in. - Vlad ----- "Carl van Heezik" wrote: Chris, What I like is that standard things like matrices and vertices are standard types in the language. If everybody is using their own implementation of matrices and vertices its unlikely that you can easily use code from others without a rewrite. Best regards, Carl Op 11 mrt 2010, om 18:59 heeft Chris Marrin het volgende geschreven: On Mar 9, 2010, at 12:18 AM, Carl van Heezik wrote: > I do not agree that you can't write code that is much faster than javascript. > If the JS<--> native transitions (stack checks, boxing/unboxing) are a big > overhead slowing things down these are the first ones to remove. > > If you make an optimized version you have everything in your own hands except > for the few parameters that are passed to the routine. When the matrix is created > you allocate memory that fits both worlds. Then you skip all overhead because it > is really not needed (that why its called overhead) and do the math the fastest way > possible. > > If you implement the same function in javascript however all these optimizations > are not possible because the developer (you don't know) is allowed to do all kinds > of crazy stuff. > > Comment: I see matrix / vector manipulation in every 3D application and think this > justifies a high speed implementation. The fact that in OpenGL ES 2.0 you do not > have to use them doesn't mean nobody uses them anymore. If anybody knows > better ways to transform vertices without the use of matrices please let me know. But do you have evidence that this is a bottleneck? Just because the code exists in all apps doesn't mean it's a performance problem. I did such an evaluation (with admittedly simple examples) and didn't find matrix manipulation to be much of a problem. And I was once a big proponent of doing a native matrix. ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: -------------- next part -------------- An HTML attachment was scrubbed... URL: From kbr...@ Thu Mar 11 10:56:31 2010 From: kbr...@ (Kenneth Russell) Date: Thu, 11 Mar 2010 10:56:31 -0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> <921bb11003091054g61d63434m174389e17465d6a2@mail.gmail.com> <4231566F-0690-48B7-B9BB-7FD43B860546@apple.com> <9E5FC525-3DA4-4483-BC53-FE0582D9E550@apple.com> Message-ID: <921bb11003111056t63445934o3735074904242a8e@mail.gmail.com> On Thu, Mar 11, 2010 at 10:21 AM, Cedric Vivier wrote: > On Fri, Mar 12, 2010 at 2:03 AM, Chris Marrin wrote: >> >> So you're saying you think authors should use gl_InstanceID in their >> shaders? I think that would be a mistake and violates the GL shader rules, I >> think. > > Hmm? People using EXT_draw_instanced and/or OpenGL 3.1+ are using > "gl_InstanceID" ;-) > > If by violating GL shader rules you mean violating GLSL ES shader spec, it > does not imo since we do not declare it, we just use it. > Though this variable does not exist in ES or older OpenGL, the WebGL > implementation ensures there is no violation (as in usage of an undeclared > variable) since it transforms it before feeding it to the underlying > graphics library. > > The addition of the possible usage of gl_InstanceID in shaders would be a > paragraph in the "Differences between WebGL and OpenGL ES 2.0" section. Agreed, this is how the instancing support would be added to WebGL. User shaders would reference gl_InstanceID, which would be rewritten by the implementation to something like "_webgl_InstanceID" if hardware instancing is not supported. -Ken ----------------------------------------------------------- You are currently subscribe to public_webgl...@ To unsubscribe, send an email to majordomo...@ with the following command in the body of your email: From ced...@ Thu Mar 11 10:57:44 2010 From: ced...@ (Cedric Vivier) Date: Fri, 12 Mar 2010 02:57:44 +0800 Subject: [Public WebGL] Geometry instancing support (ie. draw*Instanced) In-Reply-To: References: <921bb11003081815h5df93678nf04403d65c6d4956@mail.gmail.com> <921bb11003091054g61d63434m174389e17465d6a2@mail.gmail.com> <4231566F-0690-48B7-B9BB-7FD43B860546@apple.com> <9E5FC525-3DA4-4483-BC53-FE0582D9E550@apple.com> Message-ID: On Fri, Mar 12, 2010 at 2:21 AM, Cedric Vivier wrote: > The addition of the possible usage of gl_InstanceID in shaders would be a > paragraph in the "Differences between WebGL and OpenGL ES 2.0" section. > E.g / proposal : IDL: void drawArraysInstanced(in GLenum mode, in GLint first, in GLsizei count, in GLsizei primcount) raises(DOMException); void drawElementsInstanced(in GLenum mode, in GLsizei count, in GLenum type, in GLsizeiptr offset, in GLsizei primcount) raises(DOMException); 5.15.11 drawArraysInstanced(mode, first, count, primcount) (EXT_draw_instanced man page) drawElementsInstanced(mode, count, type, offset, primcount) (EXT_draw_instanced man page) Draw given primcount instances using the currently bound index array. The given offset is in bytes, and must be a valid multiple of the size of the given type or an INVALID_VALUE error will be raised. Shader variable gl_InstanceID is incremented for each instance, from 0 inclusive to primcount exclusive. 6.2 Geometry instancing WebGL adds instanced draw calls drawArraysInstanced and drawElementsInstanced, consequently gl_InstanceID is a valid vertex shader input variable that holds the integer index of the current primitive in an instanced draw call. If the current primitive does not come from an instanced draw call, the value of gl_InstanceID is zero. Cheers, -------------- next part -------------- An HTML attachment was scrubbed... URL: From joh...@ Thu Mar 11 11:17:56 2010 From: joh...@ (Johannes Behr) Date: Thu, 11 Mar 2010 20:17:56 +0100 Subject: [Public WebGL] A Declarative node set for WebGL -- introducing WebSG In-Reply-To: <46FC984E-263B-4CEB-A22E-7BF97BCA55D4@apple.com> References: <46FC984E-263B-4CEB-A22E-7BF97BCA55D4@apple.com> Message-ID: <4FCA8DF7-2D4D-4A55-B6A5-3D7B8058C8A8@igd.fraunhofer.de> Hi, we had a longer discussion in the x3dom development group about your proposal and came up with a new subsystem of x3dom to feat this idea. We would like to introduce WebSG --- the WebSceneGraph connecting WebGL and Web3D.org technology The main question was how would a modern and reduced, even more HTML oriented node-set look like and how could a webgl integration work. It's not a totally new node-set but respects the ISO-X3D standard. X3DOM-WebSG Profile: - websg tag as start - no runtime (still open for discussion) - only explicit shader based material - uses ,