Jump to content
  • Advertisement

too_many_stars

Member
  • Content count

    156
  • Joined

  • Last visited

Community Reputation

336 Neutral

About too_many_stars

  • Rank
    Member

Personal Information

  • Role
    Programmer
  • Interests
    Art
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. too_many_stars

    const parameter good practice question

    I think you guys are right. It really does not add any value to const a primitive parameter variable for the sake of documentation to whomever the user might be. I have never seen it done that way but was just wondering if it might be good practice since I have very limited exposure to production level code. Thanks again, Mike
  2. Good Morning, I just have a quick question about good programming practice with parameter arguments in C++. Is it good programming practice to const all parameter arguments that will not be changed internally? For example. void Agent::setHealth( const int h ){ health = h; } However, if I have the same function, but this time wish to signify to users that the parameter value might not be what's assigned to a private/protected variable inside the class I could do something like this void Agent::setHealth( int h ){ health = glm::clamp( h , 0 , INT_MAX ); } I am also talking about primitive types available through C++ not const referenced variables passed as arguments. Is it a waste of time to 'const' and just use the variable with function documentation? Thanks so much for the time, Mike
  3. too_many_stars

    Dealing with Non Center of Mass Translations

    Thanks so much again for the help Randy, I will do as you suggest and try to make some sense out of it. Mike
  4. Hello Everyone, It's very common in 2D and 3D to use the center of mass ( COM ) as the point of rotation. This method additionally make it easy to fit the model into a bounding sphere, AABB, capsule whatever. This is what I have always done. However, now I am trying to model a 3D hinged door. This door, due to the nature of rotation, will not be centered at the COM, instead, it will have to be translated locally either to the left or right depending on where the hinge should be. My question is... What is the best way of dealing with Non-COM rotations? The problem is, once the symmetry is gone from Non-COM model my bounding volumes are thrown off as they rely on COM. And obviously now when I am transforming from local to world co-ords it becomes harder to gauge where the object will be and how it will fit into the rest of the world. Also, I have to introduce some new variables such as glm::vec3 local_position to keep track of the new object center. It makes everything a lot messier. Thanks again for all the help, Mike
  5. too_many_stars

    glsl - material, texture and light relationship

    Thanks for the response Silence, I do like the lookup idea. It's going on the to do list. Mike
  6. Hi Guys, A quick question. I have a 3d grid sector made out of AABB boxes ( see picture below ). When I turn the light on, I get the light catching the extremities of the boxes creating ugly line artifacts. Just wondering if there's a way to solve this problem. Thanks again, Mike
  7. too_many_stars

    glsl - material, texture and light relationship

    Thanks for the response Silence@Sid, The reason I want material with a texture is if I simply want to change the texture color. I guess I could introduce another RGB variable just to change the texture color but that seems like a waste of memory. Mike
  8. Hello Everyone, I am having a difficult time coming up with a relationship between light, material, and a texture inside a shader. I have a model that has the following properties. 1.) texture 2.) material and a world light source. If the light is on, inside the fragment shader, I do the following vec3 light_frag = phongADS( material ); gl_FragColor = vec4( light_frag , 1 ) * texture( sampler , uv ); This simply calculates the light fragment based on the material with an ambient, diffuse and specular component and the multiplies this by the texture fragment However, when the light is off, and I am only dealing with a material and a texture what is the relationship between the two? Does one just take for example the diffuse component of the material like so... gl_FragColor = vec4( material.diffuse , 1 ) * texture( sampler , uv ); More generally, my question is this: Given a model ( say an AABB ) with a material, a texture and a light source, what is the proper per fragment calculation ( if light is on or off ) that takes all three into account Thanks, Mike
  9. too_many_stars

    GLubyte array and getPixel function

    Hi Sponji, Thanks so much, that's the correct answer. I thought I was tying into the array properly ( I even did a few examples on paper to make sure it worked). Mike
  10. Hello Everyone, I am having issues with extracting a pixel from a GLubyte array. Here is what I have GLubyte* pixels = SOIL_load_image( file_path.c_str() , &width, &height, &channels, SOIL_LOAD_AUTO ); // load the pixel array //later in the code //RGB is holds GLint r, g, b RGB Texture::getPixel( const int x, const int y ) const{ if( x < 0 || x > width -1 || y < 0 || y > height -1 ) return RGB(); int w = channels * width; int idx = y * w + x; GLubyte r = pixels[ idx + 0 ]; GLubyte g = pixels[ idx + 1 ]; GLubyte b = pixels[ idx + 2 ]; return RGB( (GLint) r , (GLint) g , (GLint) b ); I think I am tying into the array correctly. I do get integer values for my RGB struct, but they are all wrong. I get colors that don't even appear on the texture. If anyone knows what I am doing wrong, please let me know. Thanks so much, Mike
  11. too_many_stars

    GLSL Rendering Mulptile Materials Across a Model

    Thank you so much Koen, that's a great answer. I figured there was going to have to be some kind of batching process. Mike
  12. Hello Everyone, Here is what I have so far when it comes to rendering a model with glsl glsl->setUniform( "Ka" , material.ambient ); glsl->setUniform( "Kd" , material.diffuse ); glsl->setUniform( "Ks" , material.specular ); glsl->setUniform( "mat_shine" , material.shininess ); glBindVertexArray( vao_id ); glDrawArrays( GL_TRIANGLES , 0 , vertices.size() ); glBindVertexArray( 0 ); This works fine for a single material applied across the entire model. However, I now import an .obj model with various materials from Blender. After mapping triangle faces to material ids I am unsure how the above call to glDrawArrays( GL_TRIANGLES , 0 , vertices.size() ); needs to change in order to render more than one material on a single model. Any help would be great appreciated, Mike
  13. too_many_stars

    Shader class instancing question

    Thanks for the reply. Maybe a singleton registry with std::map< std::string , GLSL > pair? That would give a quick look up table for a particular shader and would make it available in any render method. Thanks Mike
  14. Hello Everyone, I have been going over a number of books and examples that deal with GLSL. It's common after viewing the source code to have something like this... class Model{ public: Model(); void render(); private: GLSL glsl_program; }; ////// .cpp Model::Model(){ glsl_program.compileAndLinkShaders() } void Model::render(){ glsl_program.use() //render something glsl_program.unUse(); } Is this how a shader program should be used in real time applications? For example, if I have a particle class, for every particle that's created, do I want to compiling and linking a vertex, frag shader? It seems to a noob such as myself this might not be the best approach to real time applications. If I am correct, what is the best work around? Thanks so much for all the help, Mike
  15. too_many_stars

    Help with GL_ELEMENT_ARRAY_BUFFER

    That makes sense, thanks so much!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!