Sign in to follow this  
DarkDemon

OpenGL OpenGL Texture IDs.... help please :(

Recommended Posts

Hello, I'm still rather at a novice level with Opengl and I've been hitting the same problem for awhile now. I have a proprietary 3Ds loader, and framework. Each of the objects in the scene have their own struct with information about it's structure and texture ID. I've been playing around / debugging for awhile and the texture I load is in never binded to the object and I'm not sure why. When I add break points I can see that glBindTexture(GL_TEXTURE_2D, contains the correct address for this texture ); The problem is it's never drawn, the raw texture is loaded and 2d textures are enabled. I'm using a set of arbitrary values for the tex co ords for now to ensure it's correctly displaying. The framework does read in the tex co ords but for the purposes of testing I've no need to use them yet. So the main problem is the texture is never loaded onto the model I select. I'm not entirely sure why either... I would appreciate any assistance. The project can be downloaded here: http://darkdemon.org/gl/spaceships.zip These are the offending classes, Ball.cpp, where objects are drawn and textures for that object are assigned
#include "ball.h"



void Ball::draw(){
    int l_index;
	glPushMatrix();
  	glTranslatef(x,y,z);

  	if (fileloaded){
    glScalef(0.01f,0.01f,0.01f);
    glRotatef(theta,1.0f,0.0f,0.0f);



	//Whether the object has a defined texture
	if(object.texture != NULL)
	{
	  glEnable(GL_TEXTURE_2D);
	  glBindTexture(GL_TEXTURE_2D,object.texture);
	}
	else
	{
      glDisable(GL_TEXTURE_2D);
	}

	glBegin(GL_TRIANGLES);


    for (l_index=0;l_index<object.polygons_qty;l_index++)
	{

        //----------------- FIRST VERTEX -----------------
        //TEX

		glTexCoord2f(-0.0f,0.0f); // -> arbitrary values to test to see if the texture is loading in

		// Coordinates of the first vertex
        glVertex3f( object.vertex[ object.polygon[l_index].a ].x,
                    object.vertex[ object.polygon[l_index].a ].y,
                    object.vertex[ object.polygon[l_index].a ].z); //Vertex definition

        //----------------- SECOND VERTEX -----------------
		//TEX

		glTexCoord2f(1.0f,0.0f); //-> arbitrary values to test to see if the texture is loading in

        // Coordinates of the second vertex
        glVertex3f( object.vertex[ object.polygon[l_index].b ].x,
                    object.vertex[ object.polygon[l_index].b ].y,
                    object.vertex[ object.polygon[l_index].b ].z);
        
        //----------------- THIRD VERTEX -----------------
		//TEX

		glTexCoord2f(1.0f,1.0f); //-> arbitrary values to test to see if the texture is loading in

        // Coordinates of the Third vertex
        glVertex3f( object.vertex[ object.polygon[l_index].c ].x,
                    object.vertex[ object.polygon[l_index].c ].y,
                    object.vertex[ object.polygon[l_index].c ].z);


		 
    }
	glEnd(); 
   
	//glutSwapBuffers();
  }

  glPopMatrix();
}


And Scene.cpp Where new objects are created and the texture id for an object generated
#include "scene.h"
#include "ball.h"

void Scene::initialise(){


    float startarray[4][6]={{9.0f,9.0f,0.0f,0.1f,-0.25f,0.0f},
                            {7.0f,9.0f,0.0f,0.05,-0.05f,0.0f},
                            {3.0f,9.0f,0.0f,0.01f,-0.02f,0.0f},
                            {0.0f,9.0f,0.0f,0.03f,-0.076f,0.0f}
    };
    nBalls=5;
    myBall=new Ball[nBalls];

	for(int i=0;i<nBalls;i++){
		myBall[i].initialise(0.0f,0.0f,0.0f);
	
	}

    for(int i=0;i<nBalls;i++){
        myBall[i].setx(startarray[i][0]);
        myBall[i].sety( startarray[i][1] );
		myBall[i].setz(startarray[i][2]  );

        myBall[i].setvx(startarray[i][3] );
        myBall[i].setvy(startarray[i][4] );
        myBall[i].setvz(startarray[i][5] );
       
		myBall[i].loadfile();
        myBall[i].setangle();
    }
  
	//setup a particular objects texture
	//generate new glutTextureID ready for binding for this object
	myBall[0].loadTexture("blue.raw");


}
 
void Scene::spinballs(){
  for(int i=0;i<nBalls;i++){
      myBall[i].spin();
    }
}

void Scene::moveobjects(){
    for(int i=0;i<nBalls;i++){
      myBall[i].move();
    }
}

void Scene::render(){
  //glColor3f(1.0f,0.0f,0.0f);
//  glTranslatef(x,y,z);
  // glScalef(10.0f,10.0f,10.0f);
  //glutSolidCube(5.0);
  for(int i=0;i<nBalls;i++)
	  myBall[i].draw();

}

void Scene::cdetect(){
   
    for(int i=0;i<nBalls;i++){
      if((myBall[i].getx()<-10.0)||(myBall[i].getx()>10.0))
        myBall[i].setvx(myBall[i].getvx()*-1.0f);

      if((myBall[i].gety()<-10.0)||(myBall[i].gety()>10.0))
        myBall[i].setvy(myBall[i].getvy()*-1.0f);
    }

    for(int i=0;i<nBalls;i++){
	for(int j=i+1;j<nBalls;j++){
	    float tx=myBall[i].getx()-myBall[j].getx();
	    float ty=myBall[i].gety()-myBall[j].gety();
	    float tz=myBall[i].getz()-myBall[j].getz();

            float dist=sqrt(tx*tx+ty*ty+tz*tz);
            if(dist<0.9f){
                float temp=myBall[i].getvx();
                myBall[i].setvx(myBall[j].getvx());
                myBall[j].setvx(temp);
                temp=myBall[i].getvy();
                myBall[i].setvy(myBall[j].getvy());
                myBall[j].setvy(temp);
                temp=myBall[i].getvz();
                myBall[i].setvz(myBall[j].getvz());
                myBall[j].setvz(temp);
	    }
	}
    }
}


[Edited by - DarkDemon on December 16, 2008 8:40:15 AM]

Share this post


Link to post
Share on other sites
You made a few mistakes. First you need a valid render context when creating your textures. The second thing is, your data is stored as 24 bit RGB. So you need to change the lines:


unsigned char * data = (unsigned char*) malloc(512*512*3); // <--
fread(data,1,512*512*3,infile); // <-- raw file contains RGB data, not RGBA
fclose(infile);

// ...

glTexImage2D(GL_TEXTURE_2D,0,3,512,512,0,GL_RGB,GL_UNSIGNED_BYTE,data); // <-- changed 3 and GL_RGB


And one last thing. This'll not work...

if(object.texture != NULL)


...because most of your objects texturemembers aren't initialized correctly.

Share this post


Link to post
Share on other sites
Thanks David,

I have made those revisions so I can only assume the problem now is with the render context as the texture still doesn't get drawn, I'm not too sure on these though.. I assume that was setup in the viewer class...

Revised source

#include "ball.h"



void Ball::draw(){
int l_index;
glPushMatrix();
glTranslatef(x,y,z);

if (fileloaded){
glScalef(0.01f,0.01f,0.01f);
glRotatef(theta,1.0f,0.0f,0.0f);


glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,object.texture);

glBegin(GL_TRIANGLES);


for (l_index=0;l_index<object.polygons_qty;l_index++)
{

//----------------- FIRST VERTEX -----------------
//TEX

glTexCoord2f(0.0f,1.0f); // -> arbitrary values to test to see if the texture is loading in

// Coordinates of the first vertex
glVertex3f( object.vertex[ object.polygon[l_index].a ].x,
object.vertex[ object.polygon[l_index].a ].y,
object.vertex[ object.polygon[l_index].a ].z); //Vertex definition

//----------------- SECOND VERTEX -----------------
//TEX

glTexCoord2f(1.0f,1.0f); //-> arbitrary values to test to see if the texture is loading in

// Coordinates of the second vertex
glVertex3f( object.vertex[ object.polygon[l_index].b ].x,
object.vertex[ object.polygon[l_index].b ].y,
object.vertex[ object.polygon[l_index].b ].z);

//----------------- THIRD VERTEX -----------------
//TEX

glTexCoord2f(0.0f,1.0f); //-> arbitrary values to test to see if the texture is loading in

// Coordinates of the Third vertex
glVertex3f( object.vertex[ object.polygon[l_index].c ].x,
object.vertex[ object.polygon[l_index].c ].y,
object.vertex[ object.polygon[l_index].c ].z);
}
glEnd();

}

glPopMatrix();
}






Viewer class

#include "viewer.h"


Viewer::Viewer(){


WinName="";
BufType=GLUT_SINGLE;

for(int i=0;i<3;i++){
background[i]=0.0f;
}

}

Viewer::~Viewer(){
return;
}

void Viewer::Init(int argc,char **argv){

eye[0]=0.0f;
eye[1]=0.5;
eye[2]=25.0;

aim[0]=0.0f;
aim[1]=0.0f;
aim[2]=0.0f;

upright[0]=0.0f;
upright[1]=1.0f;
upright[2]=0.0f;

glutInit(&argc,argv);

}

void Viewer::CreateWin(char *Name,int Width,int Height){
WinName=Name;
WinWidth=Width;
WinHeight=Height;
}

void Viewer::SetValue(myEnum PName,myEnum Type){

switch(PName){
case BUFFER:
if(Type==MDOUBLE)
BufType=GLUT_DOUBLE;
else
if(Type==SINGLE)
BufType=GLUT_SINGLE;
break;
case BACKCOLOUR:
break;
default:
break;
}
}


void Viewer::InitWorld(){
vrman=new WorldManager;
vrman->initialise();

}
void Viewer::InitCamera(){
mycamera=new camera(PERSPECTIVE);
mycamera->SetValue(MNEAR,5.0f);
mycamera->SetValue(YANGLE,45.0f);


mycamera->SetValuev(AIMAT, aim);
mycamera->SetValuev(UPDIRECTION, upright);
mycamera->SetValuev(POSITION, eye);

mycamera->SetValue(MFAR,33.0f);
mycamera->SetValue(HEIGHT,WinHeight);
mycamera->SetValue(ASPECT,1.0f);
}

void Viewer::SetCamera(float nvalue,float viewangle){
mycamera->SetValue(MNEAR, nvalue);
mycamera->SetValue(YANGLE, viewangle);

}

void Viewer::Show(){

GLInit();
glutMainLoop();

}


void Viewer::GLInit(){


glutInitDisplayMode(BufType |GLUT_RGB |GLUT_DEPTH);
glutInitWindowSize(WinWidth, WinHeight);
glutCreateWindow(WinName);
glutReshapeFunc(Reshape);
glutDisplayFunc(Display);
glutMouseFunc(Mouse);
glutIdleFunc(Idle);
glutKeyboardFunc(Keyboard);
glutSpecialFunc(SpecialKey);
// glEnable(GL_DEPTH_TEST);
glClearColor(0.0f,0.0f,0.0f,1.0f);

}


void Viewer::Display(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

vrman->exec_loop();

glFlush();
if(BufType==GLUT_DOUBLE){

glutSwapBuffers();
}


}

void Viewer::Reshape(int w,int h){

glViewport(0,0,(GLsizei)w,(GLsizei)h);
WinWidth=w;
WinHeight=h;
mycamera->SetValuev(POSITION,eye);
mycamera->SetValuev(AIMAT,aim);
mycamera->Render();

}

void Viewer::Mouse(int button,int state,int x,int y){

vrman->mouse(button,state,x,y);
Display();
}

void Viewer::Idle(){
vrman->idle();
Display();
}

void Viewer::Keyboard(unsigned char key,int x,int y){

switch(key){
case 0x14b:
case GLUT_KEY_UP:
eye[2]-=0.5;
aim[2]-=0.5;
break;
case GLUT_KEY_DOWN:
eye[2]+=0.5;
aim[2]+=0.5;
break;
case GLUT_KEY_LEFT:
eye[0]-=0.5;
aim[0]-=0.5;
break;
case GLUT_KEY_RIGHT:
eye[0]+=0.5;
aim[0]+=0.5;
break;
default:
vrman->keyboard((unsigned char)key,x,y);
break;
}

Display();
}

void Viewer::SpecialKey(int key, int x, int y){
switch(key){
case GLUT_KEY_F1:
upright[0]=0.0f;
upright[1]=0.0f;
upright[2]=-1.0f;
aim[0]=0.0f;
aim[1]=0.0f;
aim[2]=0.0f;
eye[0]=0.0f;
eye[1]=25.0f;
eye[2]=0.0f;
break;
case GLUT_KEY_F2:
upright[0]=0.0f;
upright[1]=1.0f;
upright[2]=0.0f;
aim[0]=0.0f;
aim[1]=0.0f;
aim[2]=0.0f;
eye[0]=0.0f;
eye[1]=0.5f;
eye[2]=25.0f;
break;
case GLUT_KEY_F12:
vrman->restart();
break;
case GLUT_KEY_UP:
eye[2]-=0.5;
aim[2]-=0.5;
break;
case GLUT_KEY_DOWN:
eye[2]+=0.5;
aim[2]+=0.5;
break;
case GLUT_KEY_LEFT:
eye[0]-=0.5;
aim[0]-=0.5;
break;
case GLUT_KEY_RIGHT:
eye[0]+=0.5;
aim[0]+=0.5;
break;
case GLUT_KEY_PAGE_UP:
eye[1]+=0.5;
aim[1]+=0.5;
break;
case GLUT_KEY_PAGE_DOWN:
eye[1]-=0.5;
aim[1]-=0.5;
break;
default:
vrman->keyboard((unsigned char)key,x,y);
break;
}
mycamera->SetValuev(UPDIRECTION,upright);
mycamera->SetValuev(POSITION,eye);
mycamera->SetValuev(AIMAT,aim);
mycamera->Render();
Display();
}





[Edited by - DarkDemon on December 16, 2008 8:59:39 AM]

Share this post


Link to post
Share on other sites
Thanks David,

I'm taking some guesses here, I tried this

http://msdn.microsoft.com/en-us/library/ms537549(VS.85).aspx


Viewer.cpp

void Viewer::Show(){

// create a rendering context
hglrc = wglCreateContext (hdc);

// make it the calling thread's current rendering context
wglMakeCurrent (hdc, hglrc);

GLInit();
glutMainLoop();
}




Still no texture is rendered, I'm probably doing it complely wrong I also read this http://www.nullterminator.net/opengl32.html but I couldn't implement it without messing it up. I've been unable to find any clear simple way to construct one.

Share this post


Link to post
Share on other sites
Thanks David,

I've tried to move it.. still no luck.


Test.cpp
I tried moving ->Show which calls glutInt and the update but I got memory errors.


Viewer *myViewer=new Viewer;
myViewer->Init(argc,argv);
myViewer->InitWorld();
myViewer->SetValue(BUFFER,MDOUBLE);
myViewer->CreateWin("Further Programming 3D",1000,800);
myViewer->InitCamera();
myViewer->Show();







Viewer.cpp I got rid of the GLInit call from the show method, and moved it to InitWorld before everything is created. I get no errors but everything moves slow, and flashes.....

void Viewer::InitWorld(){
GLInit();
vrman=new WorldManager;
vrman->initialise();

}





I've also tried moving myViewer->InitWorld(); below myViewer->Show(); again I get memory problems.


I've also made GLInt public and called it like this


Viewer *myViewer=new Viewer;
myViewer->Init(argc,argv);

myViewer->SetValue(BUFFER,MDOUBLE);
myViewer->CreateWin("Further Programming 3D",1000,800);
myViewer->GLInit();
myViewer->InitWorld();
myViewer->InitCamera();
myViewer->Show();



Everything loaded correctly, but still no texture.

Share this post


Link to post
Share on other sites
The flashes are probably becauses you just use a single buffer. Ok... let's see what you can do:


Viewer *myViewer=new Viewer;
myViewer->Init(argc,argv);
myViewer->SetValue(BUFFER,MDOUBLE);
myViewer->CreateWin("Further Programming 3D Apps Assignment: By Adam Davis",1000,800);
myViewer->InitWorld(); // <-- Init the world AFTER creating the window + gl initialization
myViewer->InitCamera();

yViewer->Show();




void Viewer::CreateWin(char *Name,int Width,int Height){
WinName=Name;
WinWidth=Width;
WinHeight=Height;
GLInit(); // <-- Initialize GL after the windows properties are set
}




void Viewer::Show(){

//GLInit(); // <-- Don't initialize GL twice
glutMainLoop();

}



And the other stuff I mentioned before. Have fun! :)

Share this post


Link to post
Share on other sites
Thanks David for the help,

That stopped the flicker and the models move fine. Sadly though that annoying issue of the texture not being applied at all seems apparent.

As a test in scene.cpp I call

myBall[0].loadTexture("blue.raw");

This should map the first object with a blue image but it doesn't work.

I did some debugging by adding break points to ensure that the image does get loaded. I also tested to ensure that inside draw glBindTexture(GL_TEXTURE_2D,object.texture); contains the correct address for the image, and it does which is something I can't understand. Everything is loaded in but it doesn't appear to be applied, I know the text co ords are just arb values but I would aspect to see least some of the blue from the image on the object.

- Again thanks again for the help it's been like hitting a brick wall.


#include "ball.h"



void Ball::draw(){
int l_index;
glPushMatrix();
glTranslatef(x,y,z);

if (fileloaded){
glScalef(0.01f,0.01f,0.01f);
glRotatef(theta,1.0f,0.0f,0.0f);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,object.texture);
glBegin(GL_TRIANGLES);


for (l_index=0;l_index<object.polygons_qty;l_index++)
{

//----------------- FIRST VERTEX -----------------
//TEX

glTexCoord2f(0.0f,1.0f); // -> arbitrary values to test to see if the texture is loading in

// Coordinates of the first vertex
glVertex3f( object.vertex[ object.polygon[l_index].a ].x,
object.vertex[ object.polygon[l_index].a ].y,
object.vertex[ object.polygon[l_index].a ].z); //Vertex definition

//----------------- SECOND VERTEX -----------------
//TEX

glTexCoord2f(1.0f,1.0f); //-> arbitrary values to test to see if the texture is loading in

// Coordinates of the second vertex
glVertex3f( object.vertex[ object.polygon[l_index].b ].x,
object.vertex[ object.polygon[l_index].b ].y,
object.vertex[ object.polygon[l_index].b ].z);

//----------------- THIRD VERTEX -----------------
//TEX

glTexCoord2f(0.0f,1.0f); //-> arbitrary values to test to see if the texture is loading in

// Coordinates of the Third vertex
glVertex3f( object.vertex[ object.polygon[l_index].c ].x,
object.vertex[ object.polygon[l_index].c ].y,
object.vertex[ object.polygon[l_index].c ].z);
}
glEnd();

}

glPopMatrix();
}





[Edited by - DarkDemon on December 16, 2008 8:52:05 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Announcements

  • Forum Statistics

    • Total Topics
      628336
    • Total Posts
      2982157
  • Similar Content

    • By DejayHextrix
      Hi, New here. 
      I need some help. My fiance and I like to play this mobile game online that goes by real time. Her and I are always working but when we have free time we like to play this game. We don't always got time throughout the day to Queue Buildings, troops, Upgrades....etc.... 
      I was told to look into DLL Injection and OpenGL/DirectX Hooking. Is this true? Is this what I need to learn? 
      How do I read the Android files, or modify the files, or get the in-game tags/variables for the game I want? 
      Any assistance on this would be most appreciated. I been everywhere and seems no one knows or is to lazy to help me out. It would be nice to have assistance for once. I don't know what I need to learn. 
      So links of topics I need to learn within the comment section would be SOOOOO.....Helpful. Anything to just get me started. 
      Thanks, 
      Dejay Hextrix 
    • By mellinoe
      Hi all,
      First time poster here, although I've been reading posts here for quite a while. This place has been invaluable for learning graphics programming -- thanks for a great resource!
      Right now, I'm working on a graphics abstraction layer for .NET which supports D3D11, Vulkan, and OpenGL at the moment. I have implemented most of my planned features already, and things are working well. Some remaining features that I am planning are Compute Shaders, and some flavor of read-write shader resources. At the moment, my shaders can just get simple read-only access to a uniform (or constant) buffer, a texture, or a sampler. Unfortunately, I'm having a tough time grasping the distinctions between all of the different kinds of read-write resources that are available. In D3D alone, there seem to be 5 or 6 different kinds of resources with similar but different characteristics. On top of that, I get the impression that some of them are more or less "obsoleted" by the newer kinds, and don't have much of a place in modern code. There seem to be a few pivots:
      The data source/destination (buffer or texture) Read-write or read-only Structured or unstructured (?) Ordered vs unordered (?) These are just my observations based on a lot of MSDN and OpenGL doc reading. For my library, I'm not interested in exposing every possibility to the user -- just trying to find a good "middle-ground" that can be represented cleanly across API's which is good enough for common scenarios.
      Can anyone give a sort of "overview" of the different options, and perhaps compare/contrast the concepts between Direct3D, OpenGL, and Vulkan? I'd also be very interested in hearing how other folks have abstracted these concepts in their libraries.
    • By aejt
      I recently started getting into graphics programming (2nd try, first try was many years ago) and I'm working on a 3d rendering engine which I hope to be able to make a 3D game with sooner or later. I have plenty of C++ experience, but not a lot when it comes to graphics, and while it's definitely going much better this time, I'm having trouble figuring out how assets are usually handled by engines.
      I'm not having trouble with handling the GPU resources, but more so with how the resources should be defined and used in the system (materials, models, etc).
      This is my plan now, I've implemented most of it except for the XML parts and factories and those are the ones I'm not sure of at all:
      I have these classes:
      For GPU resources:
      Geometry: holds and manages everything needed to render a geometry: VAO, VBO, EBO. Texture: holds and manages a texture which is loaded into the GPU. Shader: holds and manages a shader which is loaded into the GPU. For assets relying on GPU resources:
      Material: holds a shader resource, multiple texture resources, as well as uniform settings. Mesh: holds a geometry and a material. Model: holds multiple meshes, possibly in a tree structure to more easily support skinning later on? For handling GPU resources:
      ResourceCache<T>: T can be any resource loaded into the GPU. It owns these resources and only hands out handles to them on request (currently string identifiers are used when requesting handles, but all resources are stored in a vector and each handle only contains resource's index in that vector) Resource<T>: The handles given out from ResourceCache. The handles are reference counted and to get the underlying resource you simply deference like with pointers (*handle).  
      And my plan is to define everything into these XML documents to abstract away files:
      Resources.xml for ref-counted GPU resources (geometry, shaders, textures) Resources are assigned names/ids and resource files, and possibly some attributes (what vertex attributes does this geometry have? what vertex attributes does this shader expect? what uniforms does this shader use? and so on) Are reference counted using ResourceCache<T> Assets.xml for assets using the GPU resources (materials, meshes, models) Assets are not reference counted, but they hold handles to ref-counted resources. References the resources defined in Resources.xml by names/ids. The XMLs are loaded into some structure in memory which is then used for loading the resources/assets using factory classes:
      Factory classes for resources:
      For example, a texture factory could contain the texture definitions from the XML containing data about textures in the game, as well as a cache containing all loaded textures. This means it has mappings from each name/id to a file and when asked to load a texture with a name/id, it can look up its path and use a "BinaryLoader" to either load the file and create the resource directly, or asynchronously load the file's data into a queue which then can be read from later to create the resources synchronously in the GL context. These factories only return handles.
      Factory classes for assets:
      Much like for resources, these classes contain the definitions for the assets they can load. For example, with the definition the MaterialFactory will know which shader, textures and possibly uniform a certain material has, and with the help of TextureFactory and ShaderFactory, it can retrieve handles to the resources it needs (Shader + Textures), setup itself from XML data (uniform values), and return a created instance of requested material. These factories return actual instances, not handles (but the instances contain handles).
       
       
      Is this a good or commonly used approach? Is this going to bite me in the ass later on? Are there other more preferable approaches? Is this outside of the scope of a 3d renderer and should be on the engine side? I'd love to receive and kind of advice or suggestions!
      Thanks!
    • By nedondev
      I 'm learning how to create game by using opengl with c/c++ coding, so here is my fist game. In video description also have game contain in Dropbox. May be I will make it better in future.
      Thanks.
    • By Abecederia
      So I've recently started learning some GLSL and now I'm toying with a POM shader. I'm trying to optimize it and notice that it starts having issues at high texture sizes, especially with self-shadowing.
      Now I know POM is expensive either way, but would pulling the heightmap out of the normalmap alpha channel and in it's own 8bit texture make doing all those dozens of texture fetches more cheap? Or is everything in the cache aligned to 32bit anyway? I haven't implemented texture compression yet, I think that would help? But regardless, should there be a performance boost from decoupling the heightmap? I could also keep it in a lower resolution than the normalmap if that would improve performance.
      Any help is much appreciated, please keep in mind I'm somewhat of a newbie. Thanks!
  • Popular Now