Jump to content

  • Log In with Google      Sign In   
  • Create Account


derKai

Member Since 04 Sep 2011
Offline Last Active Mar 04 2014 10:18 AM
-----

#5106674 Duplicating vertices so the count is equal to UV Coordinates

Posted by derKai on 03 November 2013 - 07:36 AM

OK, here is the counts for a single mesh:

 

number of positions: 342

number of uv coords: 1884

number of faces: 628

 

okay.. here you see the number of uv coords is 3 times the number of faces.. this is very typical for textured models..

i've never seen separete index lists per semantic. i guess all your index lists are of the same size (3 * 628)

if thats so you may allocate your vertexbuffer (or buffers if you don't want interleaved vertexbuffers), iterate over the index lists and fill your buffer with the data at the given indices:

positionBuffer[faceCount*3]
tecCoordsBuffer[faceCount*3]

for(int i=0; i<faceCount*3; i++)
{
    positionBuffer[i] = positionData[positionIndices[i]];
    texCoordBuffer[i] = texCoordData[texCoordIndices[i]];
}

this will flatten you buffers (you don't need the indexbuffer for drawing)

for a interleaved buffer you will create a struct containing fields for position and texcoords and an array of these structs in a similar way




#5105024 Shader Branching Costs for "constant" Conditions

Posted by derKai on 28 October 2013 - 06:45 AM

Hey,

im wondering if there is a specified behavior for branches in shader code if the condition is not really dynamic.

While searching the forum i found some hints that dynamic branching is not possible if some functions like Sample(...) are used. What if the condition is a value defined in the constant buffer? In this case all threads are following the same path and evaluating both paths is theoretically not requiered. Is this depending on the compiler and driver or are there any specified  and documented rules?

 

with shader i mean sharder in general rendering pipeline and compute shader or cuda.

 

Thanks

- Kai




#4976819 Quaternion x,y,z rotation

Posted by derKai on 05 September 2012 - 08:00 AM

okay..i think you've got a math problem ;)
you need to know that matrix operations (and quaternion rotations) are not commutative!
the order in which you rotate your model matters! rotX * rotY != rotY * rotX
this means it's not enough to store the 3 angles (not even 3 quaternions for each axis, what is practically the same as a single quaternion with all 3 rotations, too)
your problem is, that the order you need the rotations multiplied together depends on you mental intention how it should behave..

what you can do is keep track of your axis:
save x y z as vector (initialized at startup)
if you want to rotate around one axis, say Y, create an quaternion "form axis rotation" and pass the current saved y axis and the desired angle
use this quaternion to transform all three axis
create your rotation with the current axis as basis.. this can be done e.g. by via Matrix.LookAt (eye = zero, lookat = forwardAxis, up = upAxis)
maybe you need to transpose this afterwards.. (try it)


#4976791 Quaternion x,y,z rotation

Posted by derKai on 05 September 2012 - 06:33 AM

This is because the rotations are executed one after each other..
if you apply a rotation, lets say 45° around the Y axis, your local (object space) x and z axis are rotated 45°, too.
if you then apply another rotation, lets say around the X axis, you rotate around a "neutral" axis, not the 45° rotated one.
for the next transformation this is same as well..

what rotation are you expecting?

maybe your give vector is not meant to use this way.
did you wrote the GameActor class or is it part of a library?


PARTNERS