Thursday, September 26, 2013

WebGL and the Learning Curve Saga Part III


My WebGL saga continues. If we are talking tortoise vs hare here, then I am certainly the tortoise member of this fable.

Slowly but surely we beat the thing into submission. Its not really bad, just badly documented, IMHO, like so much of the GL family. With WebGl we are definitely in a world circa 1982 or so. But MUCH faster than we ever would have achieved in 1982 no matter how rich you were. So we have vast power on all our desktops, but for some reason "we" have "chosen" to program it in a rather low level way. Well, hell, I like low level now and then. I like debugging this stuff that could have been documented but why bother, they can figure it out on their own.

So here is the kind of things I have been working on instead of figuring out how to end war or torture the rich or writing great fiction.

1. The Element Array Debacle

So, for example, if I had been paying attention, I would have noticed that the "element array" feature of WebGL (1) was defined to be a "short" or a 16 bit number. Warning alarms should have gone off in my head but its been a long time since I have programmed 16 bit machines.   Because its a short, the largest number of elements that one can therefore address is 64K vertices. In other words, it is useless for objects that are of modern complexity. Remember there are no higher order surfaces rendered directly by WebGL so we get the appearance of complexity by having a lot of triangles, I mean a lot of triangles, and maybe play with the shading. Maybe this limitation was noted in the documentation but I don't think so.

The result was that I had to rewrite the core of the object viewer to not use element arrays but just use the vertices, and the vertex attributes, etc. It took about 2 - 3 days and resulted in a much cleaner if slightly more verbose piece of code that could actually be maintained if it had to be.

2. The How Many of WHAT Exactly? Problem

The documentation says that you need to specify the number of things you are transferring. Well now, that could mean the number of triangles, or it could mean the number of vertices it takes to specify the triangles, or it could mean the number of bytes that it takes to hold the data, or ...

And the answer is: its the number of vertices you use to define the object. So the count you send is (3 * number of triangles) or (2 * number of lines). Maybe it was obvious to you, but it sure was not obvious to me from the documentation.

3. The Ongoing Normal Mystery

Look at the following picture. See anything odd? Well, its made out of flat triangles, and you should see flat surfaces. Ok, so its interpolating the normals, whats so odd about this? Its just that all the normals for a face (all triangles really) are all pointing the same direction. Unless WebGl is rebuilding the topology of the object by doing a giant vertex sort, there is no way it could be interpolating the normals.



So what is going on? No one knows, but I suspect that it is a bug in my shader that somehow does not compute the diffuse component correctly. The specular would normally and correctly be "smooth shaded", e.g. not show flat surfaces for the most part. So this maybe is just flat shaded, with transparency, and a specular. If that is not the problem then we are definitely in the twilight zone here.

"This war will be over one day".

You get extra credit for knowing what movie that is from and who said it.

____________________________________

1. Where one specifies a line or triangle by keeping a list of vertex numbers rather than repeating the vertex itself over and over again.



Sunday, September 22, 2013

Evidence of Vast Improvement in Los Angeles Mass Transit


I have recently been shown evidence that we are on the verge of a vast change in the way we do mass transit in this country. Well maybe that is a little bold and overreaching.   The evidence relates to Los Angeles specifically, not very well known for being progressive in this area.

In order to understand this evidence we first have to discuss certain techniques used to predict the future and also certain aspects of the history of the topic as it relates to the evidence. But don't worry we will get there.

It is a theme of this blog that predicting the future is sometimes easy and sometimes very hard if not completely impossible, but that it is always entertaining. One complicating factor in predicting the future of course is predicting when it will happen. Predicting what will happen is not enough. When is just as important as what.

One technique used is a concept known as the "indicator". The indicator, stolen from the fields of National Security and Economics, is nothing more than a carefully chosen event or trend that is used as a signal that something of greater scope is happening. The price of corn, the temperature of sea water, and whether a nation's troops are mobilized are all examples of indicators.

Recently I have come across solid evidence that we may be on the verge of a genuine revolution in how we do mass transit in urban areas. I suspect that this might be autonomous vehicles, which I discuss briefly below, but it might be something else. The evidence is not too specific although it is clear that something is coming.



Autonomous Taxicab, the JohnnyCab, from the original Total Recall.  If its good enough for Arnold, it should be good enough for us.


I am a firm believer that autonomous vehicles are in our future and that this is a good thing. I think that they have the potential of changing many things about how we deal with transit in an urban and non-urban environment and that many of these changes will be somewhat unexpected. Maybe we will not own cars, maybe we will just call one up from a pool when we need one. People may never have to worry about parking again and a host of other possible changes.

But being certain when this change will happen is less clear. There have been a lot of promising technologies in the past that have never been deployed in real life: people movers, monorails, levitating trains, not to mention personal airplanes and jet packs. And there are many obstacles in the way of deploying autonomous vehicles beyond the merely technical ones. I will mention just two which are daunting: the greed of the insurance industry and the stupidity of local city governments. Just navigating those two barriers will require more skill and probably more money than solving the technological issues.

Consider the following evidence of imminent change.

Slowly, and without a lot of fanfare, Los Angeles is in the process of building two mass transit systems that will reach the west side of Los Angeles. One is light rail, the Exposition Line, and it is well along and already reaches Robertson near Culver City. The other is a subway down Wilshire and it is in the early stages of construction. The estimated completion of all this work is a date well beyond 20 years from now. But there will be incremental deliverables and parts of the system will be in production sooner than other parts.



The Expo Line actually runs to Culver City.  Its like a Miracle from God that they built this thing.  


To understand why this matters you have to realize that mass transit in Los Angeles is different from other places. In other places, mass transit may be controversial, it may be a compromise, it may be expensive, it may be bankrupt, but it proceeds. But in Los Angeles, you literally have world class crime, political malfeasance, and fraud not to mention racism and major lawsuits. Volumes have been written about the stupidity, short-sightedness and corruption (e.g. bribery).  But most of all, this is an area where the politicians and the civic community failed together to find a solution to a problem that was clearly going to get worse.  In other words, they "kicked the can down the road" and hoped that others would solve it.

The problem is that in this area, as in others as well but this is an excellent test case, solving the problems require capital investment, tremendous political will, short-term grief, and a lot of time to execute.   It is an excellent example where naive, one might say, stupid, reliance on "free market solutions" is obviously a failure.   The benefits of mass transit take many forms, but several of them require the system to be planned and executed and in place for a period of time so that things can be built around it and make it all the more useful.   In other words, the transit system may have to be there for 20 years before all the benefits accrue to the investment (through the placement of hotels, universities, theatres, etc).

To ask politicians and citizens in LA to face a problem 20 years in the future and a benefit also 20 years or so in the future is so far beyond their limited intelligence and wisdom as to be beyond funny into farce.   Los Angeles was built for a reason, and that reason resounds in every decision that the civic body makes.  Los Angeles is built on a desire to steal money and fuck people right now, not on stealing money and fucking people in some future day.   This is obvious in the cheap architecture, the lack of zoning to control cheap real estate development, the dumping of wastes into the water system, the failure to control pollution generated by container ships at the Port of LA that causes a substantial percentage of the air pollution in the LA basin (is it 30% ? 40% ? No one knows).

The point is this:  it isn't possible or plausible that LA would just get around to fixing this problem, or at least some of this problem, by building a transit system, eventually.  I don't buy it.  If something like this is happening, it is an indicator, as previously described, of a larger process that is taking place behind the scenes, even if the people executing this idea are not aware of it.  I think that the will of the people and the force of shame and the collapse of the transit system in Los Angeles over the last 15 years or so has finally caused the City of LA and related areas to finally move in an area that should have been addressed 50 years ago and therefore there is no possibility of this being a wise move.  By the time it is done, something will have happened to expose why this was at best a very late decision for LA to make.

Therefore I am very optimistic that we will see a sea-change in urban transit technology in the near future, as these things are measured.  Its about time.

In a later post I will discuss why I am holding back my real feelings here about Los Angeles and their failure to deal with fundamental issues.

I grew up here.  I know where some of the bodies are buried.

Friday, September 20, 2013

More on the Design of WEBGL and the Origins of .OBJ


We have made a little progress in the last few days on both WebGL and the .OBJ origins issues.

This is an image from the current .OBJ object display software written for WebGL and written in Javascript/DOM/HTML.  Now, I doubt anyone actually needs a .OBJ viewer, its just a way to get familiar with displaying geometry with WebGL.

Instead of just showing you a picture, as I do, below, I should be able to just give you a URL so you can run it yourself, but I can't because I don't actually have a place to post the files for you to address (without seeing advertisements or in other ways compromising or inconveniencing my friends). The only web server I have access to is my own and it has only temporary IP addresses which Facebook will not even let me post. Besides, why bother to post a temporary IP address? I think it is funny how money controls everything, without money, our society says, don't even try to do anything.




So for fun I am posting this dilemma here and on Facebook, maybe someone will know where I can post some number of html and js files in a way that can be accessed by people on the net without inconveniencing them (e.g. no spyware, no ads, no Doubleclick tracking) at a price that even the poor can afford.

Regarding WebGL, once you realize that the designers had gutted it of any even slighlty higher level 3D and that this is a very low level interface to some of the power of the GPU without in any way providing even trivial conveniences for the programmer, everything is fine and you proceed.

I think they did this for good reasons. In the past, by making computers easier to use we opened the doors to allowing people to come in and take away our livelihood. The kind of conveniences I am talking about are trivial and do not hold back an experienced 3D technologist in the least (after they waste their time trying to figure out what the people who redesigned OpenGL were thinking ...).  (1)   So all that happens is that they inconvenience those who are writing their first 3D software and also tend to make such programs written to be a little more obscure because they will all be different (having to reinvent the wheel is trivial here, but since everyone will do it differently naturally it will be a little harder for someone to come in and read and modify because they will have to learn a new convention rather than rely on an industry-wide convention.)

I have no problem with this and in fact applaud it. As a victim of globalization and of the spread of these technologies, anything that makes knowledge that I have more arcane and valuable can only be good.

Regarding the .OBJ matter, we have learned both more and less. The ideas and the general approach to what the .OBJ format became was in the air at SIGGRAPH and the U of Utah in 1979 according to Frank Crow. According to Julian Gomez, there was no software from E&S that would have been an example of a .OBJ like format that would have come from them.   My leading hypothesis had been that the people at Abel's had received some sample software to (for example) load a geometric object and display it on the Picture System.   What would be a normal software development approach would be to start with that program and then write their own software on top of it.   Its an extension of the old joke that Unix only had one device driver (in other words, that everyone modified the original device driver when they had a new device to interface).  Julian may have written one of the first such "display an object" program at Andrews AFB long ago, but it did not use anything similar to a .OBJ-like format.

Julian also suggests that Mickey Mantle, who was in charge of customer support of E&S, may know more.

Thus it is still quite possible that the .OBJ format as we know it was based on ideas that were generally available but not based on specific code from a sample program, as I had expected. In other words, it may still turn out that the Abel version, written initially for motion control preview for Star Trek: The Motion Picture is the one that escaped into the wild (as I believe) and that it originated at Abel's, even if based on ideas more generally available.

 The time when this would have been written by the way is about 1977.

There is more to say, but also more to find out. I have been unable to find any early E&S documentation, for example, which would answer a lot of questions.

If anyone knows how to reach Mickey Mantle, please let me know.
_________________________________________

1. Well, that is not totally true.  OpenGL used to support drawing polygons, convex polygons, directly.  Now only triangles are supported so you have to subdivide into triangles yourself.  The problem is, this is a problem whose general case is actually fairly difficult.  Why not make everyone re-solve this themselves? Its good for them, it makes them think about fundamental principles.   I have no idea what these people were thinking.


Sunday, September 15, 2013

Amazing Simulation of 1970s Graphics in WebGL


Its the mid 1970s all over again.

I actually have written my first WebGL application to display a .obj file.

First you have to convert the .obj to a ".json" file, and then type in its name to some code.  But this process which might seem awkward and stupid, is actually all the more authentic.  This makes the application feel even more 1970s with a retro user interface.

The image is of my test object, a viewpoint .obj of a playing card.   By being completely flat, believe it or not, I can test certain things in my code that was useful.  Yes I know, its not the most compelling 3D object you have ever seen, and you would not even guess that the object is lit, but it is.

So far I have only found one incompatibility between Firefox and Chrome, that being the ability to see the "." as in "period" in a javascript program.   Firefox can, Chrome can not.

The great advantage in having all this in HTML is that it provides all sorts of tools for layout, fonts, scrolling and so forth.  Thus the "program log" window on the far left scrolls which was trivial to implement.


Wow!  Thats exciting, isnt it !

Technical Notes

Ok, so the status display is wrong.  In fact this is the line segments of the very flat 3D object that you are seeing.   The display does not become correct until the user rotates the object and from that point forward it is correct.   Fixed in the next release.


Thursday, September 12, 2013

More Balanced Commentary on WebGL


No matter how frustrating the process, after a while one learns what can be done with a system and how to get around whatever it is you need to get around.   In this case the surprise was that I simply did not realize to what extent programming WebGL meant actually also working with both Html and the DOM, even though in retrospect it is obvious, and even more than that, this is what you would want.

You want it to be involved with HTML and the DOM or how could it all be integrated into the browser otherwise.

So its all good.  

There are some mysteries in the direction that OpenGL ES 2.0 has taken.   These mysteries can no doubt be explained by the designers, but they haven't done so, not that I have been able to find.  The specific questions involve the extreme position they seem to have taken to remove many things that people who program graphics use.   Its not so hard to implement your own versions of these things, e.g. a perspective matrix, a uniform variable to put it in, etc.   But it does make one wonder why they took it out to begin with?   Maybe they are just trying to be minimal?   That could be good.  But it is a little puzzling when you know the earlier versions of OpenGL and just leap into this and can not find things you expect.

Same question about perspective matrices also applies to lights.

And they seem to have some major browser architecture issue which I will call "the problem of the lost context".   Its annoying but can be managed.

On the positive side, by being so integrated with Html and DOM it is trivial to do multiple window layout and such things as scrolling text windows that might otherwise be difficult.

So far it seems to work and browser incompatibilities between Firefox and Chrome have been minimal.

Tuesday, September 10, 2013

Corruption and Degradation in WebGL (revised)


This review was written about a week ago when I was first into my learning curve of javascript, html, dom and webGL.  Well, its a week later and I think that what I was really responding to is / was different than what I thought it was.   Its not about WebGL, its about expectations.   See note at the end of the post.

This is a review on the process of learning Javascript and WebGL. The two are very interconnected and we will start with Javascript and then move to WebGL.

Note, I am not far enough along to have a real opinion about how well WebGL works, because I am spending all my time getting through the learning curve of getting a picture up on the screen. It shows promise, when things work it almost seems magical.

But when you first are learning WebGL you have to get through Javascript so we will start there.

Although Javascript is a little weird, it does grow on you, and there are clever even possibly reasonable solutions to various flaws in the language which, once you get used to their weird syntax, seem to be OK. For example, I am using a variation on the "module" pattern in Javascript and it seems to be working out for me in terms of hiding and keeping internal state of various parts of the program. Furthermore, javascript reminds me a bit of Lisp in its devil-may-care attitude to dynamic memory and its JSON equivalent of an S-Expression. Although initially dealing with Javascript is a problem, in time the problems fade into the background.

The problem is that learning Javascript is something of a pain in the ass, and for the following reasons:

1. Javascript has a specification and a bunch of tutorials, but no serious reference manual or best practices documentation. You are expected to get all that "out on the Internet". Ha.

2. The problem is that each of these tutorials is written by a different person with wildly different skill sets, styles and talent. They are not Kernighan and Ritchie. They are not comprehensive. They are occasionally helpful, they are more often then not incomplete or inaccurate. They are in no way a substitute for a good reference manual.

3. Each of these tutorials by helpful unpaid volunteers uses a different style, and a different set of support packages, all of which are completely incompatible with each other. There is no equivalent to "stdio" in Javascript. One person uses Ajax, another uses Jquery, still another uses something else. These different packages all seem to be useful, ad hoc, mutually incompatible and of wildly varying quality and utility.

4. Learning Javascript is usually intertwined with learning some combination of DOM and HTML, each of which exists in its own versions, varying implementations, and without documentation. Repeat problems of learning Javascript for each of these.

5. Unless you have someone with the knowledge and the time to guide you through this morass, you can count on a very frustrating period and a very time-inefficient process. Its nothing that anyone involved should be proud of. Just because they made a billion dollars at it, does not mean that they did a good job.

But the good news is that, so far at least, in conjunction with a nearly Lisp-like level of interactivity, one can pretty quickly get through the learning curve and onto whatever it is you wanted to do with the language.

But then you get to WebGL and you run into a series of problems which are very related to the ones just mentioned but with a few additional ones to make it all better. Not only is there no reference manual, nor anything close to minimally acceptable reference documentation (a specification is not a reference manual, by the way), but one more time we have the morass of internet tutorials that vary from useful to not, and each of them uses their own support packages for matrix operations and so forth.

But unlike Javascript, with WebGL and all modern graphics APIs, you have to do an awful lot correctly before you can put a cube on the screen. And if you do one of those 30 or 40 things incorrectly, then you will not see a cube on the screen. But each of those 30 or 40 things is badly documented since there is no reference manual, so you are reliant on Internet based tutorials which brings us full-circle on the discussion.

The only way I have found to proceed is to divide and conquer. Which is to work your way through the creation of a working program one module and WebGL call at a time, reverse engineer what the documentation should have been, and then move on.

That takes time.

I am not all that impressed, to tell you the truth.

So now it is a week or so since I wrote the above post.  And I think I was being a little harsh.  Once you get through the learning curve, and get a handle on what documentation that there is, one can become productive.  There are still unsolved riddles but I am able to move around them.   I think that the real problem here, however badly expressed, is one of incorrect expectations.  I expected things to be better, for us to go forward with the best, and not to have to deal with things that are no better designed or documented than what we had 20 years ago.   It is perhaps a let down that we have not come very far in certain ways and that is what I think I was expressing above, without knowing it.  As for the rest, Html, Dom, and even WebGL is fine, if a little weird now and then.




Monday, September 9, 2013

Global Wahrman Reorganization on 1st Anniversary


We plan to try different schemes to make individual posts on larger topics easier to find and perhaps even in a logical order.  This will take some time, and I probably have to try a lot of things before I find an approach that I like.  So there will be a fair amount of chaos here until it settles down.

Global Wahrman is one year old and I am very happy with parts of it.  But it is getting larger and harder to find things, or to know what is here.   It will take at least 5 years before I work through the backlog of topics, I think.

As you have noticed, posts come in several varieties here.  Although the trivial posts do not take very long to write, the more complicated ones are coming in at between 2 - 4 hours.  Some take more time than that.   I am not sure about the numbers but I would guess that for every post that is published, there is another post that did not get finished to my satisfaction and never posted.  It is the longer posts that are usually more interesting because more thought has gone into them and there is a topic behind them that I have usually thought about for a while.

The blog is very demanding, and it will be challenging to manage my time if and when I ever get busy in other parts of my life.


A Modest Solution to the Syrian Civil War and Related Regional Problems


When the domestic situation looks unsolvable it is a time honored solution to look to foreign policy as a way of distracting the locals from the government-created misery that is their life. Not only is this approach used successfully by governments, it can be used successfully by individuals to help avoid thinking and working on their own problems, a sort-of trickle down "distract the miserable" approach. Thus I have been putting considerable time into the Syria issue and whether we should start firing missiles at that part of the world.

The answer, I am happy to say is, No, we should not fire missiles. Nothing we do there will help the situation, anything that we do could have unforseen results. It is a no win situation for us. I am sorry that the Syrians and their neighbors are killing each other, and I am sorry that some of these people are assholes. But that is not a good enough reason to go to war.

But if you say we must do something, I have a proposal for you. I am sure that the small-minded scum in Washington will ignore my suggestion, but I am used to that. Pearls before Swine if you ask me.

If you want to help that region, forget about bombing Syria, ask yourself why is this region all fucked up (using the technical terms here, "fucked up"). What do the following countries have in common: Syria, Lebanon, Jordan, Saudi Arabia and Iraq? They were all created out of the former Ottoman Empire which is the country we now call Turkey. Turkey was also created at the end of WWI out of the former Ottoman Empire. This was all set up by the British and the French, mostly.

Since these countries clearly can not handle their affairs, I am referring to Syria, et alia, not England and France, and since this little British and French experiment in nation building is such a disaster, lets swallow our pride, and ask Turkey to come back, and manage the area for us. Forget about Syria, its just a province of the new Ottoman Empire, and better for it.

Bring back the Sublime Porte, the Grand Vizier, the Harem. All of it. I think that the world has given a good shot at letting the people of the region rule themselves, and they have proven to everyone how competent they are at it which is not very competent at all.

Lets admit our mistakes and bring back the Ottomans.

Furthermore, I predict that this will result in a massive increase in employment for certain technical people.  The Ottoman's were well known for the use of Unix, they had Unix everywhere, especially the Harem.

Perhaps the Harem is a problem for you, my sensitive, politically correct, white friend?  You might want to look into the role of women in the near east, first.  The Harem actually had quite a bit of power in the Ottoman empire.  More power than women have in politics in most of the contemporary Near East, I think.

Below we have a photograph of a classic Harem and concept art for a proposed anime-style modern Harem.




Also, the Ottoman's were quite stylish.  Check out the head gear, below.


Suleiman Himself


Map of the Ottoman Empire at its Largest


So in conclusion, by bringing back the Ottoman Empire to that part of the world, and getting rid of the current countries of Lebanon, Syria, Saudi Arabia, Iraq etc, we have a plan that will reduce violence, increase employment, elevate the role of women in their society, and add to sartorial elegance.  All of these things are good things, good for us and good for the region.

I hope you will support the campaign to restore the Ottoman Empire with your representatives in Washington.


Sunday, September 8, 2013

Request for Information About the Origin of the .OBJ Format


I am looking for information on the origins of the .obj 3D object format.  By the time I had arrived at Robert Abel & Associates in 1980 or so, it was already in use for our vector production system which ran on E&S Picture System 2s.  

My question is where it came from originally.  I had thought that it was indigenous to Abel's, but several people have told me that it wasn't and that it originated with Evans & Sutherland.  This makes sense but I have not been able to confirm it.

The reason I am so interested is because I think I was instrumental in extending this horrible format into raster graphics.  Its a long story and I want to get all my facts straight first.

If you know, or know someone at E&S I can talk to, leave a comment here or email me.  Thanks.



Saturday, September 7, 2013

Irresistable Videos on the Ancient Silk Road


In the world of archaeology, few topics are more interesting, controversial and entertaining than the whole combined issues of Indo European Language Dispersal and its dozens and dozens of mysteries and controversies.  You may not realize that you are living immersed in these mysteries, but you are, you are one of them.  You speak one (or more) of the languages that is at the heart of the mystery.

The Penn Museum had a seminar on some of these issues which had as speakers the superstars of this world: Colin Renfrew, J P Mallory, Victor Mair and so forth.

Its all online, which is wonderful.

Now you can waste another day or two of your life learning about this stuff.

See: http://www.youtube.com/watch?v=Z0HCs6PVnzI or all 10 seminars/talks at http://www.youtube.com/watch?v=QapUGZ0ObjA&list=PL286E934A56954D08