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!


Plerion

Member Since 02 Nov 2009
Offline Last Active May 24 2015 01:49 AM

Topics I've Started

Increased frame time with less workload

23 May 2015 - 03:12 PM

Hi all

 

As my title already suggests I am having a little bit of a weird problem. First of all let me show you a picture of what im talking about.

 

This is how the scene normally looks right now:

DzslL8e.png

 

Currently there is virtually no optimization, just frustum culling and "not-rendering" of invisible blocks. As you can see it renders with over 250 FPS. However if I turn 90° to the left, watch what happens:

bHtKBbu.pngThere are less triangles rendered (indices/3) and also fewer draw calls in the second image, but the frame time nearly doubled. I am baffled why this happens. The geometry is exactly the same, the exact same rendering setup, same shaders, there is no branching in the shaders that might only happen in the second picture. Its also not depending on the light direction, when i invert the light direction so that the first image in the situation above gets hit by specular light and the second is that dull gray its the same effect. The maps are also generated randomly at each start, so this also can be ruled out.

 

I really wonder what could cause that issue, does anyone of you have an idea what i should start checking? I already did a lot of CPU profiling where i spend a lot of time in either of the two situations and compare the render loop for changes, but so far i havent had any luck. Could it be something on the GPU? Even if everything is pretty much identical?

 

Thanks in advance,

Plerion 

 


Using 2x color modulation in FFP

26 January 2015 - 03:03 PM

Hello guys

 

Im asking this question for a friend of mine. He has an old program thats still using the FFP for rendering in OpenGL. Right now it still all works but there is a new feature hed like to implement. Every vertex has a color value. But its modulated in a different way. In GLSL in the fragment shader it would be like:
 

gl_FragColor = input_color.rgb * 2 * texture_color;

So essentially a color value of 0x7F7F7F7F would just return the texture color whereas 0xFFFFFFFF would double all channels of the texture.

 

The color values are bound to a buffer and sent to the FFP using glColorPointer. In DirectX i remember there was some kind of texture sampler state that allowed to specify MODULATE_2X as color operation. Is there something similar in OpenGL?

 

Greetings

Plerion


Getting invalid instance matrices in vertex shader

24 January 2015 - 06:04 PM

Hello all

 

Im using instancing to draw the opaque parts of of heavily repeated objects. I am running into some problems reading the instance data however.

 

My input structure for the vertex shader is like that:

struct VertexInput
{
	float3 position : POSITION0;
	float4 boneWeights : BLENDWEIGHT0;
	int4 bones : BLENDINDEX0;
	float3 normal : NORMAL0;
	float2 texCoord : TEXCOORD0;
	float2 texCoord2 : TEXCOORD1;

	float4 mat0 : TEXCOORD2;
	float4 mat1 : TEXCOORD3;
	float4 mat2 : TEXCOORD4;
	float4 mat3 : TEXCOORD5;
};

In order to get the position (before view and projection) i do the following:

VertexOutput main(VertexInput input) {
	float4x4 matInstance = float4x4(input.mat0, input.mat1, input.mat2, input.mat3);

	// bone & animation stuff

	position = mul(position, matInstance);
	// ...
}

the animation stuff and the per vertex input data is correct, I modified the last line to be: position = position.xyz + eyePosition + float3(100, 0, 0); and the elements appear correctly in front of my camera.

 

I have checked with the graphics debugger, in my opinion the input data looks correct (im not showing the per vertex stuff, since thats working):

Instance buffer (i checked, its bound):

RhPXaRU.png

 

 

Input Layout:

uYRdd2k.png

 

Im using the DrawIndexedInstanced function.

 

The result is completely wrong however: 

yCLGPj0.png

 

Where should i begin to look at? What could be the reason of this strange behavior?

 

Thanks in advance,

Plerion


Passing cube normals to shader

09 January 2015 - 06:50 PM

Hello all

 

Im using cube rendering. Basically per cube im using 8 vertices and 36 indices as one might expect. The problem im currently facing is passing normals accordingly to the shader. Putting them in the vertex buffer seems impractical since each vertex has 3 independent normals. My first guess was just sending an vec3 array as uniform to the shader and index it gl_VertexID but since that is not an option in WebGL im kinda out of ideas.

 

Is the best way to do so by using 36 vertices or is there a simpler way to accomplish this? Essentially I could use the average normal on each vertex and then the average of the 4 vertices of each face would be correct again. But obviously I can only access the one normal of the vertex. In the fragment shader its the interpolated value but not the average of the 4 vertices of the quad.

 

Thanks for any tips

Cromon


Invalid bone transformations in skinned mesh

11 October 2014 - 09:55 AM

Hello all

 

I am using skinned meshes with hierarchical bones in my application. Strangely i get rather mixed results for different models. The problem right now is that i am not sure if i am reading the values wrong or doing the math wrong. Let me first show you 2 different videos of different models:

 

N°1:

https://www.dropbox.com/s/n6r7wzyfxdw20rl/2014-10-11_17-49-35.mp4?dl=0

 

As you can see it doesnt look that bad, yet there are strange bumps in the animation and the character seems to be moving up and down as well.

 

N°2:

https://www.dropbox.com/s/qgn785i5x7y1jhn/2014-10-11_17-50-59.mp4?dl=0

 

For this nice fella however the animations seem to completely wrong...

 

The main code i am using to calculate my matrices looks like that:

void M2AnimationBone::updateMatrix(uint32 time, uint32 animation, Math::Matrix& matrix, M2Animator* animator) {
	auto position = mTranslation.getValueForTime(animation, time, animator->getAnimationLength());
	auto scaling = mScaling.getValueForTime(animation, time, animator->getAnimationLength());
	auto rotQuat = mRotation.getValueForTime(animation, time, animator->getAnimationLength());

	matrix = mPivot * Math::Matrix::translation(position) * Math::Matrix::rotationQuaternion(rotQuat) * Math::Matrix::scale(scaling) * mInvPivot;

	if (mBone.parentBone >= 0) {
		matrix = matrix * animator->getMatrix(time, mBone.parentBone);
	}
}

With getMatrix like this:

const Math::Matrix& M2Animator::getMatrix(uint32 time, int16 matrix) {
	assert(matrix >= 0 && (uint32) matrix < mBones.size());

	if (mCalculated[matrix]) {
		return mMatrices[matrix];
	}

	auto& mat = mMatrices[matrix];
	mBones[matrix]->updateMatrix(time, mAnimationId, mat, this);
	mCalculated[matrix] = true;

	return mat;
}

Ive been looking through several tutorials and explanations online and found - in my opinion - several different versions of it. Mostly it seems that the whole pivot stuff is a bit different everywhere. Am i doing it the right way?

 

Thanks for any help

Plerion


PARTNERS