# Ivo Leitao

Member

122

172 Neutral

• Rank
Member
1. ## [SlimDX][D3D10/11] Problem setting matrix variable

I've post an issue concerning this in the slimdx issues area. It's located here http://code.google.com/p/slimdx/issues/detail?id=780. I've managed to correct the issue and I have attached some code in there to handle this case. Tnks

3. ## Length in hlsl (confused)

Quote:Original post by galop1n It looks like you found weird bug! I took the latest fxc.exe from the june 2010 directx sdk and here the result *** Source Snippet Removed *** And here the assembly generate *** Source Snippet Removed *** We clearly see that on cst it compute (x*x+y*y)^0.5 (the square root done by a invert square root followed by the reciprocal) On the constant, it pick up the first component, x, and updating y did nothing! I found a sick workaround for you, wrote this like that and the compiler do the math correctly. *** Source Snippet Removed *** with the good result: *** Source Snippet Removed *** galop1n Tnks a lot for your answer. I have changed my unit tests. I was almost thinking that I was not seeing it clearly :-S The same happens with other hlsl functions like distance and smoothstep for example. This is unbelievable :-(. I'm doing a small pixel shader focused language and I have a lot of unit tests, this was one of the first type of tests that I have done. In a professional tool like the Microsoft Hlsl compiler I cannot understand how things simpel as that escape.... [Edited by - Ivo Leitao on December 1, 2010 7:11:01 PM]
4. ## Length in hlsl (confused)

I'm very confused with the length function in hlsl. From what i can understand it gives me the length of a vector so for example for: length(float2(4.0, 3.0)) It should calculate the square root of 4^2 + 3^2 = 16 + 9 = 25 i.e. 5 I'm obtaining 4... what the helll ???? Here is the shader that I have used in Fx Composer 2.5. I have debugged it and confirmed that for one of the pixels the value is indeed 4.0 float4x4 WorldViewProj : WorldViewProjection; float4 mainVS(float3 pos : POSITION) : POSITION{ return mul(float4(pos.xyz, 1.0), WorldViewProj); } float4 mainPS() : COLOR { float a = length(float2(4.0, 3.0)); return float4(1.0, 0.0, 0.0, 1.0); } technique technique0 { pass p0 { CullMode = None; VertexShader = compile vs_3_0 mainVS(); PixelShader = compile ps_3_0 mainPS(); } } [Edited by - Ivo Leitao on December 1, 2010 12:35:37 PM]
5. ## [SlimDX] Setting, getting effect variables in D3D10 & d3D11

Hi, I need to obtain/set the value of a shader variable in d3d9, d3d10 and in d3d11 (I'm targeting the three). I have custom vector and matrix types (in my case Float2, Float3, Float4, Matrix2x2, Matrix3x3 and Matrix4x4) and in D3D9 i do not have any problems obtaining/setting the values of these type of variables in the shader since I could do something like this (from my code): protected T GetVariable<T>(string name) where T : struct { return this.effect.GetValue<T>(this.variableHandles[name]); } protected void SetVariable<T>(string name, ref T oldValue, T newValue, bool compare) where T : struct, IEquatable<T> { if (!compare || !oldValue.Equals(newValue)) { oldValue = newValue; this.effect.SetValue<T>(this.variableHandles[name], newValue); } } The important part here is the this.effect.GetValue<T> and this.effect.SetValue<T>. This generic methods are very handy in D3D9 allowing me to use custom types not only here but in other parts of the api. Till now my other interactions with d3d10 and d3d11 api where through a DataStream from where I was able to extract my custom types too but in this case, setting and getting shader variables, I'm not finding similar options. I've searched and I've found getRawValue and setrawvalue methods in Effect variable (unfortunately in d3d10 only in the source of slimdx not on the latest official release) How can I accomplish something similar ? Tnks in advance
6. ## Packing a generic float into a rgba texture

Quote:Original post by Matias Goldberg Yes. Suppose you know the minimum negative value is -50, and the maximum positive value is 112. Then you do: x = (x + 50) / (50 + 112) That's it! Simple math to get the value in the range [0; 1] Cheers Dark Sylinc Tnks a lot! I've not made many tests yet (too sleepy :-)) but it seems to work. I've incorporated Ysaneya code from http://www.gamedev.net/community/forums/topic.asp?topic_id=463075&whichpage=1�. Bellow in HLSL : float4 PackToFloat4(float value) { const float4 bitSh = float4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0); const float4 bitMsk = float4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); float4 res = frac(value * bitSh); res -= res.xxyz * bitMsk; return res; } float4 PackToFloat4(float value, float min, float max) { return PackToFloat4((value - min) / (max - min)); } float UnpackToFloat(float4 value) { const float4 bitSh = float4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0); return dot(value, bitSh); } float UnpackToFloat(float4 value, float min, float max) { return UnpackToFloat(value) * (max - min) + min; }
7. ## Packing a generic float into a rgba texture

Quote:Original post by Matias Goldberg Quote:Original post by Ivo Leitao Those links (specially the last two) store numbers in the [0..1) range I would like to store arbitrary floats. I don't know even if that is possible. Just divide the float by the largest possible number you know that can appear. This is often a good practice even for FP formats, since best precision is in the [0; 1] range. For example if you're doing shadow mapping, divide all values by the far clipping plane of your shadow camera. When packing to an integer texture you will always lose some precision, so the division won't actually hurt. Cheers Dark Sylinc Hum, I'm going to test it tonight Tkns. One question, what you have mentioned can be applied also to negative values for example -2.3 ? Tnks for your answer
8. ## Packing a generic float into a rgba texture

Quote:Original post by JorenJoestar Hi Ivo, there are a bunch of links around that can be useful: http://diaryofagraphicsprogrammer.blogspot.com/2009/10/bitmasks-packing-data-into-fp-render.html http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/ http://theinstructionlimit.com/?p=33 Hope those helps! Tnks for your answer but I've already reviewed all those links (two of them are on my list) but I was hoping for a way to do that with 32 bit ARGB textures where we have 8 bits per channel. I would like to split a float into 4 parts of 8 bits each and unpack it from those channels into a float. Those links (specially the last two) store numbers in the [0..1) range I would like to store arbitrary floats. I don't know even if that is possible.
9. ## Packing a generic float into a rgba texture

Quote:Original post by smasherprog What do you mean an rgba texture? What format? You can create several types of float rgba formats http://msdn.microsoft.com/en-us/library/bb173059%28VS.85%29.aspx pick which one you want and create it. I'm sorry I forgot to mention I was referring to A8R8G8B8 32 bit format. tnks for your answer
10. ## OpenGL Packing a generic float into a rgba texture

Hi, I've searched the forums and the web for an answer to the topic above but I was able to find only code to do it for numbers between 0 and 1. I wonder if it's possible to encode a generic float (for example 2.3, 12.33454 or -0.4) in a rgba texture (A8R8G8B8 32 bits). I know that I can use float textures and I'm using them, however for old graphic cards like the integrated intel cards that are still in a lot of notebooks using the float format is not possible. I've compiled a couple of links bellow concerning this topic, but none of them answer my problem http://www.gamedev.net/community/forums/topic.asp?topic_id=442138 http://www.gamedev.net/community/forums/topic.asp?topic_id=573743 http://www.gamedev.net/community/forums/topic.asp?topic_id=486847 http://www.gamedev.net/community/forums/topic.asp?topic_id=573743 http://www.gamedev.net/community/forums/topic.asp?topic_id=322318 http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=265044 http://www.gamerendering.com/2008/09/25/packing-a-float-value-in-rgba/ http://theinstructionlimit.com/?p=33 http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/ http://www.gamedev.net/community/forums/topic.asp?topic_id=498533 http://gamedusa.blogspot.com/2010/03/pack-normal-and-height-data-in-one.html I wanto to pack in HLSL or GLSL and unpack in C# [Edited by - Ivo Leitao on October 19, 2010 12:41:24 PM]

Amazing !!
12. ## Best game terrain rendering solution to use?

Quote:Original post by ndhb I also think Chunked LOD is a fairly good solution but only if A) The terrain dataset is static (CLOD uses a non-trivial algorithm for preprocessing the dataset, it isn't something you want to run on-the-fly), B) You're satisfied with using skirts to cover the artefacts from t-junctions. The skirt technique adds a little to the fillrate requirement and increases the # draw calls. CLOD might also slightly complicate accurate collision detection and terrain following because the mesh isn't regular. On the other hand the algorithm scales well and streaming in new data from disk or network is straightforward. If you need to handle a really large dataset, then you should work with algorithms that use clipmaps or similar techniques. But they're also a bit more complicated to implement. Remember the algorithm Hoppes first published does not require the latest hardware (http://research.microsoft.com/en-us/um/people/hoppe/proj/geomclipmap)! However, what I would do in your situation, is to implement either "Geomipmap (W. de Boer)" (either with VBO or VTF depending on what hardware generation you want to support), OR " GPU Terrain Rendering from Game Programming Gems 6" (H. Vistnes). Then extend it with some geomorphing in the VS. You probably also want to texture the terrain. This can obviously take a lot of time as well if you're hard to please :) I think the fastest algorithm is the chunked lod or at least the principle behind it. Concerning Geomorphing it is easy if you use the simplification method of the geomipmapping algorithm. Therefore a hybrid approach between Geomipmapping and Chunked Lod is IMHO the best strategy. Also using skirts does not increase draw calls if you connect the skirts with the main block with degenerate triangles. The fillrate problem can be handled if you use the geometric error as the size of the skirts. If you want dynamic changes you can use the strategy mentioned in the "GPU Terrain Rendering from Game Programming Gems 6" as was mentioned. It blend nicely with the rest. I have to recommend one of the best articles out there about this: Rendering Very Large, Very Detailed Terrains. Unfortunately its not online anymore (it was on the www.terrain.dk), but you can find the source code here: http://sourceforge.net/projects/vlterrain/ They use an approach very similar to this in the Torque engine. the only difference is that they use clipmapping for the textures, which by the way is a good solution and handles the only problem of the Rendering Very Large Very Detailed Terrains solution, the seams between textures. Also the approach used in the Infinity project by Ysaneya (http://www.gamedev.net/community/forums/mod/journal/journal.asp?jn=263350) is somewhat similar with a quadtree like simplification. I have implemented all of this minus the clipmapping of the textures and I have to say that I'm very happy with it.
13. ## 2008 Retrospective and progress

Have you seen this paper ( Precomputed atmospheric Scattering) : http://www-ljk.imag.fr/Publications/Basilic/com.lmc.publi.PUBLI_Article@11e7cdda2f7_f64b69/index_en.html The results they are getting look amazing
14. ## Making games in XNA and being paid for it

Quote:Original post by theZapper To add to you skeptisism, CrystalSitral, your game also has to pass peer review. So depending on how hard that is and how long it takes to review, you could make a game and never see it on Live! anyway. If your game is good enough i don't think that is an actual problem. A lot of games pass the peer review process in the beta version of the site in just a couple of hours. It seems a lot of people likes to peer review games. I have a subscription and the last games i have only managed to see them in the final state (approved), besides you get useful opinions on your game if you don't reach an approved state. There's another important thing here: recognition. This is a great way to start a career as a game developer. People with good ideas attract attention. This is a good way to make yourself known (if that is one of your objectives) Check http://catalog.xna.com/gamescatalog.aspx to see the latest games approved in the beta. There are some fine looking games there like Colosseum, skip lancer, jelly factory, Gymnast, Jelly car (my personal favorite) just to mention a few...
15. ## Making games in XNA and being paid for it

Just sharing some great news ;-) We can know make games publish them and get paid :-) Nice http://creators.xna.com/en-us/news/communitygameslaunch