CubeMap: How can I use samplerCube ?
Hi,
I have a problem to use the CubeMap Texture with samplerCube in the FragmentShader.
As Example I use the VertexShader and the FragmentShader from here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=488668
Fragment Shader:
---------------------------------------
uniform samplerCube CubeMap;
varying vec3 vCubeMap;
void main (void)
{
gl_FragColor = textureCube(CubeMap, vCubeMap);
}
---------------------------------------
But I don't know how to put the CubeMap Textures in samplerCube in Main.
Can anyone help me?
Are you binding the texture with glBindTexture(GL_TEXTURE_CUBE_MAP, ....)?
Here is more information
http://www.opengl.org/wiki/index.php/GLSL_:_common_mistakes
Here is more information
http://www.opengl.org/wiki/index.php/GLSL_:_common_mistakes
Quote:Original post by V-man
Are you binding the texture with glBindTexture(GL_TEXTURE_CUBE_MAP, ....)?
Yes, I binding the texture with glBindTexture, but it don't work. Maybe I have a trivial Bug in the Main-Routine.
glUseProgramObjectARB(shader_Rost); //Shader
//Aktivate the Textures
uniform = glGetUniformLocationARB(shader_Rost, "Rost");
glUniform1iARB(uniform, 0);
uniform = glGetUniformLocationARB(shader_Rost, "Rost_Bumpmap");
glUniform1iARB(uniform, 1);
uniform = glGetUniformLocationARB(shader_Rost, "depthTex");
glUniform1iARB(uniform, 2);
uniform = glGetUniformLocationARB(shader_Rost, "CubeMap");
glUniform1iARB(uniform, 3);
//Lightposition
uniform = glGetUniformLocationARB(shader_Rost, "lightPos");
glUniform4fARB(uniform, getLampX(), getLampY(), getLampZ(), 1.0f);
//Textures
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture[4]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, BumpMap[0]);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, depthTex);
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_CUBE_MAP, texture[6]);
glPushMatrix();
Rostwuerfel();
glPopMatrix();
From the stuff you posted, you seem to be talking about some other shader instead of that very basic shader you first posted. If the very basic shader doesn't work, then you have to give more information or post the entire code. Make sure your texcoords are correct. I could also recommend a library that generates geometry with the proper str coordinates for cube, sphere, etc. (glhlib)
Yes, the stuff I posted was from the shader without the Cubemap. The shader was only a texture with Bump Mapping before. With the the both shader
Vertex shader:
varying vec3 vCubeMap;void main(){ vec3 vVertex = vec3(gl_ModelViewMatrix * gl_Vertex); vec3 vNormal = vec3(gl_NormalMatrix * gl_Normal); vec3 vView = -normalize(vVertex); vCubeMap = reflect(vView, vNormal); gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;}
Fragment shader:
uniform samplerCube CubeMap;varying vec3 vCubeMap;void main (void){ gl_FragColor = textureCube(CubeMap, vCubeMap);}
the cube are black. I have changed the Fragment shader to
Fragment shader:
uniform samplerCube CubeMap;varying vec3 vCubeMap;void main (void){ vec3 vCubeMapTEST(1.0, 0.5, 1.0); gl_FragColor = textureCube(CubeMap, vCubeMapTEST);}
but the Cube ist permanent black. I think the CubeMap Textures are wrong with glBindTexture(GL_TEXTURE_CUBE_MAP, texture[6]).
But here is the complete Code, but the comments are German.
#include <stdlib.h>#include "glut.h"#include "Textures.h"#include "Shader.h"#include <iostream>#include "glext.h"#include <math.h>using namespace std;//Shader VariablenGLhandleARB shader; //shader programGLhandleARB vs; //vertex shaderGLhandleARB ps; //pixel shaderGLhandleARB shader_Silber; //shader programGLhandleARB vs_Silber; //vertex shaderGLhandleARB ps_Silber; //pixel shaderGLhandleARB shader_Glas; //shader programGLhandleARB vs_Glas; //vertex shaderGLhandleARB ps_Glas; //pixel shaderGLhandleARB shader_Rost; //shader programGLhandleARB vs_Rost; //vertex shaderGLhandleARB ps_Rost; //pixel shaderGLhandleARB shader_Messing; //shader programGLhandleARB vs_Messing; //vertex shaderGLhandleARB ps_Messing; //pixel shaderGLhandleARB shader_Holz; //shader programGLhandleARB vs_Holz; //vertex shaderGLhandleARB ps_Holz; //pixel shaderGLhandleARB shader_Steinboden; //shader programGLhandleARB vs_Steinboden; //vertex shaderGLhandleARB ps_Steinboden; //pixel shaderGLhandleARB shader_Glitzer; //shader programGLhandleARB vs_Glitzer; //vertex shaderGLhandleARB ps_Glitzer; //pixel shader//Handle für BumpMap TangenteGLhandleARB prgmBMap;GLuint BMapTangent;// Model Methodenextern void Tisch();extern void Boden(GLfloat);extern void Flaschenlampe(GLfloat X, GLfloat Y, GLfloat Z); //Taschenlampe ^^ extern void Silberwuerfel(GLuint BMapTangent);extern void Rostwuerfel();extern void Glaswuerfel();extern void Messingwuerfel(GLuint BMapTangent);extern void Steinboden();extern void Skybox();// Kamera Funktionen und Variablen float fRotation; //Für Berechnung der Kamera Bewegungfloat getCamX(); //Rückgabe des Kamera Wertes auf der X-Achsefloat getCamZ(); //Rückgabe des Kamera Wertes auf der Z-Achsefloat getCamY(); //Rückgabe des Kamera Wertes auf der Y-Achsefloat fCamHigh; //Kamera Höhefloat fCamRadius;//Kamera Radius (Kleiner = Näher an Objekten / Größer = Weiter von den Objekten)// Lampen Funktionen und Variablen float getLampX(); //Rückgabe des Licht /Lampen Wertes auf der X-Achsefloat getLampY(); //Rückgabe des Licht /Lampen Wertes auf der Y-Achsefloat getLampZ(); //Rückgabe des Licht /Lampen Wertes auf der Z-Achsefloat fRotationLamp; //Für Berechnung der Lampen Bewegungfloat fLampHigh; //Lampen Höhe// Kamerafahrtbool CameraSelfMove;bool CameraSelfMove_Up;bool CameraSelfMove_Zoom;void CameraMovement();// Aktive Elementebool GlaswuerfelAktive;bool MessingwuerfelAktive;bool RostwuerfelAktive;bool SilberwuerfelAktive;// Aktiverung der Pfeiltastenvoid pfeile(int a_keys, int x, int y);// Methoden für Shadowmapvoid shadowBegin(); //Beginn eines Shadowmap Modelvoid shadowEnd(); //Ende eines Shadowmap Modelvoid bauSchattenSzene(); //Baut die Szene für die Shadowmapfloat proj[16];float mv[16]; GLuint depthTex; //Datei um die Shadowmap als Textur zu speichernGLuint BumpMap[9]; //Bumpmapping GLuint texture[9];//Extensions für MultitexturingPFNGLACTIVETEXTUREPROC glActiveTexture; //Active Texture setzt aktive Textureinheit PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f; //setzt 2d-texturkoordinaten einer textureinheitPFNGLMULTITEXCOORD3FPROC glMultiTexCoord3f; //setzt 3d-texturkoordinaten einer textureinheitextern PFNGLVERTEXATTRIB3FARBPROC glVertexAttrib3fARB;//Extension functionsextern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;extern PFNGLUNIFORM1IARBPROC glUniform1iARB;extern PFNGLUNIFORM1FARBPROC glUniform1fARB;extern PFNGLUNIFORM4FARBPROC glUniform4fARB;extern PFNGLUNIFORM4FVARBPROC glUniform4fvARB;extern PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;extern PFNGLVERTEXATTRIB4FARBPROC glVertexAttrib4fARB ;extern PFNGLGETATTRIBLOCATIONARBPROC glGetAttribLocationARB; extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;extern PFNGLVALIDATEPROGRAMARBPROC glValidateProgramARB;/*---------------------------------------------------------// INIT---------------------------------------------------------*/void Init(){ //////////// SHADER glGenTextures(1, &depthTex); glBindTexture(GL_TEXTURE_2D, depthTex); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,512,512, 0,GL_DEPTH_COMPONENT,GL_UNSIGNED_BYTE, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); //Variablen für Kamera und Licht setzen fCamHigh = 1.0; fRotation = 0; fLampHigh = 0; fCamRadius =7; // Kamerafahrt CameraSelfMove = false; CameraSelfMove_Up = false; CameraSelfMove_Zoom = false; //Aktive Elemente GlaswuerfelAktive = true; MessingwuerfelAktive = true; RostwuerfelAktive = true; SilberwuerfelAktive = true; //Adressen der Multitexturing-Funktionen setzen glActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress("glActiveTexture"); glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2f"); glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC) wglGetProcAddress("glMultiTexCoord3f"); //Texturen laden CreateTGATexture(&texture[0], "Textures//Holz.tga"); CreateTGATexture(&texture[1], "Textures//Silber.tga"); CreateTGATexture(&texture[2], "Textures//Glas.tga"); CreateTGATexture(&texture[3], "Textures//Messing.tga"); CreateTGATexture(&texture[4], "Textures//Rost.tga"); CreateTGATexture(&texture[5], "Textures//Steinboden.tga"); CreateTGATexture(&texture[6], "Textures//mauer.tga"); CreateTGATexture(&BumpMap[0], "Textures//Rost_normal.tga"); CreateTGATexture(&BumpMap[1], "Textures//Steinboden_normal.tga"); CreateTGATexture(&BumpMap[2], "Textures//Holz_normal.tga"); CreateTGATexture(&BumpMap[3], "Textures//Silber_normal.tga"); CreateTGATexture(&BumpMap[4], "Textures//Glas_normal.tga"); CreateTGATexture(&BumpMap[5], "Textures//Messing_normal.tga"); CreateTGATexture(&BumpMap[6], "Textures//mauer_normal.tga"); // OpenGL Settings glClearColor(1.0f, 1.0f, 1.0f, 0.0f); glEnable(GL_DEPTH_TEST); //glEnable(GL_TEXTURE_CUBE_MAP_EXT); glDepthFunc(GL_LEQUAL); glClearDepth(1.0f); //Shader initialisieren bool glslSupported = InitGLSL(); if(!glslSupported) cout<<"Error Initializing GLSL"<<endl; //Shader laden LoadShader(&shader, &vs, &ps, "Shader//Normal_VS.txt", "Shader//Normal_PS.txt"); LoadShader(&shader_Silber, &vs_Silber, &ps_Silber, "Shader//Silber_VS.txt", "Shader//Silber_PS.txt"); LoadShader(&shader_Glas, &vs_Glas, &ps_Glas, "Shader//Glas_VS.txt", "Shader//Glas_PS.txt"); LoadShader(&shader_Messing, &vs_Messing, &ps_Messing, "Shader//Messing_VS.txt", "Shader//Messing_PS.txt"); LoadShader(&shader_Rost, &vs_Rost, &ps_Rost, "Shader//Rost_VS.txt", "Shader//Rost_PS.txt"); LoadShader(&shader_Steinboden, &vs_Steinboden, &ps_Steinboden, "Shader//Steinboden_VS.txt", "Shader//Steinboden_PS.txt"); LoadShader(&shader_Holz, &vs_Holz, &ps_Holz, "Shader//Holz_VS.txt", "Shader//Holz_PS.txt"); //LoadShader(&shader_Glitzer, &vs_Glitzer, &ps_Glitzer, "Shader//Glitzer_VS.txt", "Shader//Glitzer_PS.txt"); //Lichtquellen Eigenschaften setzen float lightambient[4] = {0.5,0.5,0.5,1.0}; glLightfv(GL_LIGHT0,GL_AMBIENT,lightambient); float lightdiffuse[4] = {0.5,0.5,0.5,1.0}; glLightfv(GL_LIGHT0,GL_DIFFUSE,lightdiffuse); float lightspecular[4] = {1.0,1.0,1.0,1.0}; glLightfv(GL_LIGHT0,GL_SPECULAR,lightspecular); float lightposition[4] = {getLampX(), getLampY(), getLampZ(),1.0}; glLightfv(GL_LIGHT0,GL_POSITION,lightposition); }/*---------------------------------------------------------// Render---------------------------------------------------------*/void Render(void){ //schaut ob automatische Kamera Bewegung an ist if(CameraSelfMove) CameraMovement(); // Setzt die neuen Kamera und Licht Positionen ////////////////////////////////////////// // Shadowmap erzeugen ////////////////////////////////////////// glViewport(0,0,512,512); //Setzt den Viewport auf 512x512 die größe der Shaowmap Textur glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Leert die Buffer glLoadIdentity(); gluLookAt(getLampX(), getLampY(), getLampZ(), 0.0015f,0.001f,0.005f, 0,1,0); //setzt die Kamera auf Poistion der Lichtquelle glGetFloatv(GL_MODELVIEW_MATRIX, mv); glGetFloatv(GL_PROJECTION_MATRIX, proj); bauSchattenSzene(); //baut die Szene nach glBindTexture(GL_TEXTURE_2D, depthTex); //Bindet die Textur glCopyTexImage2D(GL_TEXTURE_2D, 0,GL_DEPTH_COMPONENT, 0,0,512,512,0); //Speichert das Bild in die depthTex Textur ////////////////////////////////////////// // Normale Szene erzeugen ////////////////////////////////////////// glViewport(0, 0, 800, 600); //setzt den Viewport wieder zurück glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Leert die Buffer glLoadIdentity(); gluLookAt(getCamX(), getCamY(), getCamZ(), 0.0, 0.25, 0.0, 0.0, 1.0, 0.0); //Position der Kamera float lightposition[4] = {getLampX(), getLampY(), getLampZ(),1.0}; //Position der Lichtquelle glLightfv(GL_LIGHT0,GL_POSITION,lightposition); //shader aktivieren glUseProgramObjectARB(shader); //Tangente für Bump Mapping BMapTangent=glGetAttribLocationARB(shader_Messing,"tangent"); int uniform; ///////////////////////////////// Holztisch/////////////////////////////// glUseProgramObjectARB(shader_Holz); //Shader für Holz shadowBegin(); //Inititalisiert die Shadowmap///////////////////////////////// ROSTWÜRFEL/////////////////////////////// glUseProgramObjectARB(shader_Rost); //Initialisiert den Shader für den Rostwürfel float time = 1; shadowBegin(); //Inititalisiert die Shadowmap //Texturen dem Objekt bekannt machen uniform = glGetUniformLocationARB(shader_Rost, "Rost"); glUniform1iARB(uniform, 0); //erstes bild kommt in erste textureinheit uniform = glGetUniformLocationARB(shader_Rost, "Rost_Bumpmap"); glUniform1iARB(uniform, 1); //erstes bild kommt in erste textureinheit uniform = glGetUniformLocationARB(shader_Rost, "depthTex"); glUniform1iARB(uniform, 2); //erstes bild kommt in erste textureinheit uniform = glGetUniformLocationARB(shader_Rost, "CubeMap"); glUniform1iARB(uniform, 3); //erstes bild kommt in erste textureinheit //Lichtposition bekannt machen uniform = glGetUniformLocationARB(shader_Rost, "lightPos"); glUniform4fARB(uniform, getLampX(), getLampY(), getLampZ(), 1.0f); //Aktivieren der Texturen glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren... glBindTexture(GL_TEXTURE_2D, texture[4]); //...und die in die textur gerenderte szene binden glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, BumpMap[0]); //...und die in die textur gerenderte szene binden glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, depthTex); //...und die in die textur gerenderte szene binden glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_CUBE_MAP, texture[6]); //Erstellt die Szene glPushMatrix(); Rostwuerfel(); glPopMatrix(); shadowEnd(); //Beendet die Shadowmap glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren...///////////////////////////////// Steinboden/////////////////////////////// glUseProgramObjectARB(shader_Steinboden); //Initialisiert den Shader für den Steinboden shadowBegin(); //Inititalisiert die Shadowmap //Texturen dem Objekt bekannt machen uniform = glGetUniformLocationARB(shader_Steinboden, "Steinboden"); glUniform1iARB(uniform, 0); //erstes bild kommt in erste textureinheit uniform = glGetUniformLocationARB(shader_Steinboden, "Steinboden_Bumpmap"); glUniform1iARB(uniform, 1); //erstes bild kommt in erste textureinheit uniform = glGetUniformLocationARB(shader_Steinboden, "depthTex"); glUniform1iARB(uniform, 2); //erstes bild kommt in erste textureinheit //Lichtposition bekannt machen uniform = glGetUniformLocationARB(shader_Steinboden, "lightPos"); glUniform4fARB(uniform, getLampX(), getLampY(), getLampZ(), 1.0f); //Aktivieren der Texturen glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren... glBindTexture(GL_TEXTURE_2D, texture[5]); //...und die in die textur gerenderte szene binden glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, BumpMap[1]); //...und die in die textur gerenderte szene binden glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, depthTex); //...und die in die textur gerenderte szene binden //Erstellt die Szene glPushMatrix(); Steinboden(); glPopMatrix(); shadowEnd(); //Beendet die Shadowmap glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren...///////////////////////////////// Skybox / Kellerwände/////////////////////////////// glUseProgramObjectARB(shader); //Initialisiert den Shader für den Skybox shadowBegin(); //Inititalisiert die Shadowmap //Texturen dem Objekt bekannt machen uniform = glGetUniformLocationARB(shader, "Skybox"); glUniform1iARB(uniform, 0); //erstes bild kommt in erste textureinheit uniform = glGetUniformLocationARB(shader, "Skybox_Bumpmap"); glUniform1iARB(uniform, 1); //erstes bild kommt in erste textureinheit# uniform = glGetUniformLocationARB(shader, "depthTex"); glUniform1iARB(uniform, 2); //erstes bild kommt in erste textureinheit //Lichtposition bekannt machen uniform = glGetUniformLocationARB(shader, "lightPos"); glUniform4fARB(uniform, getLampX(), getLampY(), getLampZ(), 1.0f); //Aktivieren der Texturen glActiveTexture(GL_TEXTURE0); //erste textureinheit aktivieren... glBindTexture(GL_TEXTURE_2D, texture[6]); //...und die in die textur gerenderte szene binden glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, BumpMap[6]); //...und die in die textur gerenderte szene binden glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, depthTex); //...und die in die textur gerenderte szene binden //Erstellt die Szene glPushMatrix(); Skybox(); glPopMatrix(); //Beendet die Shadowmap shadowEnd(); glActiveTexture(GL_TEXTURE0); //erste textureinheit wieder aktivieren///////////////////////////////// Lampe/////////////////////////////// glUseProgramObjectARB(shader); //Initialisiert den Shader für die Taschenlampe //Texturen dem Objekt bekannt machen glBindTexture(GL_TEXTURE_2D, texture[3]); //Aktivieren der Texturen glActiveTexture(GL_TEXTURE0); //erste textureinheit wieder aktivieren //Erstellt die Szene glPushMatrix(); Flaschenlampe(getLampX(),getLampY(),getLampZ()); glPopMatrix();///////////////////////////////// Stellt die Szene dar/////////////////////////////// //shader deaktivieren glUseProgramObjectARB(0); glutSwapBuffers(); }/*---------------------------------------------------------// changeSize(int w, int h)---------------------------------------------------------*/void changeSize(int w, int h) { if(h == 0) h = 1; float ratio = 1.0* w / h; glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, w, h); gluPerspective (75.0f, float(w)/float(h), 0.1f, 400.0f); glMatrixMode(GL_MODELVIEW);}/*---------------------------------------------------------// Main---------------------------------------------------------*/int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100,100); glutInitWindowSize(800,600); glutCreateWindow("Ich hab Hunger!"); Init(); glutDisplayFunc(Render); glutReshapeFunc(changeSize); glutIdleFunc(Render); glutKeyboardFunc(processNormalKeys); glutSpecialFunc(pfeile); glutMainLoop(); return 0;}/*---------------------------------------------------------// bauSchattenSzene() benötigt für die Shadowmap---------------------------------------------------------*/void bauSchattenSzene(){ //Baut die Szene genauso auf wie in Render() aber ohne Texturen usw //Da die Shadowmap dies nicht benötigt glPushMatrix(); Tisch(); glPopMatrix(); if(GlaswuerfelAktive) { glPushMatrix(); Glaswuerfel(); glPopMatrix(); } if(SilberwuerfelAktive) { glPushMatrix(); Silberwuerfel(BMapTangent); glPopMatrix(); } if(MessingwuerfelAktive) { glPushMatrix(); Messingwuerfel(BMapTangent); glPopMatrix(); } if(RostwuerfelAktive) { glPushMatrix(); Rostwuerfel(); glPopMatrix(); } glPushMatrix(); Steinboden(); glPopMatrix(); glPushMatrix(); Skybox(); glPopMatrix();}/*---------------------------------------------------------// shadowBegin() benötigt für die Shadowmap---------------------------------------------------------*/void shadowBegin(){ glActiveTexture(GL_TEXTURE1); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, depthTex); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glTranslatef(0.5f,0.5f,0.5f); glScalef(0.5f,0.5f,0.5f); glMultMatrixf(proj); glMultMatrixf(mv); glMatrixMode(GL_MODELVIEW);}/*---------------------------------------------------------// shadowEnd() benötigt für die Shadowmap---------------------------------------------------------*/void shadowEnd(){ glActiveTexture(GL_TEXTURE2); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glActiveTexture(GL_TEXTURE0);}
It looks like texture[6] is not a cubemap
You are calling
CreateTGATexture(&texture[6], "Textures//mauer.tga");
glBindTexture(GL_TEXTURE_2D, texture[6]);
You are calling
CreateTGATexture(&texture[6], "Textures//mauer.tga");
glBindTexture(GL_TEXTURE_2D, texture[6]);
Quote:Original post by V-man
It looks like texture[6] is not a cubemap
You are calling
CreateTGATexture(&texture[6], "Textures//mauer.tga");
glBindTexture(GL_TEXTURE_2D, texture[6]);
And how do I make a cubemap? I know what a cubemap is, but I don't know do make a cubemap in GLSL.
[Edited by - GhostRider03 on June 15, 2008 2:29:16 PM]
You should search for some tutorials or some example.
developer.nvidia.com has many examples.
It's not by making a 2D texture and binding it as a cubemap, that's for sure!
developer.nvidia.com has many examples.
It's not by making a 2D texture and binding it as a cubemap, that's for sure!
Quote:Original post by V-man
It's not by making a 2D texture and binding it as a cubemap, that's for sure!
I know that.
Quote:Original post by V-man
You should search for some tutorials or some example.
developer.nvidia.com has many examples.
I had search in the Internet and found some tutorials like http://developer.nvidia.com/object/cube_map_ogl_tutorial.html (this is the best i found), but it don't help.
I had read two OpenGL and GLSL books and the only thing I know is the technical background about cubemaps. And now I search for a example to make a cubemap, but up to now without success.
V-man thanks for your help, even if it came to no result.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement