Jump to content

  • Log In with Google      Sign In   
  • Create Account

Murdocki

Member Since 30 Jan 2010
Offline Last Active Feb 16 2014 05:37 AM

#5101769 Sun Shadows

Posted by Murdocki on 16 October 2013 - 04:43 AM

Usually you dont see the entire world, so you can limit the area you have to include in your shadow map, thus increasing it's resolution. As with other rendering optimizations it's always good to not render what you dont see, meaning you only need to have shadows inside your player's frustum.

Using the sun's direction you can build an oriented bounding box around your frustum. You'll then have to extend that box in the direction of the sun so that it reaches all the way up to your scene/world's roof. This ensures that objects (a tree or tall building for example) that are outside of the player's view but are casting shadows into the player's view are still rendered into your shadow map.

If you extend the obb's size to the roof of your scene and the sun is at an angle(which is pretty much always) then you'll be extending a part of the obb outside of the scene's bounding box. This will lose you a little bit of precision, which you can solve by using a sheared matrix for the sun's projection.




#4976743 understanding return by value.

Posted by Murdocki on 05 September 2012 - 02:27 AM

If you want to avoid the intermediate constructor/destructor you could explicitly use the copy constructor like so:
Test B( A.Make(11) );

To avoid the copy during method return you either have to return a reference or a pointer, but for this you'll need to guarantee that the object will survive beyond the method's scope. You could also use reference out parameters like so:
bool Make(int ID, Test& outParam )
{
  outParam = Test(ID);
  return true; //Return something for the user to know if creation succeeded.
}
int main(int argc, char **argv)
{
  Test A = Test(10);
  Test B;
  A.Make(11, B);
}



#4975550 Initializing DevIL

Posted by Murdocki on 01 September 2012 - 03:29 PM

Are you sure you have to init ilu and ilut yourself? I'm not and i can use them just fine:

..context creation..
ilInit();
ilutRenderer( ILUT_OPENGL );
..texture loading..
GLuint textureID = ilutGLLoadImage( charArr );
ilutGLBuildMipmaps();

provided charArr is a proper file, textureID then contains the id of the opengl texture you can use.


#4974218 Maintaining aspect ratio in fullscreen mode

Posted by Murdocki on 28 August 2012 - 01:57 PM

Since you want to make your viewport width match your window width you just need to use the window's height and the desired viewport height to calculate what you should provide in the y parameter for your glViewport call:
http://www.opengl.org/sdk/docs/man/xhtml/glViewport.xml
x, y specify the lower left corner of the viewport.

Your game coordinates should be viewport relative unless you make them so that they aren't.


#4972555 Titlescreen Art ( want opinions )

Posted by Murdocki on 23 August 2012 - 06:30 AM

light really helps bring structure in clouds. Depending on what you are aiming for these images may give you some ideas:

cloud roof
high contrast
no ground reference (also birds!)
internal light source (lightning)

These examples have higher contrast though so that might distract the user from the more important parts like menu items and character.


#4972527 Titlescreen Art ( want opinions )

Posted by Murdocki on 23 August 2012 - 03:46 AM

looks very clean and the particles should be awesome in movement.
Only 1 comment, not sure if it's intended but the depth seems to be missing from the clouds.


#4955193 Why do i get stripes instead of a plain color? (in a defined area)

Posted by Murdocki on 03 July 2012 - 02:45 AM

i'm not quite sure why it would create the stripes but it's probably uninitialized memory or unintended texture access. Also i'm not quite sure at how the client states should work with immediate mode. I'm only using those calls when i'm using vertex buffers.

glEnableClientState enables usage of provided data. So for example if you want to use vertex colors you would enable GL_COLOR_ARRAY and then make a call to glColorPointer to provide the colors that should be used.

it looks like glColor is not used when drawing arrays, try enabling the color array and provide the colors. It may also be a good idea to look up either immediate mode rendering or vertex buffer objects, i suggest the latter. This may be a good page to give you an idea.

*edit: When you are uncertain what a specific opengl call does, try paste it into google, add xml as second search string and then hit the page from opengl.org. They're usually pretty good.


#4954875 Why do i get stripes instead of a plain color? (in a defined area)

Posted by Murdocki on 02 July 2012 - 05:45 AM

looks like there's still some leftovers from rendering the background, you could check if you've disabled texturing and if vertex coloring is set up properly.
Not quite sure on that language you're using or immediate mode, but looks like the first image is correct and the others use some sort of texture.


#4907966 if cube is far don't render.

Posted by Murdocki on 31 January 2012 - 06:15 AM

if all you're after is drawing 10000 identical cubes you might want to use instancing. Otherwise do what hedman said and use a quad/oct-tree and implement batching. You are potentially making a crazy amount of drawcalls now so that could be improved.


#4892352 Recommended Method for Rendering a GUI with VBOs

Posted by Murdocki on 09 December 2011 - 03:35 PM

You can tackle this task in several steps using a profiler to see what step you should take next, if any. You can start with one vbo per widget or geometry type, i am using one quad with dimensions 1 by 1. Then i'm setting a size uniform to a shader to scale this quad appropiately to the size of the widget. Also providing a translation uniform for position ofcourse ;).


When you have got this working you will see a huge number of draw calls. What you can do then is either implement the render to texture together with lazy updating, or you could switch to one big dynamic vertex buffer which shouldn't be too bad either knowing whole characters get skinned trough dynamic vertex buffers, so you got some bandwidth availabe. For the first option you might want to make sure to share a depth buffer with your scene's rendering somehow so you can chip off a few of those fragment shader executions. Every fragment behind hud/gui doesnt need to be lit or use other expensive calculations. For the second option you probably first need atlas textures because it wont make much sense to use one big vertex buffer if you still have to switch textures and only render portions. Also if you know your widgets wont be moving very much you might want to make an exception here and drop interleaved vertex formats for a separation between position and uv. You are probably switching textures/uvs more often than positions so this could save you some bandwidth.


#4853319 proper glUniform use

Posted by Murdocki on 24 August 2011 - 12:19 PM

You probably misinterpreted the "not changing frequently" part, uniforms are described as not changing frequently because they're the same for the whole draw call unlike vertex attributes which change every vertex. Also in reply to v-man calling glGetUnitformLocation is a call you are suggested to do load time rather than run time, you want to profile this on your target platform though, in my case it's lots faster to just make the calls than to map them.


PARTNERS