Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Fr Jul 18, 2025 04:58

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 
Autor Nachricht
BeitragVerfasst: Sa Mai 16, 2009 14:56 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Hi,

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.

Bild

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.

Any advice appreciated.

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 16, 2009 17:03 
Offline
DGL Member
Benutzeravatar

Registriert: Di Sep 20, 2005 13:18
Beiträge: 1054
Wohnort: Dresden
Programmiersprache: C, C++, Pascal, OPL
Hello,

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. :lol:

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


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 16, 2009 18:57 
Offline
DGL Member
Benutzeravatar

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

Projekte: https://github.com/tak2004


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 16, 2009 19:02 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
TAK2004 hat geschrieben:
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.

Thanks.

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 16, 2009 20:18 
Offline
Guitar Hero
Benutzeravatar

Registriert: Do Sep 25, 2003 15:56
Beiträge: 7810
Wohnort: Sachsen - ERZ / C
Programmiersprache: Java (, Pascal)
Maybe Spheremapping can help you.
With this technique you can add details to a simple object.

A sample is in this tutorial from our wiki: http://wiki.delphigl.com/index.php/Tutorial_Lektion_8#Das_etwas_andere_Licht

Together with multitexturing, you can create some "funky" surfaces.

_________________
Blog: kevin-fleischer.de und fbaingermany.com


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 16, 2009 21:54 
Offline
DGL Member
Benutzeravatar

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 networkmy 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


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 16, 2009 22:01 
Offline
DGL Member
Benutzeravatar

Registriert: Mi Jan 24, 2007 00:44
Beiträge: 144
Like a bevel, or a 45 degree angled quad before the 90 degree angled quad? Or even more?

I'll have a play around... and report back.

_________________
Cheers, DpM
http://www.hmusiccentre.org.uk


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Sa Mai 16, 2009 23:33 
Offline
DGL Member
Benutzeravatar

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 networkmy 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


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 8 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

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.

Suche nach:
Gehe zu:  
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.007s | 14 Queries | GZIP : On ]