• 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.
Sign in to follow this  
Followers 0
tcige

what does 'w' mean in shader assembler

21 posts in this topic

it seems to be the fourth component of input register, and D3DDECLTYPE_FLOAT3 sets it to 1

1

Share this post


Link to post
Share on other sites

It's the homogeneous coordinate. I would strongly suggest reading more graphics theory before proceeding.

 

thanks a lot

 

but i do not agree with your opinion, i am using api, not designing api

1

Share this post


Link to post
Share on other sites

but i do not agree with your opinion, i am using api, not designing api

I do not agree with your opinion. Even if you are just using the API, you will have to deal with matrix transformations at some point in your game and you will have to understand what are homogeneous  coordinates to do it right.

 

Even if your API provides a complete math framework, you will have to know how to use it. To know how to use it you will have to learn maths and linear algebra.

Edited by renega_666
2

Share this post


Link to post
Share on other sites

Just to reinforce what renega_666 already said: in the context of any graphics programming (and if you have to touch shaders, you are way in), not knowing about homogeneous coordinates is like taking a job as a driver, then get into the car, point at the steering wheel and ask 'What's that?'. 

2

Share this post


Link to post
Share on other sites

Just to reinforce what renega_666 already said: in the context of any graphics programming (and if you have to touch shaders, you are way in), not knowing about homogeneous coordinates is like taking a job as a driver, then get into the car, point at the steering wheel and ask 'What's that?'. 

 

thanks for the info about 'homogeneous', i only see it in 'D3DFVF_XYZRHW', is there some concrete context 'homogeneous' applies

 

you and renega_666 misunderstand what i mean, for example, i do not know rsa, but i can use it easily with CryptoAPI, of course rsa is important

0

Share this post


Link to post
Share on other sites

you and renega_666 misunderstand what i mean, for example, i do not know rsa, but i can use it easily with CryptoAPI, of course rsa is important

 

Maybe you can get some result from it, encrypt some strings, but to be able to actually write a secure application, you also need to know some crypto theory to use it properly (know when its actually meaningful to use, make your keys secure, use the right algorithms for setting up sessions, verify they work as intended, etc etc)

 

Similarly, you need to know a subset of linear algebra, dealing with transformations and projections, to be able to write and debug 3D graphics code.

2

Share this post


Link to post
Share on other sites

you and renega_666 misunderstand what i mean, for example, i do not know rsa, but i can use it easily with CryptoAPI, of course rsa is important

And here you misunderstand what we mean. Homogeneous coordinates are not some arcane detail of graphics programming - they are central to it and no one can seriously use a graphics API without knowing about them.
1

Share this post


Link to post
Share on other sites

is there some concrete context 'homogeneous' applies

Yes it applies to transforms (translation, projection,...) which are used extensively in every game.

 

If you don't understand homogeneous coordinate how can you understand perspective projection? If you don't understand perspective projection, how do you setup a camera for your 3D game? Of course you can follow a tutorial/manual without understanding what's happening and have a working 3D camera but whenever you will have to debug or adapt the code you'll be lost.

 

Linear algebra is something that every game developer should know!

1

Share this post


Link to post
Share on other sites

I was using GL/D3D for years (and building games/toy-engines with them), just with the knowledge that "'w' is some kind of magic", and that "matricies are some kind of magic" before I got around to learning linear algebra and the theory behind all the computer graphics magic tongue.png

 
...

 

I had some doubts before, but now i know that you are human after all. biggrin.png

Unfortunately i am still in world of magic, but i am striving to learn.

0

Share this post


Link to post
Share on other sites

A person can't use a graphics api if they don't know what homogenous coordinates are??? I guess I should have told myself that before I did this. https://www.youtube.com/watch?v=5XVCXviFNfw I feel I should point out that I've built this from scratch without using any pre-made game engine and I've got it working on both Windows and iOS, so far, and I don't have a clue what homogenous means, not even when talking about milk.

1

Share this post


Link to post
Share on other sites

Yes, if you only scale the w component and not the x, y and z components.

 

(EDIT: HULK SPEAK IN CAPITAL LETTERS ONLY TOO!)

Edited by Paradigm Shifter
0

Share this post


Link to post
Share on other sites

For the longest time I was content to think that 'w' was just added to vector processors to fill in the extra value in the set of four to match the four values neccessary for color. From all this I've gathered that 'w' is neccessary to make the perspective matrix work. So if I were to carry this logic further I would surmise that 'w' is scaled down by the projection matrix math for vertices that are further back and scaled up for objects that are closer to give the illusion of depth. Thus we have perspective on the matter!

0

Share this post


Link to post
Share on other sites

For the longest time I was content to think that 'w' was just added to vector processors to fill in the extra value in the set of four to match the four values neccessary for color. From all this I've gathered that 'w' is neccessary to make the perspective matrix work. So if I were to carry this logic further I would surmise that 'w' is scaled down by the projection matrix math for vertices that are further back and scaled up for objects that are closer to give the illusion of depth. Thus we have perspective on the matter!

It's actually more general than this. Homogenous coordinates are used for transformations done by matrix multiplication. For example even simple translation would not be possible with just x,y,z vectors and a 3x3 matrix.

 

Btw, to the discussion - IMHO you really don't need to understand homogenous coordinates to be able to work with 3D graphics. You can be fine for a looooong time with just remembering that direction vectors have w = 0 and points have w = 1. That's what you'll eventually may need to code manually in a shader or something, when you have just a x,y,z vector and want to make matrix transformations with it.

But of course it's always better if you do understand it.

Edited by Tom KQT
1

Share this post


Link to post
Share on other sites

Out of all of the conjecture and philosophical discussion (which is also important...) nobody answered the original question from the OP.  He wants to know why his w value is initialized to 1 when he only has a XYZ format for his vertex information.  Its been really long since I worked with D3D9, so I couldn't say off the top of my head why that is.  Can you describe how you managed to determine that the value is 1?

 

Regarding the debate, I can also confirm that I ran for a long time without really understanding what w really was doing.  However, I agree with JTippets that the steering wheel analogy doesn't quite fit.  Without knowing w, but still knowing how to use matrix functions roughly, you can get a bunch of work done.  It is like being able to drive without understanding how an engine works.  Sooner or later, when your engine breaks down, you better know the ins and outs of how it should work, or you won't have any chance to fix it.  But until then, you can drive pretty far.

1

Share this post


Link to post
Share on other sites

Out of all of the conjecture and philosophical discussion (which is also important...) nobody answered the original question from the OP.  He wants to know why his w value is initialized to 1 when he only has a XYZ format for his vertex information.  Its been really long since I worked with D3D9, so I couldn't say off the top of my head why that is.  Can you describe how you managed to determine that the value is 1?

The original question isn't really very clear.

I would guess that it may be about this: If you have a vertex declaration entry for vertex position (D3DDECLUSAGE_POSITION) with the type D3DDECLTYPE_FLOAT3 and your vertex shader input parameter for position is float4, then w is automatically filled with w = 1, because that's what points need. I don't know whether for normal it would put 0 there, but I guess it would.

Anyway, I personaly have always been consistent in this and with D3DDECLTYPE_FLOAT3 I use float3 in shaders. And I add w manually.

Edited by Tom KQT
1

Share this post


Link to post
Share on other sites

 

Out of all of the conjecture and philosophical discussion (which is also important...) nobody answered the original question from the OP.  He wants to know why his w value is initialized to 1 when he only has a XYZ format for his vertex information.  Its been really long since I worked with D3D9, so I couldn't say off the top of my head why that is.  Can you describe how you managed to determine that the value is 1?

The original question isn't really very clear.

I would guess that it may be about this: If you have a vertex declaration entry for vertex position (D3DDECLUSAGE_POSITION) with the type D3DDECLTYPE_FLOAT3 and your vertex shader input parameter for position is float4, then w is automatically filled with w = 1, because that's what points need. I don't know whether for normal it would put 0 there, but I guess it would.

Anyway, I personaly have always been consistent in this and with D3DDECLTYPE_FLOAT3 I use float3 in shaders. And I add w manually.

 

 

That seems like prudent advice - can the original poster chime in about that?  Are you using all four components of a vector without initializing them?  It could be that since he is using an assembly shader, that the full register is initialized regardless of if he declares 3 or 4 components.

0

Share this post


Link to post
Share on other sites

Its just me who thinks wikipedia entries on any math subject are terrible? I never learned anything about math on wikipedia, but I did learned a trick: try searching on really early versions of the entry, before some calculus freak made his version full of weird notations and explanations nobody really cares, helps a lot, since early version focus on things ppl are actually more concerned, instead of those versions full of history and names.

1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0