# Tybon

Member

74

194 Neutral

• Rank
Member
1. ## Bullet Holes

You can take a look at my tutorial. It uses D3D9 and HLSL shaders. It may not be the best way but it's pretty simple if you know D3D9 and HLSL, so your mileage may vary.
2. ## getting transformation matrix

The normal/look vector corresponds to r31, r32, r33. You will need more information about the face to calculate the up(r21, r22, r23) and right(r11, r21, r31) vectors. If you know which vertex corresponds to which corner of quad, then it should be easy. For example, suppose vertex A is the top left corner and vertex B is the top right corner, the B-A will give you the right vector.
3. ## getting transformation matrix

If you know the winding order of the face then it should be possible. The center of the face would be the position. The normal of the face would be the look vector. The first 2 vertices in the winding order can be used as the up or right vector(which can be determined if you also have the texture coordinates of the vertices). Take the cross product obtain the last missing vector, then you should have the 4x4 matrix.
4. ## [Solved] Projected Texture Trouble

Hi, I have a room made of 6 quads. When I paint a decal by projecting a texture onto one of the walls, the wall opposite to that will also get painted by the decal, but upside down. I need to know how to get rid of the upside down texture on the opposite wall. Do I need to test if each vertex is behind the origin of the projection and zero out those texture coordinates? [Edited by - Tybon on April 8, 2005 7:57:43 AM]
5. ## Retrieving a float value from a heightmap...

It's hard to tell unless I know how you calculate the position of your terrain vertices. But if the quad you are in looks like this: h0--h1 | / | | / | h2--h3 then the height should be: if(t < 1-s) h = h0 + s*(h1-h0) + t*(h2-h0); else h = h3 + (1-s)*(h2-h3) + (1-t)*(h1-h3);
6. ## Looking For Spotlight Shader Tutorial

I took the screenshots again at the exact same spot to get a better comparison. As you can see from above, the projected lightmap "wraps" around the lit surface (notice the left side of the projected circle is warped due to a shift in the height of the surface). The per-vertex (and I assume the per-pixel as well) light is calculated at real-time and models real light more accurately IMO. Is my projected lightmap flawed?
7. ## Looking For Spotlight Shader Tutorial

Ok, after going through a few articles on shadow maps, I got the projected spotlight texture working: This is the per-vertex spotlight with penumbra: Ideally, if I had PS 2.0, I would do per-pixel spotlight, because I think looks more realistic than the projected texture. But since I only got PS 1.3, I guess I have to stick with projected texture. Now I need to go figure out how to add in a falloff distance and attenuation to the projected texture...
8. ## Looking For Spotlight Shader Tutorial

Quote:Original post by superpig Usually, your surfaces have got two parts to them - lighting (either in the form of lightmap textures, or vertex lighting), and the actual surface texture. You multiply the two together to produce the final result, allowing your standard texture set to be used in different lighting conditions. To do this projective texturing, you'd project a circle onto the geometry, and add it to the value taken from the lightmap/vertlighting before multiplying by the texture. If you're using lightmaps: ps_1_1 tex t0 ; lightmap tex t1 ; flashlight texture, with texture coordinates done projectively tex t2 ; actual surface texture add r0, t0, t1 ; calculate total lighting at this point - environment light + flashlight mul r0, r0, r2 ; multiply by texture color Nice and simple. It gives you a lot of control over the appearance of your flashlight, too - if you want to add dark spots or cracks to simulate a dirty lens, you can easily do that just by messing with the texture a bit. Thanks for the reply. I'm kind of a newb and the part I don't understand is "with texture coordinates done projectively". Currently I use a heightmap for my terrain, and I calculate the vertex lighting in the VS, I pass that value to the PS and it is multipled by the surface texture to get the final color. I don't know how to blend in a flashlight texture. I mean if I do it like the surface texture then there will just be a whole bunch of flashlight circles tiled over the terrain. Please help me with the texture coordinates for the flashlight...
9. ## Looking For Spotlight Shader Tutorial

Quote:Original post by superpig Meh, if all you're looking at is a flashlight for the player, a projected texture should sort you out. That's how games like Half-Life do it. I'm not sure how that works... I am also working with PS 1.3 and I can't use texture coordinates directly. I'm to go play half life 2 for a while and observe the way it's flash light works, and maybe I'll come out with something...
10. ## Looking For Spotlight Shader Tutorial

I got the spotlight working in the vertex shader. The problem now is that per-vertex lighting doesn't look very good when the lit surface is close to the view, as you can see from the screenshot below the edge of the cone is jagged and not round. I guess this is where per-pixel lighting can fix the problem, but I'm not sure how to do it...
11. ## Looking For Spotlight Shader Tutorial

I am looking for a tutorial on how to implement spotlight using programmable shaders. I need to know how to calculate per-vertex lighting in the VS given a spotlight's parameters (origin, falloff, etc.), which is then passed to the PS for per-pixel lighting. Can anyone please point me to a link or post some code samples? Thanks a lot.

Quote:Original post by bakery2k1 Quote:Original post by ZedFx There we go, not too hard to work that one out was it, now onto the real dodgy problem: Quote:first[array] array[first] == *(array + first) == *(first + array) == first[array] This works for 2D arrays too: array[row][col] == row[array][col] == col[row[array]]
13. ## My 2nd Game!

Added collision detect with the trees so you can't walk through them anymore :) The screen gets a red tint over it for a short instance when you are damaged. Also made the code a little more cleaner and readable. You should be able to see the overall structure of the game just by looking at Game.cpp alone. That's pretty much all I wanted to do with this little demo. I can now move on to my next project :) Thanks for all feedbacks. [Edited by - Tybon on February 24, 2005 7:33:23 PM]
14. ## My 2nd Game!

Quote:Original post by kaysik nice work! 3 things: 1 - any way to invert the mouse? Having it that ways is giving me a headacke and I keep shotting the ground :D 2 - I i hold down starfe then let go I keep strafing for ages (like 2 seconds) which is annoying when trying to dodge rockets 3 - If you strafe while moving forwards or backwards you run really fast but great game, feel proud :D Radion 9200, 2.5ghz == 35fps You can now invert pitch by turning on caps lock. The problem with unresponsive movement control is now fixed. The problem with moving diagonally too fast is now fixed too. Thanks for your inputs :) [Edited by - Tybon on February 22, 2005 4:38:12 AM]
15. ## Editting a .X file

Quote:Original post by d000hg There's a couple of things I want to change about a .X model I have. Firstly the vertex format seems to be single texcoords only, I don't know about colour. To make it fit ingame better I need to change this. Do I want to load into a 3D editor, change vertex format and save out or can I easily hack it by hand? You can use CloneMeshFVF to change the vertex format, and save it back to a .x file with D3DXSaveMeshToX. Quote:Original post by d000hg Secondly, I want to use the same model with different skins. In the .X file it references a .bmp file. Now I could change this from "carskin.bmp" to "car skin tag", and then have a set of textures from which which the correct skin is chosen when this tag is written. But skinning is done all the time, how easy is it to load one model and then render it with multiple skins without having extra copies of the vertices and triangle data? Or is this just not done? You can set the texture you want before you call DrawSubset to render the model.