• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

173 Neutral

About pekarn

  • Rank

Personal Information

  1. Gamma Correction

    Yes and that is my understanding of how it should work. What I'm saying is that if I output a linear gradient without any correction my eyes perceive it as linear on the monitor aswell, if I apply correction to it then it doesn't look linear anymore. Basically the color that I perceive on the monitor matches the linear values that I output from the shader. Which, as you say, is not what should happen, and that's why I'm confused.
  2. Hello! I'm currently trying to make sure that my engine handles gamma in a correct way. The problem is the results that I'm getting contradict my understanding of how it should work (based on what I've read). The test that I'm doing is from the shader use the screen uv to output a linear gradient from black to white. I currently do no correction at all (my backbuffer format is not a srgb format, I don't set any gamma ramp, the shader doesn't do any correction). Based on my understanding this would result in the gradient that I see on my monitor being incorrect since I don't do any correction. However the result I see is a gradient that looks linear. When I try to apply correction the gradient ends up looking non-linear.   So basically when I don't do any correction at all I get what seems like correct results. According to the settings on my monitor it's using 2.2 gamma. I looked in NVIDIA control panel and the gamma override setting there is turned off as it should be. Interestingly if I enable it and change the gamma the image will change gamma for a bit less than a second and then it seems something else will override it and the image will look normal again even though the slider is still set to something different.   I've tried messing around with this (http://mynameismjp.wordpress.com/2010/04/30/a-closer-look-at-tone-mapping/) tonemapping sample. If I do the same thing and output a linear gradient from the shader in that sample I will get an incorrect output on the monitor because it uses an srgb backbuffer.   I'm just really confused right now as to what's going on so any help to sort it out would be great.   Thanks
  3. StructuredBuffer vs Buffer

    Thanks for your replies. :)
  4. Hello! Direct3D 11 added several new resource types for shaders. The ones of interest for this post is Buffer, StructuredBuffer and ByteAddressBuffer. I have some questions about the differences between them. I have mostly used StructuredBuffer before and occasionally Buffer. I have never used ByteAddressBuffer. I mostly care about Buffer and StructuredBuffer but figured I'd include ByteAddressBuffer aswell.   I know that with a regular Buffer the data in the buffer can have a different format than what you declare it with in the shader and the GPU will automatically do the conversion just like when you sample a texture or pass in data in a vertex buffer. With a StructuredBuffer the data has to match the declaration in the shader which limits you to HLSL types.   Other than that and the syntax difference is there any other difference between Buffer and StructuredBuffer? Any difference in performance? If my data isn't stored in a different format than how I use it in the shader is there any reason to use Buffer over StructuredBuffer?   For example is there any difference between these two (assuming that the data in the buffer are regular uncompressed floats)? struct SData { float f; }; StructuredBuffer< SData > Buf; Buffer< float > Buf;     Another example, would it make any difference for performance or anything else between these two? struct SData { float f; uint i; }; StructuredBuffer< SData > Buf; Buffer< float > Buf1; Buffer< uint > Buf2;     And finally, what's the reason to use a ByteAddressBuffer? Like I said I've never used them so I just know what the documentation says. You can't access individual bytes, you have to access whole uint values. So why use a ByteAddressBuffer over something like: Buffer< uint > Buf;     Thanks for helping me clear this up.
  5. As far as I know there is no easy solution to this. You have to either split into multiple draw calls and change the parameters for the draw call to do the offset, but obviosly you don't want to do that because the goal was to reduce draw calls. The only other way (that I can think of) is to apply the offset to the indices that you put in the buffer.
  6. Container Access Problem

    [quote name='dimitri.adamou' timestamp='1344762298' post='4968650'] If your compiler supports Lambda expressions try this one out [code] auto it = remove_if(List.begin(), List.end(), [](const SayProcess& lp) { lp.Say(); return true; }); List.erase(it, List.end()); [/code] [/quote] Actually std::list has a member function remove_if that will do this more efficiently (because it doesn't have to move the elements). So the above code would be replaced by [source lang="cpp"]List.remove_if( [](const SayProcess& lp) -> bool { lp.Say(); return true; } );[/source] This is only for list though. If your container is std::vector for example you have to use the erase-remove idiom demonstrated by dimitri.adamou. Also I believe lambda functions can only leave out the return type if the function consists of only a single return statement. I added the return type in my code above.
  7. Counting number of class instances

    The #ifdef guards only prevent the header from begin included more than once in a single source file.
  8. Counting number of class instances

    The code is probably compiled so that a temporary object is created before the creation of 'a' so that's why 2 instances are created. Might be something wrong with the destructor that causes it to not decrease the value? Can you show the constructor and destructor for A?
  9. [quote name='yewbie' timestamp='1311720543' post='4840861'] Side note, why do people use the TEXT( ) macro instead of L [/quote] Because TEXT can be changed to mean anything. If you are compiling with different settings you may not want/need the L there. If you had used the L you would have to go through your code and change it everywhere you used L. If you used the TEXT macro you can just change the TEXT macro to mean something else and the code will still work.
  10. render to texture dx9

    [quote name='Yours3!f' timestamp='1311750062' post='4840969'] I tried to debug the app frame by frame, and it seems that in the first frame the render_to_tex_surf is correct, but in the following frame it somehow loses the data, and points to wrong memory location, and it cannot be accessed, that's when access violation occur. [/quote] That's probably because you're destroying the surface. You shouldn't be releasing the surface after setting it as a rendertarget. The surface's refcount will increase when you set it as rendertarget ( if I recall correctly ) but it will be decreased again when another rendertarget ( the backbuffer ) is set. When you call release on the surface you will cause the surface to be destroyed while your app is still running. Assuming you only do GetSurface once you should only release the surface once, at the end of the program.
  11. surface data

    Could you specify what error you're getting from memcpy. Also have you checked to make sure the lock is successful?
  12. surface data

    You need to make sure that the data in your surface is 32-bit. If it has any other format it will have a different size.
  13. Apart from the extremely minor performance loss of looping twice those two methods are completely equal. Use which ever method fits best into the structure of your code. The scaling rotation parameter allows you to rotate the scaling axes. Instead of scaling your sprite along the X and Y axes you scale it in another direction. Play around with it and test different values and you'll see what I mean. I have never found anything useful to use it for.
  14. D3D10 Warnings/Info Problem

    [quote name='mwadelin' timestamp='1308834484' post='4826757'] D3D10: WARNING: ID3D10Buffer::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS ] This warning appears twice at the beginning of execution of my program. Any idea what it means? [/quote] I also get that error the first time I call DrawText. I ignored it and haven't had any related issues since.
  15. Texture2D Sample in HLSL

    [quote name='chenpan' timestamp='1308732057' post='4826336'] The texture's fomat is DXGI_FORMAT_R32_FLOAT. So I don't think there is anything wrong in the following code snippet. float current; float maxd; maxd = current = g_Disparity.Load(int3(x,y,level)); [quote name='MJP' timestamp='1308722354' post='4826276'] What format are your textures? You need to declare your Texture2D with an appropriate return type for the format in order for the data to be interpreted correctly. [/quote] [/quote] What MJP is saying is that [code]Texture2D g_Disparity; [/code] needs to be changed to [code]Texture2D<float> g_Disparity; [/code] so that the texture will be interpreted properly
  • Advertisement