Soft Shadow Technique using XNA 3.0 - c#

I am working with XNA 3.0 (sigh, I know) and I am working off a tutorial that helps implement a 3d scene with objects where a spot light hits a torus and projects a hard-edged shadow. Now, I want to know where I can find help (tutorial, source code, snippet) to soften said shadow?

Simplest way would be use Percentage Closer Filtering. Basically it works by taking a few shadow map samples. You can start from an article in GPU Gems.

Related

Drawing Lines in WPF-Forms with crayon-shader?

we have a project at university where we have to create fractals that are controllable by the user (with kinect). We are still in an early phase where we evaluate some ideas (though we already got some working prototypes). Our idea right now is to use a blackboard-image as background and draw the fractals on top of it. To make this look more natural we'd like to use some crayon effects on the lines we draw.
Our internet-research produced two main ideas to achieve this:
Paint an image of a photoshop-like brush for every moueposition of a line.
Use shaders on drawline-functions.
The first does work for an early test, but looks awful. I guess the latter would be the best approach, but the information in the internet seems to be lacking regarding this topic. At least I didn't find anything that really helped a lot. The Questions is:
Has anyone links or general tips on how to achieve this effect, or is it not possible in C#/WPF. Might there be an even better way? And how can I apply a created shader to drawline-method/brushes?
Thanks in advance and kind regards
Michael
EDIT
Nice tip from #Bradley Uffner ! (unfortunately he deleted his answer)
There is a tutorial here on how to achieve such effect :
http://alastaira.wordpress.com/2013/11/01/hand-drawn-shaders-and-creating-tonal-art-maps/
Another thing I've found recently which might interests you :
http://blogs.msdn.com/b/hemipteran/archive/2014/03/26/generating-noise-for-applications.aspx
I've didn't read well the title of your question, Windows Forms do not support shaders at all.
Be more specific about the meaning of a crayon shader
Regarding using shaders in WPF, you cannot apply them at a line-level but on a Control level instead.
This the class representing a shader in WPF:
http://msdn.microsoft.com/en-us/library/system.windows.media.effects.effect(v=vs.110).aspx
What I suggest
use an Image and set its Source property to use a WriteableBitmap
use the excellent WriteableBitmapEx library to easily draw on it, basically it's the WriteableBitmap in WPF but with many extension methods for drawing lines, circles, rectangles etc ...
then apply your shader to the Effect property of Image
For developing your shader
Use Shazzam, it allows you to develop an HLSL shader for WPF in a cool interface, preview it instantly and it will generate the Effect class ready to paste on your project.
There might be a couple of interesting shader for you in DOSBox SVN-Daum
Here's an example of the cartoon shader :
Obviously there will be quite some work as copy-pasting the shader to Shazzam won't work right away but you'll know what are the maths behind achieving the effect.
Mark the answer as accepted if you are satisfied with it :D if not edit your question and add more details.

Using GIFs with XNA

I was looking for a way to use GIFs within XNA when I found this: http://xnagif.codeplex.com/
Can anyone tell me the proper steps in adding and linking this library to my project? I couldn't get it to work when I tried it, and I feel as though I might deleted/overwrite a necessary component to my project.
As I said, spritesheet animation is much easier with spritesheet than gifs and gives you much more flexibility, like storing multiple animations in the same image file.
This nice tutorial will help you get started on spritesheet animation in XNA. It shouldn't take long for you to develop a working animation library with this.
In short, XNA already has a parameter in its Draw method that allows you to draw only a small part of the full image (parameter: source). Using this, you can change the source every X second to make it look like an animated gif. I assure you that it really isn't too complicated and shouldn't be too long to implement (as I have done it myself several times already, always improving my animation engine)

3D scene graph for .NET

Is there any scene graph implementation for Windows Forms in .NET? It doesn't need to be free, but it can't be WPF.
I have to create a part of a bridge and color the stress accordingly. Interactive rotation would be nice, as well as zoom. I think DirectX or OpenGL would be fine.
A custom solution via XNA seems too complicated. I rather want to use a library, which provides higher level objects - optimally a scene graph, minimally triangles and light.
ILNumerics provides a scene graph in 3D. And supports Windows.Forms. Here are some examples.
Edit: It for sure is free: GPL version 3
You can do XNA rendering within Windows Forms it seems:
http://www.google.com/search?q=xna+windows+forms
There's SlimDX which wraps DirectX for .Net. I've gotten samples to work, but I'm new to 3D programming and there isn't much documentation on how to use SlimDX beyond the simplistic tutorials.
Unity3D is a game engine which might meet your needs with a straight-forward installation and 3D modeling import and view. No step-through debugger though, if that matters.
XNA might be a good choice, but I switched to evaluate SlimDX because of some concerning limitations Microsofts forces in networking gamer-services I saw early on. It made me think there would be other limitations that I wouldn't be able to bypass. Also, I was interested in more flexibility in performance and higher-quality realtime effects than I believed that XNA can provide. I'd be interested in others thoughts on whether such fears about XNA are founded. Perhaps they're not an issue for your stress visualization project.

How should I start playing with 3D?

I'm a developer for just about 6 months now, and since I enjoy programming I've started little programs such as encripters, calculators, tools, stuff to play with DropBox (hehe), stuff that play with bitmaps, drawing graphics, and even a program to update the MSN display image according to the artwork of the music you're listening yo on iTunes.
One of my other hobbies is 3d modelling (completely amateur) and I'd like to mix these hobbies together! So I've read a little about it and figured I'd have to have good notions on geometry, math, point spacial position (which I do, from my 3d modelling experience), but I don't know how to use API's for it, so I've 'simulated' simple 3d with a simple program I've made (a spinning cube).
Here are some questions:
1) What would be a nice 3d development tool for a .NET programmer like me?
2) Is there a way of using 3d models made in 3DS Max ? (I intend on modelling characters)
3) What knowledge should I have in order to render it, and move it around ?
4) Which API should I use ?
NOTE: Not a dupe, I'm asking for directions specific for .NET development possibly using 3ds MAX, and there were no questions about it so far
EDIT:
I've got three answers that seem quite nice, so let me specify a little and maybe you can tell me what's the more appropriate tool.
What I'd like to build soon would be like:
portable (click'n'run, no need to install, and (hopefully) no need to send DLL's along)
"3D embedding" in winforms application, like a picturebox you could render in.
Real winforms application-like (having all System api's like IO, Drawing and etc)
The development enviroment would be nice if it:
Had the possibility to import existant 3D models (not a must, but a plus)
Had the ability to create 3d models programatically (a must)
Possibly has a tool for materials and textures (that would be a huge plus)
Is Well known (high availability of tutorials, questions in S.O., forums..)
And it would be really nice if I could use C# all the way :)
I'm going to provide another vote for XNA. The comment that it's too "game centric" is a non-starter - it provides a rendering loop with feedback on how fast everything is running so you can adjust your rendering to try to maintain a specific framerate (if you want). This isn't particularly game-centric as it's something that most 3D applications should worry about. The only thing that's really unusually game-centric about it is that it provides easy access to game controllers. Feel free to ignore that bit if you don't want to use it.
The only downside for you using XNA is your requirement that it be click'n'run, XNA has a redistributable that you have to worry about. Note that Win7 has this installed by default, but Vista and earlier don't.
EDIT:
XNA is made for applications that are strictly 3D. As such it doesn't natively support using typical windowing controls inside of an XNA project. But, there are ways around this...
A few useful links. Embedding XNA in a winform : http://forums.xna.com/forums/p/6471/34180.aspx#34180
WPF controls directly inside an XNA project : http://www.c-sharpcorner.com/UploadFile/iersoy/256/Default.aspx
Personally, I found XNA a little too "Game Centric" for my tastes. I was more interested in design/architecture type uses.
You may find SlimDX more to your liking.
Even though there are great suggestions in this post already(such as SlimDX and XNA), I'd just like to mention OpenTK.
OpenTK is closer to OpenGL than Direct3D, but it might be the best solution for cross-platform 3D .NET applications.
Since you are using C#.Net, the XNA library will be excellent for you. It is free off the Microsoft website and integrates into the VS IDE. A lot of available tutorials around to help get started.
Also, if I remember correctly. to use a 3d model in XNA, simply export the completed model as (.X). It can then be loaded into your work.
I vote you try Blender. www.blender.org
It's free, open source, and has a great community both on forums and IRC. Progress on the app is pushed forward by major community projects every year, some of which are movies and games and have won some awards. It is gaining industry acceptance as a way to model extremely fast.
Downsides: It's not considered as "pro" as Maya or ZBrush, and it has a very different brain about interface. Learning curve can be interesting, depending on how you learn and how much help you receive.
Upsides: It's free, great community, updated regularly, many tutorials and community projects to work on.
Community:
Blender channel on IRC
Blenderartists forums
Previous community Projects:
Elephant's Dream
Big Buck Bunny
My vote goes for Povray. It is a 3d renderer with a c-like syntax language. It doesn't satisfy your .net needs, but if cool non the less for 3d rendering. If you any kind of interactivity XNA is probably your best best. But I'm interested in your finds.
Re: "Has the ability to create 3d models programatically (a must)"
A few pointers:
Polygon Triangulation
(Dr. ?) Jonathan Richard Shewchuk's Triangle library
Dr. Hang Si's TetGen library
Constructive Solid Geometry
GNU Triangulated Surface Library
There are no .NET libraries I am aware of that allow you use the above mentioned libraries/techniques. You will have to use PInvoke or C++/CLI in order to make calls to these libraries from the managed world.

XNA Game Studio 3.1 and Zune HD (How to render a 3D texture/model)

I am wondering if anyone can find a sample or has a sample or knows how to draw a 3D Model on the Zune HD.
It appears Microsoft limited the functionality of XNA for the Zune HD by removing the Model object. Is there a way they suggest replacing this object, or is there something else that can be done to draw Models?
Thanks.
It seems that there isn't really a way to do it at the moment, I know somebody has tried but it didn't work out very well.
The first link takes you to a discussion about why it's not available and the second takes you to the attempt at using 3d objects on the Zune.
Lack of 3d - Zune
3d Attempt
It seems like it's something that might not be available for a while, if at all.

Categories