Welcome Guest Login Register Member List
ExpressionEngine Forums
Advanced Search
Username: Password:
Remember Me? forgot password?
You are here: Forum Home  >  Development Study Group  >  Talk about Game Development  >  Thread
   
 
Shaders
 
Dave Seah
Posted: 18 July 2008 08:56 AM   [ Ignore ]  
Administrator
Avatar
RankRank
Total Posts:  48
Joined  2007-10-28

It's been a few months since I've posted, and the status of the project is "slowly building". I've started a second pass, after a longish hiatus, building up the fundamentals again,this time making them work a little cleaner together.

Our initial pass, designed for quick prototyping so we could really test the motion-tracking camera system, was based entirely on using the BasicEffect fixed function pipeline. We could draw models. We also used SpriteBatch to draw our graphical representations of pieces (called "visuals" in our nomenclature), but these use a different coordinate system than our model space. As a result, everything is kind of a mess. Our physics and collision detection was hacked together out of some rather simplistic assumptions I made about impulses. It worked, mostly, but not reliably in all cases. Still, we were able to test a 80% scale system in a museum space.

The second pass, which I'm doing now, is more carefully achitected, but I'm also now learning more details about how the graphics device draws. It's actually pretty simple at the lowest level: lists of triangles get rendered by the graphics device. You set up various buffers that contain vertex data, and then tell the graphic device to draw it through an Effect. Effects are essentially programs that convert the vertex data into the filled, shaded 3D shapes projected on the screen.

The learning problem: shaders are mysterious black boxes to me, and they are quite varied. BasicEffect, which implements an approximation of the "fixed function pipeline" of older versions of Direct3D, is good enough for drawing textured, lit models, but it doesn't do fancy stuff that we'd like. To do that, you have to get into using custom Effects, which in essence means you need to learn how to write a shader using a language called HLSL (High Level Shading Language). This is a significant jump. Unfortunately, there is no shader source code available for BasicEffect, which would have been WONDERFUL for people learning how to write shaders who started learning the guts of XNA with the built-in Model code.

I found this list of HLSL Shader Resources, which I'm starting to work through. My immediate challenge is just to draw a per-pixel opaque texture map onto a quad, which will complete the implementation of my VSprite3D visual class. This is not supported by BasicEffect. So I'm looking for a good starting bit of code that I can just drop in as-is.

Profile
 
Dave Seah
Posted: 18 July 2008 09:51 AM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRank
Total Posts:  48
Joined  2007-10-28

I think this is the DirectX 9c HLSL documentation for reference.

I read through the Shader Series Introduction on creators.xna.com, and now that I've come to accept certain ideas about "shaders" being programs that transform a certain kind of data, it is starting to settle in. Even the so-called "semantics" are starting to make sense now that I'm starting to get a more intuitive feel for the hardware features of a graphics device that's capable of rendering 3D geometry.

I downloaded the various shader series projects and am now going to look through them. In particular, the per-pixel example and the multi-material/multi-light examples are intriguing. Per-pixel is what I suspect I need to implement my alpha 3D sprites. Multi-material/Multi-lighting is about managing multiple effects, which is something I wasn't sure how to approach in an efficient and easy-to-maintain manner.

Profile
 
Dave Seah
Posted: 18 July 2008 10:01 AM   [ Ignore ]   [ # 2 ]  
Administrator
Avatar
RankRank
Total Posts:  48
Joined  2007-10-28

The first article in the shader series, a word document, covers the very basic aspects of HLSL. For some reason, it is clicking with me today. It seems to take a few months for something radically new to me to sink in and settle.

Profile
 
Dave Seah
Posted: 30 July 2008 05:49 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
RankRank
Total Posts:  48
Joined  2007-10-28

Perhaps the ability to use the alpha information from a diffuse color map is actually in the system, as I see suggested in this post.

Also, this tutorial on recreating basic effect, albeit without any mapping whatsoever, looks useful for understanding the concepts.

I am probably being overly resistant to diving in and really learning what's going on...I'd rather just have something I can plug in so I can get on with developing the system, but I get distracted by wanting to succintly understand the capabilities of the system.

Profile
 
Dave Seah
Posted: 02 August 2008 11:07 PM   [ Ignore ]   [ # 4 ]  
Administrator
Avatar
RankRank
Total Posts:  48
Joined  2007-10-28

Ho ho, the alpha IS working. I had not set the device render states correctly. Yay! Must pay more attention to renderstates.

Profile
 
   
 
 
‹‹ Architecting Pass 1      3D Math ››

Powered By ExpressionEngine
Template Design By Sonnenvogel.com
Select a theme:

ExpressionEngine Discussion Forum - Version 2.1.0 (20080319)
Script Executed in 0.8002 seconds

Atom Feed
RSS 2.0