I want to create some 3D and angled transport button icons, for Play, Pause, Next Track etc. for my application and I decided to do it with some simple calls to GL_TRIANGLES and GL_QUADS. Below is an example of an extremely simple Play button icon.
For this I have used two triangles (one you can't see) and three quads (one you can't see) and I have manually calculated the normals and positioned a relatively straightforward light source at 0,1,5 - mostly in front of the object, but slightly above. The light ambience is at 0,0,0,1, light diffuse is at 1,1,1,1 and light specular is at 1,1,1,1. Material specular is at 0,0,0,1 and material emissive is at 0,0,0,0, with glColorMaterial set to GL_FRONT_AND_BACK for GL_AMBIENT_AND_DIFFUSE. I then use glColor3f to set to R,G,B of 0.5,1,0.5 - hence the light green button colour you see.
What I am wondering is this... is there an easy way to make the front face of the Play button shiny in, say, the top corner? The whole polygon has the same face normal of 0,0,1. I'm not especially doing anything special with lighting so far - so I'm wondering if I need to set up a spotlight - possibly coming in from the top left towards the triangle, but not hitting it all - would that work? Or whether I can do this some other way, by altering GL_SHININESS or something else.
one possibility is to set the normal for every point particular. But with this very simple objects you could (and should) get problems, because the angles between the faces of the object are to high.
An other possibilty is to use a "per-pixel-shader", but I have now experience in this and I think it could be to much for this simple problem.
I think the OpenGL Shininess means only, how fast the faces become darker by Rotating from the Screenplane away. But I'am not sure.
Ziz
PS: Sorry for my bad English, but I hope you unterstand, what I mean.
_________________ Denn wer nur schweigt, weil er Konflikte scheut, der macht Sachen, die er hinterher bereut. Und das ist verkehrt, denn es ist nicht so schwer, jeden Tag zu tun als ob's der letzte wär’. Und du schaust mich an und fragst ob ich das kann. Und ich denk, ich werd' mich ändern irgendwann. _________________Farin Urlaub - Bewegungslos
Registriert: Di Mai 18, 2004 16:45 Beiträge: 2623 Wohnort: Berlin
Programmiersprache: Go, C/C++
The problem of fixed function lightning is the bad shading result.
If you want nice interpolation between the colors then you need fragment shader.
You can only use one Normal per face(flat shading) if you don't use vertexarray or vbo else you have to clone the normal for every vertex of the same face.
If you use one normal per vertex then you get smoothshading(every facenorma,l where the vertex is a part of, will avaraged to one normal and assigned to the vertex) but this is not what you want.
The easiest way is to use texture and draw the lightning by your own(spherical gradient in the left top corner of the picture).
_________________ "Wer die Freiheit aufgibt um Sicherheit zu gewinnen, der wird am Ende beides verlieren" Benjamin Franklin
The easiest way is to use texture and draw the lightning by your own(spherical gradient in the left top corner of the picture).
This is what I was starting to think, but also what I wanted to avoid - if possible. I did not envisage that what I wanted to do would even be possible, just thought I would check by asking the forum.
Registriert: Do Sep 02, 2004 19:42 Beiträge: 4158
Programmiersprache: FreePascal, C++
Another way, which is possible is to modify the shape of the object a little bit by making the edges on the top a little bit smoother (=> more quads). This will give even with the default shading a quite reasonable result. You know what I mean?
greetings Lord Horazont
_________________ If you find any deadlinks, please send me a notification – Wenn du tote Links findest, sende mir eine Benachrichtigung. current projects: ManiacLab; aioxmpp zombofant network • my photostream „Writing code is like writing poetry“ - source unknown
„Give a man a fish, and you feed him for a day. Teach a man to fish and you feed him for a lifetime. “ ~ A Chinese Proverb
Registriert: Do Sep 02, 2004 19:42 Beiträge: 4158
Programmiersprache: FreePascal, C++
Yeah, but I think, one subdivision will not be enough. I thought about four or more. I do not know, whether this is that good for a simple button - maybe using textures will be the better alternative.
greetings Lord Horazont
_________________ If you find any deadlinks, please send me a notification – Wenn du tote Links findest, sende mir eine Benachrichtigung. current projects: ManiacLab; aioxmpp zombofant network • my photostream „Writing code is like writing poetry“ - source unknown
„Give a man a fish, and you feed him for a day. Teach a man to fish and you feed him for a lifetime. “ ~ A Chinese Proverb
Mitglieder in diesem Forum: 0 Mitglieder und 3 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.