XNA Game Development Forums
2012/05/21 20:40:13 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1] 2 3 4
  Print  
Author Topic: Tutorial 3 :: More Rendering Complexity - Shaders and Cameras  (Read 17445 times)
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« on: 2006/10/22 20:34:44 »

Talk about the Shader/Camera tutorial here

[Quick Help]
For those who are having problems running the shader, check your card Shader model, if it is not SM 3.0, then change the compile lines in the shader so it compiles to SM 2.0
Code:
technique TransformTexture {
    pass P0 {
        VertexShader = compile vs_2_0 Transform();
        PixelShader  = compile ps_2_0 Texture();
    }
}
« Last Edit: 2007/01/25 17:02:38 by Chr0n1x » Logged
patricker
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #1 on: 2006/11/08 06:31:47 »

I'm having an issue with the Tutorial, tried downloading your copy to see if I could fix my problem but when I build and ran the copy on your site I get the same error:

Error: Both a valid vertex shader and  pixel shader (or valid effect) must be set on the device before draw operations may be performed.

The place it hits this error is: HMTexturedQuad.cs Line 56

myDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);

Any Ideas?

--Peter
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #2 on: 2006/11/08 16:41:58 »

are you not changing it to use pixel shader 2? My default in the shader itself is to use 3. See if that helps
Logged
patricker
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #3 on: 2006/11/08 17:10:10 »

Thanks, that fixed it.

I really do like your tutorials.  I went through them all the way before the update and I'm going back through them again.  I am very much looking forward to the next one.

--Peter
Logged
hoax
Newbie
*
Offline Offline

Posts: 1


View Profile
« Reply #4 on: 2006/11/09 08:19:08 »

I'm think that classical fps spectator mode for camera would be better choice. Try move your mouse by circle trajectory and say me after two seconds, where is ceil, and where is floor Smiley
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #5 on: 2006/11/09 23:18:39 »

I have a solution for this problem that is being added into the next tutorial. This is simply because the mouse pointer only tracks to the edges of the screen (in fullscreen mode) so the movement of the camera has to stop. This is a Beta 2 XNA change and was not apparent in Beta 1. A workaround is simply resetting the mouse position to window center at each update.
Logged
zdave
Newbie
*
Offline Offline

Posts: 2


View Profile
« Reply #6 on: 2006/11/10 03:27:14 »

Another thing you can try is resetting the rotation quaternion on each update, and keeping track of the pitch and yaw angles instead. This eliminates the roll that apparently comes about from successive pitch and yaw rotations. Something like this worked for me:

yaw += mouseDx * 0.01f;
pitch += mouseDy * 0.01f;

camera.Rotation = Quaternion.Identity;
camera.Rotate(Vector3.UnitY, yaw);
camera.Rotate(Vector3.UnitX, pitch);
...

~David
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #7 on: 2006/11/10 03:50:13 »

Using pitch and yaw angles like this brings back the Gimbal Lock problem however, so I don't suggest using it as a permanent solution.

For reference, Gimbal Lock is explained well here:

http://www.gimblelock.com/Biography/gldefinedheader.html
http://en.wikipedia.org/wiki/Gimbal_lock
« Last Edit: 2006/11/10 03:54:31 by mikeschuld » Logged
zdave
Newbie
*
Offline Offline

Posts: 2


View Profile
« Reply #8 on: 2006/11/10 20:57:47 »

OK I understand the problem, but how does it occur if only quaternions are used? I haven't seen it happen yet doing it this way...

What do you suggest is the best way to cancel the rolling effect?
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #9 on: 2006/11/11 03:39:30 »

Gimbal lock can't occur with just quaternions, so if you have seen it at all with just those, then something else must being going wrong somewhere. The best solution I have found for the camera stopping anywhere is just to set the mouse position to somewhere in the middle of the game window so that it always has room to move around not matter where it was last frame.
Logged
Marlun
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #10 on: 2006/11/16 07:27:35 »

I've come as far as trying to run the application to see the textured quad in the center of the screen (just befor adding the camera) but I'm having a problem. I'm getting:

Error loading "Content\Shaders\TransformTexture". File not found.

when running the application. I copied the shader code from your example and added it to a file TransformTexture.fx. I added that file to my Content\Shaders folder. I've added it to "Copy always" and tested different Build Actions but none work.

What can be wrong?

Thanks in advance!
Logged
MicahN
Newbie
*
Offline Offline

Posts: 8


View Profile
« Reply #11 on: 2006/11/16 08:55:11 »


Make sure your "Asset Name" in the properties window of the shader is named the same as in the code.  For example, TransformTexture and not TransformTexture.fx.

Micah
Logged
Marlun
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #12 on: 2006/11/16 11:37:27 »

Hello, yes it is set to the same as what I'm having in my code. What should the Build Action be set to? Content?

Also, the "XNA Framework Content" is set to false, if I set it to true it won't compile.
Logged
Marlun
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #13 on: 2006/11/16 11:55:34 »

I now also found that the program searches for "TransformTexture.xnb" and all I have in that folder is the TransformTexture.fx file, does the content pipeline need to compile it? When I set the XNA Framework Content to true I get an error: UnsuportedType, and if I click it the first word in the .fx file is selected: "float4x4".
« Last Edit: 2006/11/16 11:58:19 by Marlun » Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #14 on: 2006/11/16 18:42:45 »

Here are the settings for the shader file:

Build Action: Content
Content Importer: Effect - XNA Framework
Content Processor: Effect - XNA Framework
Copy to Output Directory: Do Not Copy
XNA Framework Content: True
Logged
Pages: [1] 2 3 4
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Tutorial 4 :: Moving Cameras and a Simple Input Component Tutorial Discussion « 1 2 » mikeschuld 21 8463 Last post 2008/12/11 10:42:13
by mikeschuld
World (Mesh) orientation and cameras Hazy Mind XNA Engine letsrock 4 2000 Last post 2007/03/13 11:09:49
by Robin Sarac
Shaders and rotating models.... General Discussion Nemo Krad 3 2827 Last post 2007/03/03 17:42:12
by Nemo Krad
Depth buffering and order of rendering??? Hazy Mind XNA Engine 5parrowhawk 1 1439 Last post 2007/02/28 08:02:01
by mikeschuld
I can't see anything on tutorial 4 More Rendering, Vertices and Indexes Hazy Mind 3D Engine moonsvista 5 2906 Last post 2007/03/30 14:37:05
by moonsvista
How can I speed up shaders?? General Discussion EclipsE 7 2808 Last post 2007/04/27 00:26:21
by Chr0n1x
Multiple postscreen shaders Hazy Mind XNA Engine EclipsE 2 1671 Last post 2007/04/29 21:50:58
by Chr0n1x
Effectively Rendering Point Sprites General Discussion DaphydTheBard 11 4318 Last post 2007/08/05 11:37:33
by Nemo Krad
Rendering to Background General Discussion inbreed 1 1599 Last post 2007/05/02 00:13:17
by Chr0n1x
Switching shaders. Motion Blur. Shadows. Hazy Mind XNA Engine amartinez1660 0 977 Last post 2007/05/07 00:01:25
by amartinez1660
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.235 seconds with 20 queries.