Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 18 Nov 2005
Offline Last Active Jul 22 2015 01:51 PM

#5230493 degenerate triangles

Posted by dpadam450 on 22 May 2015 - 03:32 PM

It shouldn't matter which one you choose, though webGL may be a lot slower so indices might be faster.




but instead use drawArrays with gl_triangels and a degenerate triangle to separate quads.

You would simply just have duplicated vertices where each triangle has 3 unique vertices. The degenerate thing would be if you were drawing indexed vertices using triangle strips/fans where you send -1 I believe as a degenerate index which tells the GPU to draw a brand new polygon that isn't attached to the edges of the previous triangle.

#5229015 How to create an MSAA shader? (For deferred rendering)

Posted by dpadam450 on 14 May 2015 - 01:50 PM

You have some misconceptions here:

MSAA takes a pixel and chops it into 2x2 sub-pixels (or more if you go higher quality). The pixel shader gets run ONCE for the pixel. If all of those 2x2 sub-pixels are inside a triangle, it will write the same color value 4 times. If the sub pixels fall on a triangle edge, it writes the pixel shader value only for the pixels the triangle lives in.

At the end of the day, the buffer is downsampled to ONE pixel by averaging the four sub-pixel values. So: There is no such thing as "Screen Space MSAA". There is no blurring, that is only with FXAA, because it has no sub-pixels, so it has to just smear spots with high contrast.

So when you are talking about deferred, you are talking about making a texture that is supporting MSAA (meaning it is actually much bigger because it has to hold all these sub-pixels) and then you can call a downsample function or something. I'm not sure how that specifically works but I'm assuming you just call a "gl" command to resolve the MSAA buffer to an actual texture.

Also, this makes it so that you are writing more data to your gBuffer for deferred so it could slow things down significantly. You could try only using MSAA on your color buffer and not any other ones.

#5228382 I'm having trouble attracting contributors to my project as it gets older

Posted by dpadam450 on 11 May 2015 - 10:28 AM

Didn't read all the responses since I didn't want to spend a lot of time on this topic:


People that have experience, simply don't like joining projects . We all started trying to make projects at the start and they always fail. As you grow you realize it is hard to actually find the right people to work together for no pay and with good experience. This is why new projects are usually a few guys who know each other that decide to go full-time to work on a game project / new company.


I would look at what it will take to get to the finish line. Put a spreadsheet of everything you can think of and put hour estimates and add them up. See how much time you work in a week etc. It is something that sounds like you don't have and are just aiming at random goals, there has to be structure in the project.

I didn't get to click the link since my work blocks game websites, but I'm assuming the quality isn't enough to get a kickstarter/donations page...? After 4 years if you don't have at least half the game done, then I would suggest letting it die. It relieves  a lot to just let it go and start fresh. I've done it many times.

#5228016 3D Texture upload fails

Posted by dpadam450 on 08 May 2015 - 04:04 PM

What is the format of the file you are loading in? Have you made sure that data is loaded correctly before going to the GPU? Is it actually a file format of unsigned shorts?


What happens if you do color = volValue*10 .......are the pixels actually different? Do they resemble the shape of a ct scan or just junk data?

#5227999 Back Face Culling idea

Posted by dpadam450 on 08 May 2015 - 01:55 PM

I had this idea years ago:

Normal back face culling is calculated once a triangle's points have been transformed, the cross product is taken from the order of the vertices and then it checks the sign-bit of the resultant vectors z-axis.

Why don't we instead pass in the view vector in model space (this would only work for non animated objects), perform the same cross product to get the triangles facing direction, and perform a dot(modelSpaceView, triangleDirection).


This way you don't have to transform half of your vertices before actually realizing the triangle is facing the wrong direction. Any issues with this? It would save lots of multiplications and additions...

#5224019 Normal Map Generator (from diffuse maps)

Posted by dpadam450 on 17 April 2015 - 11:46 AM

I mean take your brick texture and manually create a height map like this so the line parts have no height and the other parts have height:

The other ones do whatever you want. Again If you have a concrete diffuse, take a separate concrete texture and generate a normal map. This way you have normal map data that doesn't correlate to where there is already contrasted diffuse data.


A good example of how NOT to do it:



See those dark dirty lines? If you just grayscale that image for a height map and then normal map, it thinks that those dirt parts are actually height differentials and then makes contrasted normals around those areas. The result: all those darkened dirty lines just get darker and when lit, it won't really look like it is lit because it's already dark and contrasted along all those pixels.

#5219351 OpenGL FrameBuffer Object(FBO) issues

Posted by dpadam450 on 26 March 2015 - 10:12 AM

I'm not familiar with with the latest openGL. is GL_BGRA a valid format? Try GL_RGB, GL_RGBA  it may be stricter than that where you need GL_RGB8/GL_RGBA8.

#5219345 Skeletal animation issues

Posted by dpadam450 on 26 March 2015 - 09:53 AM

I think the baked version he is suggesting that those are the final outputs of what the bind pose should be (not going through skeletal animation).
Easiest way to debug is to set all your bones to the identity matrix and verify that through animation, your output is the bind pose.

Once you have this, manipulate a single bone matrix. Rotate it a couple degrees but don't animate it every frame.

#5217223 Normal Map Generator (from diffuse maps)

Posted by dpadam450 on 17 March 2015 - 06:23 PM

I would take the diffuse, block out the "lines" parts in black, the other parts in white. Potentially do a guassian blur depending on how smooth I want the edges of the block pieces. This will be my height map for a normal map. Generate the normal map


This could work as is but if you want micro detail normals, we can then go and find maybe a plain looking photo of some concrete and create a normal map from it that has those tiny details and overlay/merge them together with the previous normal map.


Then for specular I would go find another concrete texture, convert to black and white, play with the contrast/brightness and try it out. Sometimes you may actually want parts of the diffuse in the specular, sometimes you don't.


Now with your method, if you have a brick texture, you can't change the height of the bricks. You will only get a 1 pixel differential when creating the normal map from the brick part to the "lines" part. The algorithm will simply say thats a red pixel thats a white one, ok done. 


Again with any other concrete textures that are say white concrete with some dirty parts. The dirty parts will get normal mapped. That doesn't make sense and doesn't look good. The contrasting grime will generate different normals even though the surface hasn't changed just because of some dirt or leaking rust etc. So again just source a completely different concrete texture and generate a normal map from it. Using 1 image for all 3, you just get normals among the contrast in the diffuse, and it just never looks quite eye-popping.

#5216841 Normal Map Generator (from diffuse maps)

Posted by dpadam450 on 16 March 2015 - 08:20 AM


I'm making a commercial game


Then you should definitely swap a couple normal textures in game to see the difference it makes when sourcing different images, whether for this project or the next. It is a huge difference. I've never had a good result doing what you are suggesting, even though I did it for a while too.

#5216153 Normal mapping on flat water surface produces incorrect specular highlights

Posted by dpadam450 on 12 March 2015 - 04:04 PM

Your vertex shader looks odd.
Each triangle should have a tangent space vector and a normal vector (in model space).

Those vectors get multiplied by the model or modelview to get them into world space or camera space, depending on where you are performing your lighting.

Your vectors from the normal map are already in tangent space (they are relative to your TBN vectors).


So it should be
vec3 normal = modelviewmatrix*normal;

vec3 tangent = modelviewmatirx*tangent;

vec3 biTangent = modelviewmatrix*bitangent;


You have now put the NTB vectors from model, to world, to camera. Your light is probably in world space? so you need to get it into camera space so that all 4 vectors are in the same space to describe each other (so you can describe the light relative to the TBN)

vec3 lightVecView = viewmatrix*light;


vec3 lightVecTangentSpace = TBN*lightVecView;
For this line I usually just take the light as :  dot(lightVecView.x, tangent), dot(lightVecView.y, biTangent), dot(lightVecView.z, normal)

// so this is wrong, the inverse of the model matrix will put the normal from the exported space and rather than apply the world matrix to put the vectors in the world, you are putting them into some unknown 3d space from what I can tell.
mat3 normalMat = transpose(inverse(mat3(model)));


//as long as sun.Position.xyz is in camera space and the TBN vectors are in camera space, OR they are both in world space, you are fine.
mat3 TBN = transpose(mat3(t, b, n));
TangentFragPos = TBN * FragPos;
TangentLightDir = TBN * sun.Position.xyz;
TangentPlayerPos = TBN * playerPos;

#5214988 Mipmaps with multiple texture arrays

Posted by dpadam450 on 06 March 2015 - 12:11 PM

All texture parameters need to be set for the current bound texture. You can also change them at run time.


Also, you may want to turn on anisotropic filtering for some nicer results. Something you can change at run-time with the click of a button to see the change. 2,4,8,16 you can set it to. Will drop your performance a bit. I use 8.0 most of the time.

GLfloat fLargest;

#5214890 Mipmaps with multiple texture arrays

Posted by dpadam450 on 05 March 2015 - 11:10 PM

MipMapCount = log((double)TextureSize) / log((double)2);
This will calculate the mip map level given an input "texturesize", so you don't have to hard code it.

#5214889 Mipmaps with multiple texture arrays

Posted by dpadam450 on 05 March 2015 - 11:05 PM

    glTexStorage3D(GL_TEXTURE_2D_ARRAY, numDiffuseMipMapLevels, pixelFormat, TextureSize,TextureSize, textures.size());

mipLevelUploading = 0;
//loop through 'i' textures

glTexSubImage3D(GL_TEXTURE_2D_ARRAY, mipLevelUploading, 0, 0, i, diffuseTextureSize, diffuseTextureSize, depth, pixelFormat, GL_UNSIGNED_BYTE, texture->pixels);

That's my code and this is called about 8 times back to back uploading all my texture arrays.


Maybe your glTexStorage3D call isn't factoring in mip maps properly?..........aha scrolled up,:

glTexStorage3D(GL_TEXTURE_2D_ARRAY,11, GL_RGBA8, 4096, 4096, 1); <-------------------13 mip maps, not 11

#5214883 Mipmaps with multiple texture arrays

Posted by dpadam450 on 05 March 2015 - 09:44 PM



Is this called before or after the image loading calls? I forget if it should be before or after.


"The only thing that really affects things is whichever array is loaded first is the one with issues."


Just to be clear. If you bypass loading the second image, the first image will is completely fine?  And when you tested your texture arrays being applied, did you still load both, but only bind one during drawing? Since it obviously sounds like a loading issue, just wondering  if you still loaded them both.


Have you tried gDebugger to see if it says your texture arrays are mip-mapped. You can also use the texture viewer to see what they hold.