Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 Jul 2011
Offline Last Active Apr 22 2014 04:29 AM

#5086087 Deferred Shading lighting stage

Posted by rocklobster on 15 August 2013 - 06:08 AM

Thanks. Right now I'm currently outputting Position, Normal, Diffuse, Tangent and BiTangent. Should I also output specular and ambient properties? Or will this be too much memory usage?

#5085847 Deferred Shading lighting stage

Posted by rocklobster on 14 August 2013 - 09:33 AM

Hey guys,


I've attempted to implement deffered shading lately and I'm a bit confused about the lighting stage.


This is the algorithm for what I do at the moment:


- Bind render target
- bind my G-buffer shader program
- render the scene


- Bind my normal shader for rendering the quad 
(fragment shader takes Position, Normal and Diffuse samplers as uniforms)
- Render full screen quad
- swap buffers

So am I right to assume that to light the scene I should also add this change to the second pass:


- Bind my normal shader for rendering the quad 
(fragment shader takes Position, Normal and Diffuse samplers as uniforms)
    - Set this light as uniform for the shader
    - Render full screen quad 
- swap buffers

And in my fragment shader I'll have the code which shades all the pixels based on the type of light passed in (directional, point or spot).


Cheers for any help

#5023729 High School Student with High Goals -- Need Advice

Posted by rocklobster on 20 January 2013 - 08:13 PM

Hello everyone,

I need some advice from you all. I have two problems, one is lack of money and one is lack of drive.

I am a Sophomore High School student who wants to be successful early and is able to go to Stanford. From what I understand Stanford is looking only for the best, so in order to be "the best" I am trying to hold a 4.1+ GPA, trying to make some video games that I can sell so Stanford can see that I show initiative and so that they can see that I can program, and I am trying to play sports at the same time to show that I am a well rounded student (and I enjoy them). I enjoy making games and programming. I like to use C++ and OpenGL and when I was learning and just messing around with that language and library in middle school, I had no problems (probably because I had more time and was less stressed). Now I have problems.

I am having problems with drive. I have this game idea that I like and have been working on but I think these high aspirations of mine are not allowing me to apply myself to programming because I am too busy (and stressed) with school and sports. I go to school at around 8 and I get home after sports at around 5:30. I have plenty of time till bed, but I just don't have the drive to work on my self produced projects (my game for example). Does anyone have any ideas as to why I can't seem to hop onto my computer and start programming? I always seem to drift to youtube and just start watching videos there. I just don't have any will power at this point in the day to push myself to start programming. If I ever do start, I enjoy it, but I just can't seem to start. Does anyone have any advice for me?

Also being a high school student and soon to be college student, I need money. I am looking to use my intermediate programming abilities to make some extra cash and my video game endeavors are not producing any income at the moment. I have looked at freelancing on freelancer.com but it seems as though the amounts are always low and the bids are always in before I even have a chance to compete. So is there any other site or way I can use my programming abilities to make some extra cash? I have looked locally but there isn't much.



Maybe it's because you are mentally and physically drained after such a long day, and you don't have the energy left for your own projects? If this was the case I would definitely prioritise my activities. I'd have gone crazy at university If I never had a side project I could spend time during the week to keep my mind of university work. 


Also take some value from what this person said:


Personal satisfaction is so much better than reaching milestones set by society.


Which doesn't mean drop everything, but find a nice balance to keep yourself mentally healthy and satisfied. 

#5020854 Grass and what to do

Posted by rocklobster on 12 January 2013 - 03:45 PM



This might help you. I think there is a youtube vid showing it off also.

#5011563 how to texture an object with DevIL

Posted by rocklobster on 17 December 2012 - 12:44 AM

Thanks for the response, but i still can't get this to work. I fixed 'Bind texture' part in my GenerateTexture() function but I don't see the way to use

GLuint id = glGetUniformLocation(programId, "gSampler");

and i put this

glUniform1i(id, 0); // 0 for GL_TEXTURE0
in my render function

the problem is that the tutorials on the link i posted use more than one shader function to load and process shaders. So I can't get programId from outside. When I put this function inside CompileShaders function that is used in tutorials I still can't make this work. Can you help?

Basically the getUniformLocation and uniform1i functions are for sending data to the shader. So to draw your textured object you need to:

- Bind the shader
- Set texture unit
- Bind texture
- Set the uniforms for the shader
- Draw the object

Make sure your function that creates your shaders returns a GLuint for the program id (this will be the return value from glCreateProgram())

then you can bind the shader, texture and set the uniforms

// loading the data
GLuint myShader = CreateShaders("vertex.vert", "fragment.frag");
GLuint texId = CreateTexture("logo.png");

// when drawing

glBindTexture(GL_TEXTURE_2D, texId);

GLuint loc = glGetUniformLocation(myShader, "gSampler");
glUniform1i(loc, 0);

// then just draw your mesh
glDrawArrays(GL_TRIANGLES, 0, mesh.count);

#4999581 Final Year Project

Posted by rocklobster on 10 November 2012 - 02:29 AM

If you do end up going with c++, have a look at Raknet.

Also, there is a networking and multiplayer section of these forums, probably already has your answers.

#4994465 The maths behind the rotations

Posted by rocklobster on 27 October 2012 - 11:52 AM

Are you familiar with matrix multiplication? If not I suggest you have a look into it. Something that also helped me understand rotations was doing simple vector rotations (cameras are a good example).


Possibly learning how to use cos and sin to move around the bounds of the unit circle would be a good start. http://en.wikipedia.org/wiki/Unit_circle

If you are standing in the middle of the unit circle looking directly right (x = 1, y = 0) and say you want to rotate 45 degrees you would get those coordinates like this

x = cos(45.0);
y = sin(45.0);

This will give you the new direction at 45 degrees from the original direction. Think about it, cos(90) gives a value of 0. This is correct because if we rotated 90 degrees, the x component of the vector (direction) would be 0, because it would be pointing directly up (x = 0, y = 1).

Hope this helps a bit, rotations are very tricky to start off learning.

#4988214 Questions about GLEW and its versions

Posted by rocklobster on 08 October 2012 - 10:22 PM

I think you can specify the context you want to use with your window creation library. I think for SDL it's something like

For GLFW i think they have some flags you can set when you open the window using


#4985266 [Answered] Good math library for OpenGL

Posted by rocklobster on 29 September 2012 - 10:59 PM

I've used GLM. Header file only math library, the syntax is similar to the shader language GLSL though.

#4939332 collada animation with multiple skeletons

Posted by rocklobster on 11 May 2012 - 10:05 AM

Ive been able to load static geometry using my own loader for collada that I wrote. However the next step is to add animation. The problem I am having is what do when an instance_controller has multiple skeletons. In my current model I am trying to load every node that is rigged is referencing every joint. For example

<instance_controller url="#geom-Cylinder018-skin1">

I am not sure what I am suppose to do with this? At the moment I am linking them all to the correct nodes in the visual_scene. However every node in the model does what you see above! Ive loaded it using AssimpView just to see that it actual is rendered and that works fine. Can anybody explain to me what I am suppose to do in the above situation. Thanks

#4932773 SDL reading 24bit texture pixels

Posted by rocklobster on 19 April 2012 - 05:50 AM

Hi guys,

I've recently been trying to generate a texture using a procedural method however i've ran into a problem. What i'm currently doing is looping through each pixel in a heightmap, and then summing up the pixels of x many textures by a certain weight (eg. If the heightmap pixel was fully white, then it's the highest point so a snow texture will be weighted strongly). The problem is at a certain point in this algorithm my getColourAt(int x, int y) breaks.

    RGBColour TextureReader::getColourAt(int x, int y)
	    Uint8* p = (Uint8*)m_surface->pixels + y * m_surface->pitch + x * m_surface->format->BytesPerPixel;
	    Uint32 pixels = p[(y * m_surface->w) + x];	   // format, &red, &green, &blue);
	    RGBColour rgb(red, green, blue);
	    return rgb;

It breaks with x index of 109 and y index of 236. The textures i'm using are 256x256 24bit TGA textures. The only problem i've been able to narrow down to is that it might be something to do with 24bit texture and using an Uint32.

Just to clarify i've tested

Uint8* p = (Uint8*)m_surface->pixels + y * m_surface->pitch + x * m_surface->format->BytesPerPixel;

Using Uint32* instead of Uint8* and it breaks at a different index. I've checked that the surface is valid and it is. I can view the bbp, format, width and height etc.

Thanks for any assistance.

- rocklobster