Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Community-Fossil
Community-Fossil
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
uniform sampler2D texunit0; uniform sampler2D texunit1; uniform vec3 lpos; varying vec4 pos; varying vec3 normal; varying vec3 lightVec; varying vec3 viewVec; void main( void ) { pos= gl_ModelViewProjectionMatrix * gl_Vertex; normal = normalize(gl_NormalMatrix * gl_Normal); lightVec = normalize(lpos - pos.xyz); viewVec = vec3 (normalize(- (gl_ModelViewProjectionMatrix *gl_Vertex))); gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; gl_TexCoord[1] = gl_MultiTexCoord1; gl_TexCoord[2] = gl_TextureMatrix[0]*gl_ModelViewMatrix*gl_Vertex; } FRAGMENT: uniform sampler2D texunit0; uniform sampler2D texunit1; uniform sampler2D texunit2; uniform vec3 lpos; varying vec4 pos; varying vec3 normal; varying vec3 lightVec; varying vec3 viewVec; void main( void ) { gl_TexCoord[2] = gl_TexCoord[2]/gl_TexCoord[2].w; gl_TexCoord[2]=(gl_TexCoord[2]+ 1.0) * 0.5; vec4 base = texture2D(texunit0, gl_TexCoord[0].xy); vec3 norm = texture2D(texunit1, gl_TexCoord[0].xy).xyz*2.0-1.0; vec4 shadow = texture2D(texunit2,gl_TexCoord[2].xy); norm = normalize(gl_NormalMatrix * norm); float fresnel =max((norm.z-0.6)*-1.0,0.0); float diffuse = max(dot(lightVec, norm),0.0); float specular = max(dot(reflect(lightVec,norm), viewVec), 0.0)*1.7; specular=pow(specular,8.0); float shade=1; if((shadow.z+0.005) < gl_TexCoord[2].z) shade=0; else shade= diffuse; gl_FragColor = (base* shade)+ (vec4(0.0,0.1,0.3,0.0)*fresnel) +(vec4(0.5,0.5,0.4,0.0)*specular*shade); } |
Community-Fossil
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
void setShadowMatrix(){ mat4 modelview, projection; mat4 bias = mat4(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0); glGetFloatv(GL_MODELVIEW_MATRIX, modelview.getArray()); glGetFloatv(GL_PROJECTION_MATRIX, projection.getArray()); //shadowMatrix = bias*projection*modelview; glMatrixMode(GL_TEXTURE); glLoadIdentity(); glLoadMatrixf(bias.getArray()); glMultMatrixf(projection.getArray()); glMultMatrixf(modelview.getArray()); glGetFloatv(GL_TEXTURE_MATRIX, shadowMatrix.getArray()); glMatrixMode(GL_MODELVIEW); } |
C-/C++-Quelltext |
|
1 |
shadowMatrix = bias*projection*modelview; |
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Administrator
Community-Fossil
Und was mich noch viel mehr interessiert, warum multipliziert OpenGL Matrizen anders als der Rest der Welt???
Community-Fossil
Zitat
Bist du dir sicher dass nicht einfach nur du deine Matritzen anders multiplizierst als der Rest der Welt?
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »DeKugelschieber« (11.08.2011, 23:28)
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
octave-3.2.4.exe:1> A = [2 4 8 0; 4 5 -7 1; 9 4 -3 -2; 1 0 6 7] A = 2 4 8 0 4 5 -7 1 9 4 -3 -2 1 0 6 7 octave-3.2.4.exe:2> B = [6 -7 4 5; 9 0 0 -3; 4 -2 8 8; 9 3 -1 5] B = 6 -7 4 5 9 0 0 -3 4 -2 8 8 9 3 -1 5 octave-3.2.4.exe:3> A*B ans = 80 -30 72 62 50 -11 -41 -46 60 -63 14 -1 93 2 45 88 |
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
float M[16] = { 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f }; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
mat4 M = { 0.5f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.0f, 0.5f, 0.0f, 0.0f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f }; |
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »dot« (11.08.2011, 23:53)
Werbeanzeige