• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

dxCUDA

Members
  • Content count

    21
  • Joined

  • Last visited

Community Reputation

141 Neutral

About dxCUDA

  • Rank
    Member
  1. Ok, So I think I have fixed every issue under the sun relating to all my previous issues. One issue remains however, there is a very stark contrast between a lit area and the falloff with the lighting. I've been heavily experimenting and nothing I do seems to have an impact. As I move in the scene the dark area moves towards me and I cannot illuminate this area with the spotlight. [img]http://i50.tinypic.com/34gt6yr.png[/img] Thanks
  2. Progress, but now the world is black, I was setting [CODE] m_LightVec[lightNum]->pLightVar = pBasicEffect->GetVariableByName( "pLight" ); m_LightVec[lightNum]->pLightVar->SetRawValue(&m_LightVec[lightNum]->pointLight, 0, sizeof(pointLight)); [/CODE] to: [CODE] m_LightVec[lightNum]->pLightVar = pBasicEffect->GetVariableByName( "pLight" ); m_LightVec[lightNum]->pLightVar->SetRawValue(&m_LightVec[lightNum]->directionalLight, 0, sizeof(DirectionalLight)); [/CODE] Now I am sure the issue is in my shader to do with the position of the light. I was generating the image above when I by accident, used the directional light pos(dir). [CODE] else if (pLightType == 1) { lightIntensity = saturate(dot(bumpNormal, +pLight.pos)); // Determine the final diffuse color based on the diffuse color and the amount of light intensity. color = saturate(material.Kd * lightIntensity); // The vector from the surface to the light. float3 lightVec = pLight.pos - input.p; // The distance from surface to light. float d = length(lightVec); //if( d > pLight.range ) //return float4(0.0f, 0.0f, 0.0f, 0.0f); // Normalize the light vector. lightVec /= d; //color = color / dot(pLight.att, float3(1.0f, d, d*d)) * textureColor; color = color * textureColor; specularPower1 = 5.0f;//Need to make this modifiable outside of the shader if(lightIntensity > 0.0f) { //Calculate the reflection vector based on the light intensity, normal vector and light direction reflection = normalize(2 * lightIntensity * bumpNormal +pLight.pos); // Determine the amount of specular light based on the reflection vector, viewing direction, and specular power. specular = pow(saturate(dot(reflection, lightVec)), specularPower1); // Use the specular map to determine the intensity of specular light at this pixel. specular = specular * specularIntensity; // Add the specular component last to the output color. color = saturate(color + specular); } //calculate lighting I = calcBlinnPhongLighting( material, pLight.color, input.n, -pLight.pos, input.h ); [/CODE] I am still receiving the per-object light error as before still however!
  3. Another day, another issue. Currently I am rendering a red point light in the world, but seemingly one point light is being applied independently for each object. Obviously I want one point light in the world to effect all objects (objects to share the same lighting). This issue was also apparent with my directional light. I think it might be an issue either in my shader transforming into clip space and maybe then I need to do a new transformation [CODE] input.p = mul( input.p, World ); output.p = mul( input.p, View ); output.p = mul( output.p, Projection ); [/CODE] Or the issue is in my baseObject render method, whereby I am rendering something per-object as opposed to globally, or there is a transformation I am missing to incorporate at this level [CODE] void dxBaseModel::render() { D3DXMatrixIdentity(&posMatrix); D3DXMatrixIdentity(&rotMatrix); D3DXMatrixIdentity(&meshWorld); D3DXMatrixRotationYawPitchRoll(&rotMatrix, rotation.y, rotation.x, rotation.z); D3DXMatrixTranslation(&posMatrix, position.x, position.y, position.z); D3DXMatrixMultiply(&meshWorld, &rotMatrix, &posMatrix); pViewMatrixEffectVariable->SetMatrix(viewMatrix); pProjectionMatrixEffectVariable->SetMatrix(projectionMatrix); myTexture.pTextureSR->SetResource( myTexture.textureSRV[0] ); myTexture.pBumSR->SetResource(myTexture.textureSRV[1]); myTexture.pSpecSR->SetResource(myTexture.textureSRV[2]); D3D10_TECHNIQUE_DESC TechDesc; pBasicTechnique->GetDesc(&TechDesc); for( UINT p = 0; p < TechDesc.Passes; p++ ) { WVP = meshWorld*viewMatrix*projectionMatrix; pWVPMatrixEffectVariable->SetMatrix((float*)&WVP); pWorldMatrixEffectVariable->SetMatrix((float*)&meshWorld); pBasicTechnique->GetPassByIndex( p )->Apply( 0 ); pMesh->DrawSubset(0); } } [/CODE] Here's an image of the scene to illustrate the issue at hand. Thanks [IMG]http://i47.tinypic.com/izlu2q.png[/IMG]
  4. OpenGL

    It works now, thanks for the help, even though the triangle is a little bit weird. Here's the code for any future searches: [CODE] include gl.inc include glu.inc .data _neg15 dd -1.5f ; _neg6 dd -6.0f _pos1 dd 1.0f _neg1 dd -1.0f _20 dd 20.0f .code ASMrender proc sub rsp, 32h mov ecx, GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT call glClear add rsp, 32h call glLoadIdentity sub rsp, 32h movss xmm2, dword ptr [_neg15] xorps xmm1,xmm1 movss xmm0, dword ptr [_neg1] call glTranslatef add rsp, 32h sub rsp, 32h mov ecx, GL_TRIANGLES call glBegin add rsp, 32h sub rsp, 32h xorps xmm2,xmm2 movss xmm1, dword ptr [_pos1] xorps xmm0,xmm0 call glVertex3f add rsp, 32h sub rsp, 32h movss xmm2, dword ptr [_neg1] movss xmm1, dword ptr [_neg1] xorps xmm0,xmm0 call glVertex3f add rsp, 32h sub rsp, 32h movss xmm2, dword ptr [_pos1] movss xmm1, dword ptr [_neg1] xorps xmm0,xmm0 call glVertex3f add rsp, 32h call glEnd ret ASMrender endp end [/CODE]
  5. OpenGL

    Thanks Mozeiko That's a good direction to take after this learning exercise. I didn't quite understand from the other post initially about the SEE2 registers, but I do now and it works.. Would asm be viable in a runtime situation whereby we have an if -else statement, we could then do this in asm and avoid the doubled call each frame, as it would remove half the calling?. I could see it being better than C++ in such a situation, or would I still be wrong?
  6. OpenGL

    Well I check the value of _m15 which equated to 0BFC00000h so I created _neg15 dd -1.5f to be more clear on the value and this was also 0BFC00000h . I'm entirely certain that everything is working accordingly, as if I just chose to contain glClear and glLoadIdentity within the asm function, in conjunction with triangle drawing C++ side, and it works. So it must be incorrect data parsed in asm to the gl procedures.
  7. OpenGL

    Cheers for that, Still doesn't seem to be working. All I get is a black screen. I have a feeling it might be the data from _m1, _m15 etc. I'll keep digging
  8. OpenGL

    Thanks Rufelt, I realize this is a somewhat pointless effort in terms of optimizations and yadda yadda. I'd rather just learn how asm works and once I am familiar, in the future I can focus on some decent optimizations with SSE(or so I've heard) So the asm now looks something like this, however the screen is black, no white triangle: [CODE] sub rsp, 32h mov ecx, GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT call glClear add rsp, 32h call glLoadIdentity sub rsp, 20h mov rdx, _m15 mov rcx, 0 mov r8d, _m6 call glTranslatef add rsp, 20h sub rsp, 18h mov edx, GL_TRIANGLES call glBegin add rsp, 18h sub rsp, 20h mov edx, 0 mov ecx, _1 mov r8d, 0 call glVertex3f add rsp, 20h sub rsp, 20h mov edx, _m1 mov ecx, _m1 mov r8d, 0 call glVertex3f add rsp, 20h sub rsp, 20h mov edx, _1 mov ecx, _m1 mov r8d, 0 call glVertex3f add rsp, 20h call glEnd ret [/CODE]
  9. Experimenting with learning x64 asm and how code operates on a low level, and trying to work out where speed is increased in projects when ASM is appropriately used. My project is x64 with MASM in visual studio 2010 Currently I am trying to replace the basic glClear glLoadIdentity etc with asm to understand how to interface between code and asm. I'm following the asm examples over at NEHE, but I constantly keep getting an access violation error when I seem to introduce 'push' into the code. This is the code asm-side: [CODE] include gl.inc include glu.inc .data _45d0 equ 40468000h ;45.0 _45d1 equ 0 _01d0 equ 1069128089 _01d1 equ -1717986918 ;0.1 _100d0 equ 1079574528 _100d1 equ 0 ;100.0 _1d0 equ 1072693248 _1d1 equ 0 ;1.0 _05 equ 1056964608 ; 0.5 _1 equ 1065353216 ; 1.0 _m1 equ -1082130432 ;-1.0 _3 equ 1077936128 ; 3.0 _m15 equ -1077936128 ;-1.5 _m6 equ -1061158912 ;-6.0 .code ASMrender proc display: push GL_COLOR_BUFFER_BIT call glClear call glLoadIdentity call glEnd push _m15 push 0 push _m6 call glTranslatef xor eax,eax ret ASMrender endp end [/CODE] Over in C++ I am just doing the standard 'extern "C" void ASMrender and then calling ASMrender() in the main render loop. Here's a screenshot of some of the action where it all goes wrong. [img]http://i45.tinypic.com/2db1fll.png[/img]
  10. [quote name='Nyxenon' timestamp='1337489291' post='4941580'] I always have yaw, pitch, and roll variables, then every frame I update them with the controller or whatever, then I create a quaternion using those variables, then I transform the "backward" vector with that quaternion. Make the camera position that vector (multiply it by whatever distance you want it to be from the player), add the player position to that vector, then set the target to the character position. It's really not hard to do, and I would provide some sample code, but I'm a little lazy right now [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] Aww, hell, here's some pseudo-code: [code] float yaw, pitch, roll;//Some variables that will be in your camera class or wherever you want them //You could also just use a quaternion rather than those variables, then just multiply the quaternions. //I feel it's a little better to use yaw, pitch, and roll since you can keep track of your camera's rotations a little better (doesn't really matter if it's a free camera anyway) //I really don't know which is which with yaw pitch roll, but only two are important (I think yaw and pitch, yaw being up/down, pitch being rotation?) //Anyway, doesn't matter. Just find out which is which, add to them using input from a controller/keyboard, then create your quaternion Quaternion rotator = Quaternion.FromYawPitchRoll(yaw,pitch,roll); float camDistance = 5.0f; vector3 back = Vector3.Backward; back = Vector3.Transform(back, rotator);//Rotate our vector rotator *= distance;//Push it out a distance from the player) rotator += playerPosition;//Add the position View = Matrix.CreateLookAt(back, playerPosition, upVector); [/code] [/quote] Thanks for this, really helpful. I have managed to create an orbit and FPS camera, but there is room for improvement, I will factor in this concept. I solved my problems however, and I created my FPS camera with head bobbing. This is the final code: [CODE] bool dxCamera::keyHeldA; bool dxCamera::keyHeldS; bool dxCamera::keyHeldW; bool dxCamera::keyHeldD; void dxCamera::perspectiveCamera(D3DXMATRIX &in_projectionMatrix, D3D10_VIEWPORT &in_viewPort, D3DXMATRIX &in_worldMatrix, D3DXMATRIX &in_viewMatrix) { float yaw, pitch, roll; D3DXMATRIX yawMatrix; D3DXMATRIX pitchMatrix; D3DXMATRIX rollMatrix; D3DXMATRIX upLocal; D3DXVECTOR3 Direction; D3DXMATRIX directionMatrix; // Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians. rotation.x = m_rotationX * 0.0174532925f; rotation.y = m_rotationY * 0.0174532925f; rotation.z = m_rotationZ * 0.0174532925f; //rotation.x = pitch; //rotation.y = yaw; //rotation.z = roll; up = D3DXVECTOR3(0.0f, 1.0f, 0.0f);//Create the up vector right = D3DXVECTOR3(1.0f, 0.0f, 0.0f); lookat = D3DXVECTOR3(0.0f, 0.0f, 1.0f); //D3DXVECTOR3 inputMoveVec[2] = {position, rotation}; // Setup matrices to rotate around axes D3DXMatrixRotationAxis(&yawMatrix, &up, rotation.y); D3DXMatrixRotationAxis(&pitchMatrix, &right, rotation.x); //move lookat vector D3DXVec3TransformCoord(&lookat, &lookat, &pitchMatrix); D3DXVec3TransformCoord(&lookat, &lookat, &yawMatrix); D3DXVec3Normalize(&lookat, &lookat); //Get the direction vector from camera to target, normalise it. //D3DXVec3Normalize(&Direction, &(lookat - right)); //Get the UP vector (in the world) and determine the cross product, to give us our right (left) hand vector. D3DXVec3Cross(&right, &up, &lookat); D3DXVec3Normalize(&right, &right); //Cross product the right vector and direction vector, to determine up relative to the camera. D3DXVec3Cross(&up, &lookat, &right); //Useful for generation of direction looking at for future cameras direction = atan2((double)lookat.z, (double)lookat.x); velocity.x = (sin(direction)); velocity.y = 30.0f; velocity.z = (cos(direction )); D3DXMatrixIdentity(&in_viewMatrix); in_viewMatrix._11 = right.x; in_viewMatrix._21 = right.y; in_viewMatrix._31 = right.z; in_viewMatrix._12 = up.x; in_viewMatrix._22 = up.y; in_viewMatrix._32 = up.z; in_viewMatrix._13 = lookat.x; in_viewMatrix._23 = lookat.y; in_viewMatrix._33 = lookat.z; in_viewMatrix._41 = -D3DXVec3Dot(&(position), &right); in_viewMatrix._42 = -D3DXVec3Dot(&(position), &up); in_viewMatrix._43 = -D3DXVec3Dot(&(position), &lookat); D3DXMatrixPerspectiveFovLH(&in_projectionMatrix, (float)D3DX_PI * 0.5f, (float)in_viewPort.Width/(float)in_viewPort.Height, 0.1f, 5000.0f); } void dxCamera::initialiseFPSCamera(float in_headHeight, float in_bobPeriod, float in_bobScale) { bobPeriod = in_bobPeriod; bobScale = in_bobScale; headHeight = in_headHeight; } void dxCamera::walk(float speed, float sin) { bob = headHeight + sinf(sin * bobPeriod) * bobScale; if(keyHeldW == true) { position.x += lookat.x * speed; position.y = bob; position.z += lookat.z * speed; } if(keyHeldS == true) { position.x -= lookat.x * speed; position.y = bob; position.z -= lookat.z * speed; } keyHeldW = false; keyHeldS = false; } void dxCamera::strafe(float speed) { if(keyHeldA == true) { position -= right * speed; } if(keyHeldD == true) { position += right * speed; } keyHeldA = false; keyHeldD = false; } void dxCamera::translateCamera(float &in_CameraX, float in_CameraY, float in_CameraZ) { position.x = in_CameraX; position.y = in_CameraY; position.z = in_CameraZ; } void dxCamera::rotateCamera(float &in_rotationX, float & in_rotationY, float &in_rotationZ) { m_rotationX = in_rotationX; m_rotationY = in_rotationY; m_rotationZ = in_rotationZ; } [/CODE]
  11. I think I am going to go back to calculating the bitangent and tangent in the main code, rather than the shader. The main motivation for me to accomplish what I wanted, was to try and do all my calculations within the shader, but I realise it not possible. So I will do it how I used to and apply this: tangent[a].w = (Dot(Cross(n, t), tan2[a]) < [color=purple][font=CourierNew]0[/font][/color].0F) ? -[color=purple][font=CourierNew]1[/font][/color].0F : [color=purple][font=CourierNew]1[/font][/color].0F; to fix this problem I used to have, whereby the tangent would be overlapping, I believe: [img]http://s16.postimage.org/45qxsrs1x/image.png[/img]
  12. Thank you for your reply, this concept has helped me gain a better understanding of the process and technical specifics such as this. I'll work this into my shader, hopefully this resolves the issue.
  13. Update: So I was aware that I needed to create a direction from the position and rotation, but unsure of the method. Here is the progress I have made with that: [CODE] direction = atan2((double)rotation.x, (double)position.x); velocity.x = (sin(direction) * 5.0f); velocity.z = (cos(direction ) * 5.0f); [/CODE] And then I apply the velocity to the right vector as such: [CODE] in_viewMatrix._41 = -D3DXVec3Dot(&(position + velocity), &right); [/CODE] So the final result I am trying to accomplish is create a new position based off of the rotation. It however doesn't accomplish this.
  14. Thanks for the reply! I'm trying to implement an FPS-style camera. I am able to move on a set axis, and rotate about the local camera origin, but I cannot update the movement direction in relation to the camera facing angle. So what I want to achieve, is look in a direction and translate in that direction. Here is my revised code I've been working on. [CODE] float yaw, pitch, roll; //D3DXMATRIX rotationMatrix; D3DXMATRIX yawMatrix; D3DXMATRIX pitchMatrix; D3DXMATRIX rollMatrix; D3DXMATRIX upLocal; D3DXVECTOR3 Direction; // Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians. pitch = m_rotationX * 0.0174532925f; yaw = m_rotationY * 0.0174532925f; roll = m_rotationZ * 0.0174532925f; position.x = m_fCameraX; position.y = m_fCameraY; position.z = m_fCameraZ; up = D3DXVECTOR3(0.0f, 1.0f, 0.0f);//Create the up vector right = D3DXVECTOR3(1.0f, 0.0f, 0.0f); lookat = D3DXVECTOR3(0.0f, 0.0f, 1.0f); rotation = D3DXVECTOR3(m_rotationX, m_rotationY, m_rotationZ); // Setup matrices to rotate around axes D3DXMatrixRotationAxis(&yawMatrix, &up, yaw); D3DXMatrixRotationAxis(&pitchMatrix, &right, pitch); //D3DXMatrixRotationAxis(&rollMatrix, &lookat, roll); //move lookat vector D3DXVec3TransformCoord(&lookat, &lookat, &pitchMatrix); D3DXVec3TransformCoord(&lookat, &lookat, &yawMatrix); D3DXVec3Normalize(&lookat, &lookat); //Get the direction vector from camera to target, normalise it. D3DXVec3Normalize(&Direction, &(lookat - right)); //Get the UP vector (in the world) and determine the cross product, to give us our right (left) hand vector. D3DXVec3Cross(&right, &up, &lookat); D3DXVec3Normalize(&right, &right); //Cross product the right vector and direction vector, to determine up relative to the camera. D3DXVec3Cross(&up, &lookat, &right);//Should be direction instead of lookat //lookat = Direction + right;//Avoid gimble locking D3DXMatrixIdentity(&in_viewMatrix); in_viewMatrix._11 = right.x; in_viewMatrix._21 = right.y; in_viewMatrix._31 = right.z; in_viewMatrix._12 = up.x; in_viewMatrix._22 = up.y; in_viewMatrix._32 = up.z; in_viewMatrix._13 = lookat.x; in_viewMatrix._23 =lookat.y; in_viewMatrix._33 = lookat.z; in_viewMatrix._41 = -D3DXVec3Dot(&position, &right); in_viewMatrix._42 = -D3DXVec3Dot(&position, &up); in_viewMatrix._43 = -D3DXVec3Dot(&position, &lookat); [/CODE]
  15. I can't quite figure out current how to Transform the lookAt and up vector by the rotation matrix so the view is rotated about the player origin. Cheers [CODE] up.x = 0.0f; up.y = 1.0f; up.z = 0.0f; // Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians. pitch = m_rotationX * 0.0174532925f; yaw = m_rotationY * 0.0174532925f; roll = m_rotationZ * 0.0174532925f; D3DXVECTOR3 rotation = D3DXVECTOR3(m_rotationX, m_rotationY, m_rotationZ); D3DXVECTOR3 camera[3] = { D3DXVECTOR3(m_fCameraX, m_fCameraY, m_fCameraZ),//Eye D3DXVECTOR3(m_fLookatX, m_fLookatY, m_fLookatZ),//LookAt up };//Up // Create the rotation matrix from the yaw, pitch, and roll values. D3DXMatrixRotationYawPitchRoll(&rotationMatrix, yaw, pitch, roll); //Translate in the direction of player rotation D3DXVec3TransformCoord(&camera[0], &camera[0], &rotationMatrix); // Transform the lookAt and up vector by the rotation matrix so the view is correctly rotated at the origin. D3DXVec3TransformCoord(&camera[1], &camera[1], &rotationMatrix); D3DXVec3TransformCoord(&camera[2], &camera[2], &rotationMatrix); camera[1] = camera[0] + camera[1]; D3DXMatrixLookAtLH(&in_viewMatrix, &camera[0], &camera[1], &camera[2]); [/CODE]