• 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.

MegaPixel

Members
  • Content count

    182
  • Joined

  • Last visited

Community Reputation

241 Neutral

About MegaPixel

  • Rank
    Member
  1. Side track question:   Considering the the data decomposition approach, is it of any benefit to base the task scheduler on a work stealing design pattern in order to   minimize mutexes on the job queue ? And if yes, is it currently used by any game engine ?   cheers
  2.   Yes that's true. But is also true that if the main sources of the mathematical model are no very precise and clear in stating what assumptions are made and so on, someone   that has to start studying them might not be find himself in the right track from the beginning. Also, the two main sources that I've checked are obviously the J. Tessendorf paper and the gamasutra article (which is actually a summarization of approaches) from Jensen. I understand that both paper have advanced mathematical models, like the DFT to work in the frequency domain and back to time domain etc. If you know about some other papers that are less advanced that I can study to get an introduction (other than what I've studied in my engineering degree) I'll be happy to study them as well in order to integrate my knowledge.   Btw, there was a bug in the displacement of the y axis (it was flipped as well). Also the horizontal disp :). I'll have a look again at the papers to see if I've missed something.   In the meantime thanks a lot for your advices and help and keep up with your awesome work.   Updated video:   http://www.youtube.com/watch?v=L7GX52V1uQU
  3.   I don't understand why you flipped the immaginary part and real part of H(K,t) ... (in the paper is not clear how that calculation is done ... and it's just says -i * Knorm * H(K,t), to me looks like it's that -i is a complex number with no real part and just Im(-i) = -1 and I can't see any flip in the immaginary and real part as you did ...). I'm sure I'm missing something from the equation that I was trying to understand   I didn't copy and paste the code (the pixel shaders that you see there are all written by myself from scratch straight from theory), I actually studied quite a lot before to implement it and then implemented everything by myself from scratch . There is not a special goal, it's   just for learning purposes ;-).   I'll try the correction and thanks for the explanation ;). Also, your water is beautiful     I verified the calculation, now I understand why was uncorrect. I forgot to consider that there will be i^2 after the multiplication that obviously is -1 :) and the immaginary part will appear on the real part which then is meant to be swapped again because I store the real part in the first component and the immaginary part in the second ;)   thanks for your help :D
  4.   I don't understand why you flipped the immaginary part and real part of H(K,t) ... (in the paper is not clear how that calculation is done ... and it's just says -i * Knorm * H(K,t), to me looks like it's that -i is a complex number with no real part and just Im(-i) = -1 and I can't see any flip in the immaginary and real part as you did ...). I'm sure I'm missing something from the equation that I was trying to understand   I didn't copy and paste the code (the pixel shaders that you see there are all written by myself from scratch straight from theory), I actually studied quite a lot before to implement it and then implemented everything by myself from scratch . There is not a special goal, it's   just for learning purposes ;-).   I'll try the correction and thanks for the explanation ;). Also, your water is beautiful
  5.   Dx, Dy, Dz in the space domain (after inverse FFT has been applied) are stored in R16_FLOAT and then interleaved in a R16G16B16A16_FLOAT for ease of use later on (so no integer here but I suppose that 16bits float is enough here ? o should I use 32bit ?.   I use Phillips spectrum for now.   The speed of wave dependes on the dispersion relation ? you mean omega? at the moment I'm using omega = sqrt(k*g) trying to let it loop with period T.   For the choppiness displacement vector I'm not sure if it's correctly calculated, because on the tessendorf paper as well as the nvidia slides is not very clear how to carry on   the calculation. Also shouldn't the horizontal displacement vector be the gradient vector flipped ?   this is the pixel shader code to generate H0 before to start the simulation (this will be execute at the simulation start and any time that a parameter like wind speed, wind direction etc. will change). float lengthSqr(in float2 v){ return dot(v,v); } float getPhillipsSpectrum(in float2 k,in OceanData oceanData){ const float windDependency = oceanData.A_V_windDependency_unused.z; const float2 W = oceanData.W_unused_unused.xy; const float A = oceanData.A_V_windDependency_unused.x; const float V = oceanData.A_V_windDependency_unused.y; float L = (V*V)/GRAVITY; float damping = 0.001f; float l = L*damping; float ksqr = lengthSqr(k); if(ksqr < 0.0000001f) //avoid division by 0 return 0.f; float2 Wn = normalize(W);//normalize wind direction float2 kn = normalize(k); float kdotw = dot(kn,Wn); float k4 = ksqr*ksqr; float kL2 = ksqr*L*L; float exp_term = exp(-1.f/kL2); float P_k = A*(exp_term/(ksqr*ksqr))*(kdotw*kdotw); //resulting Phillips spectrum //introduce wind dependency if(kdotw < 0.00001f) P_k *= windDependency; //finally suppress waves smaller than a small length (l<<L) return P_k*exp(-ksqr*l*l); } float2 get_k(in float2 pos,in OceanData oceanData){ float2 k; const float4 width_height_Lx_Lz = oceanData.width_height_Lx_Lz; k.y = ((pos.y-width_height_Lx_Lz.y*0.5f)*TWOPI)/width_height_Lx_Lz.w; k.x = ((pos.x-width_height_Lx_Lz.x*0.5f)*TWOPI)/width_height_Lx_Lz.z; return k; } float4 main(PS_Input Input) : SV_Target{ float2 pos = Input.Pos.xy; //screen space position float2 gaussRand0 = gaussianDistributionTexture.Load(int3(pos,0)).xy; float2 gaussRand1 = gaussianDistributionTexture.Load(int3(pos,0)).zw; float2 k = get_k(pos,oceanData); //get the Phillips spectrum float P_k = sqrt(getPhillipsSpectrum(k,oceanData)*0.5f); float P_mk = sqrt(getPhillipsSpectrum(-k,oceanData)*0.5f); //H0(k) float2 H0k = P_k*gaussRand0; //H0*(-k) float2 H0mkConj = float2(P_mk*gaussRand1.x,-P_mk*gaussRand1.y); return float4(H0k,H0mkConj); } this is my pixel shader code for the three spectrum update: PS_Output main(PS_Input Input){ PS_Output Output = (PS_Output)0; float2 pos = Input.Pos.xy; //screen space position float4 h0k_h0mkConj = h0k_h0mkConjTexture.Load(int3(pos,0)); float2 K = get_k(pos,oceanData); //get the wave vector //start calculating H(k,t) first then Dx and Dz const float T = oceanData.A_V_windDependency_T.w; const float t = time.x; const float2 H0k = h0k_h0mkConj.xy; const float2 H0mkConj = h0k_h0mkConj.zw; float omega0 = TWOPI/T; //basic angular frequency float k = length(K); float omegad = floor(sqrt(k*GRAVITY)/omega0)*omega0; float2 Knorm = normalize(K); float omegadt = omegad*t; float2 expLeft = float2(cos(omegadt),sin(omegadt)); //euler formula float2 expLeftConj = conjComplex(expLeft); //H(k,t) //HKt = H0*expLeft + H0Conj*conj(expLeft); float2 a = mulComplex(H0k,expLeft); float2 b = mulComplex(H0mkConj,expLeftConj); //Dy axis displacement in frequency domain float2 HKt = addComplex(a,b); //Dx,Dz displacements in frequency domain float2 DxKt = mulComplex(float2(0.f,-Knorm.x),HKt); float2 DzKt = mulComplex(float2(0.f,-Knorm.y),HKt); Output.Dx = float4(DxKt,0.f,1.f); Output.Dy = float4(HKt,0.f,1.f); Output.Dz = float4(DzKt,0.f,1.f); return Output; } those two are the complex representation of the horizontal displacement vector in frequency domain:   float2 DxKt = mulComplex(float2(0.f,-Knorm.x),HKt); //mulComplex is used to perform the complex multiplication between two complex number float2 DzKt = mulComplex(float2(0.f,-Knorm.y),HKt);   I'm not sure if the computation is correct as in the paper it doesn't break down further so I would expect to be like (the nvidia slides don't use the minus sign ...):   -i * (K/k) * H(K,t)   which means:  -i is a complex number with no real part but just Im(-i) = -1 if I understand correctly.   so this should come down to:   Kn == K/k which is K normalized    -i*Kn.x ---> float2(0.f,-Knorm.x)  -i*Kn.y ---> float2(0.f,-Knorm.y)   then to produce each component I should perform a complex multiplication with H(k,t) for each component to produce Dx and Dz in the frequency domain.   I paste you the nvidia approach (which is actually the tessendorf one):         Also: nvidia doesn't put any minus sign while Tessendorf does ... !!! ... :/   Plus, the colors of the final displacement from NVIDIA seem to be differents in general from the ones of my heightmap as you can see in my first video ... might be because of some bug in the horizontal vec displacement ?   thanks in advance for your help
  6. Hi all,   I've implemented radix-2 FFT on the gpu and that's the result that I've got so far (for the lod algorithm I'm using geometry clipmap with toroidal update on).   http://www.youtube.com/watch?v=vLByMPrxYLQ   http://www.youtube.com/watch?v=R2-pC1seKLY   sometime It looks like that the waves instead of doing a smooth and gentle fade off, they just looks like they cut off with a discontinuity ... If you look at the 1st video at 0:18 I show the heightmap update along with the related spectrum. The heightmap looks ok to me (it actually has choppiness in as well, as you can see because it's colored).   Note: there is choppiness as well (which I tried to disable it to see if that was the problem, but it wasn't).   can someone shed some light or has some ideas ?   Also what could be a good rule of thumb to follow to try different settings for the water ?   Reminder:   I've got grid size in meters (MxN) and grid resolution which is the actual heightmap res.   wind speed V wind direction W   PS.: if I increase V the speed of the simulation is still the same. I guess V will generate just bigger waves ? ...   Thanks in advance
  7.   So that means that there is no way to switch from one camera control to another without interpolating between them ?   I thought it was possible to just accumulate in the right order (based on the current camera control type) to be consistent to one camera control or   another without sudden changes to show up.   Plus, currently I'm calculating my orientation like this and it works stable with no gimbal lock or numerical instabilities, but I do not understand why I should work with delta rotations instead of absolute angles (it works anyway).   Here is a code snippet:   //create orientation QuatfFromAxisAngle(Vec3f(1.f,0.f,0.f),mPitch,&mRotX); QuatfFromAxisAngle(Vec3f(0.f,1.f,0.f),mYaw,&mRotY); QuatfFromAxisAngle(Vec3f(0.f,0.f,1.f),mRoll,&mRotZ); QuatfMult(mRotX,mRotY,&mRotXY); QuatfMult(mRotZ,mRotXY,&mOrientation); //normalize quaternion QuatfNormalize(mOrientation,&mOrientation); //now extract the orientation part of the view matrix Mat44fInitFromQuaternion(mOrientation,&mViewMatrix.mat44f); mViewMatrix.mat44f.v03 = -Vec3fDot(cameraPos,mRight); mViewMatrix.mat44f.v13 = -Vec3fDot(cameraPos,mUp); mViewMatrix.mat44f.v23 = -Vec3fDot(cameraPos,mForward);   It works smooth and perfect (I keep Roll == 0 all the way).  Pitch, Yaw are just accumulated absoulte angles: Pitch += dPitch; same for yaw   What I'm thinking is It possible to make just one class that gives just very bare bones operators to implement different camera behaviours without having to implement a class for every camera type ?   I saw some implementation showing something like:   rotateXCameraRelative   or rotateXWorldRelative blabla   which leads me to think they are just basic operators and there is no reference to first person or third or track ball ... and the idea is that a very specific combination of them can implement for example a first person behaviour or a trackball if you use a different combination of them.   I
  8. Hi to everyone, I'm trying to build a generic camera class (so just one class) that with few simple operators can allow one to create any type of high level camera. I'd like to do it this way because I think that, then, switching for example between a first person and a trackball like camera will be easier. For now I've successfully implemented the usual 1st person camera by defining few simple operators on the camera class and creating orientation using quaternions. Operators/Methods: moveXCameraRelative moveYCameraRelative rotateXCameraRelative rotateYCameraRelative The thing is that I can't figure out how to switch between (say) a 1st person and a trackball without screwing everything. What I mean is flying a bit with a 1st person and then from that exact pov switch to trackball and use it and then back to 1st person transparently (like in a DCC tool). What I thought is that I should accumulate orientations etc. but I guess that my current method is not very correct because instead of accumulating orientations deltas I accumulate the angle and calculate the orientation of accumulated angles instead of defining an offset quaternion. I saw some implementation they do something like: Quaternion q(axis,delta) //the offset quaternion (relative rotation quaternion) I do something like: angle += delta; Quaternion q(axis,angle); //the absolute rotation quaternion should I use the first solution and accumulate quaternions instead of accumulate the absolute angle to have the possibility to implement the behaviour that I described before ? Thanks in advance for your help
  9. [quote name='mauro78' timestamp='1348847187' post='4984749'] [quote name='MegaPixel' timestamp='1348818490' post='4984649'] [quote name='mauro78' timestamp='1348756396' post='4984365'] [quote name='MegaPixel' timestamp='1348755712' post='4984362'] I personally use one render target 16bit fp only as everything get modulated in one go: return dffuseTerm*lightColor diffuseTerm should be what you call in-scatter and light color is the rgb color of a given light. I don't see why you have to use so many render target to store the computed lighting ... any reason for that ? The problem, IMHO, is more relevant when you have to chose the number of gbuffers and their number of bit per channel as that is one thing that can influence your bandwidth. [/quote] MegaPixel, In-scatter is not diffuse lighting that's why I need more space :-) [url="http://en.wikipedia.org/wiki/Light_scattering...."]http://en.wikipedia...._scattering....[/url] my final color is: fragment color = (diffuse fragment color*texture_color) + inscatter fragment color regards p.s. [b]>The problem, IMHO, is more relevant when you have to chose the number of gbuffers and their number of bit per channel as that is one thing that can influence your >bandwidth.[/b] I agree but my problem is not about this (g-Buffer creation phase)...but in the next one: accumulation phase [/quote] Ohh you meant indirect lighting ? [/quote] No It's not. Diffuse computation model the interaction between photons and surface Scattered light model the interaction between photons and athmosphere or other medium. Here You can have 3 types of results in-scattered,out-scattered,absorbed. The resulting effects is sort of volumetric effects..... [/quote] Ok so you are talking about sky light (the light reflected from the sky)? Light shafts ? ...
  10. [quote name='mauro78' timestamp='1348756396' post='4984365'] [quote name='MegaPixel' timestamp='1348755712' post='4984362'] I personally use one render target 16bit fp only as everything get modulated in one go: return dffuseTerm*lightColor diffuseTerm should be what you call in-scatter and light color is the rgb color of a given light. I don't see why you have to use so many render target to store the computed lighting ... any reason for that ? The problem, IMHO, is more relevant when you have to chose the number of gbuffers and their number of bit per channel as that is one thing that can influence your bandwidth. [/quote] MegaPixel, In-scatter is not diffuse lighting that's why I need more space :-) [url="http://en.wikipedia.org/wiki/Light_scattering...."]http://en.wikipedia...._scattering....[/url] my final color is: fragment color = (diffuse fragment color*texture_color) + inscatter fragment color regards p.s. [b]>The problem, IMHO, is more relevant when you have to chose the number of gbuffers and their number of bit per channel as that is one thing that can influence your >bandwidth.[/b] I agree but my problem is not about this (g-Buffer creation phase)...but in the next one: accumulation phase [/quote] The accumulation phase is not a problem, just use another render target [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]. I personally use a different render target for my indirect lighting [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] ... Again, the problem is normally the gbuffer phase, in a typical pipeline when you need to compose different results it's very normal to subdivide those in more passes, with each pass it's own render target etc. and then compose them at the end.
  11. [quote name='mauro78' timestamp='1348756396' post='4984365'] [quote name='MegaPixel' timestamp='1348755712' post='4984362'] I personally use one render target 16bit fp only as everything get modulated in one go: return dffuseTerm*lightColor diffuseTerm should be what you call in-scatter and light color is the rgb color of a given light. I don't see why you have to use so many render target to store the computed lighting ... any reason for that ? The problem, IMHO, is more relevant when you have to chose the number of gbuffers and their number of bit per channel as that is one thing that can influence your bandwidth. [/quote] MegaPixel, In-scatter is not diffuse lighting that's why I need more space :-) [url="http://en.wikipedia.org/wiki/Light_scattering...."]http://en.wikipedia...._scattering....[/url] my final color is: fragment color = (diffuse fragment color*texture_color) + inscatter fragment color regards p.s. [b]>The problem, IMHO, is more relevant when you have to chose the number of gbuffers and their number of bit per channel as that is one thing that can influence your >bandwidth.[/b] I agree but my problem is not about this (g-Buffer creation phase)...but in the next one: accumulation phase [/quote] Ohh you meant indirect lighting ?
  12. [quote name='mauro78' timestamp='1348754753' post='4984354'] [quote name='MegaPixel' timestamp='1348733400' post='4984269'] [quote name='Ashaman73' timestamp='1348724434' post='4984233'] Puting it into a 16 float is the hard problem. If you would have a 16 bit int you could use a 5:5:6 distribution. I don't know what your scatter value means and what value ranges they have, but there are other options. One option is, that you can reconstruct one value from the other two (maybe using a mapping to transform the scatter value in a better representation). This way you only have two values, which could be saved as decimal number like "left_value + (right_value/MAX_RIGHT_VALUE)". This way you save the right value as fraction. Though you need to ensure that your base values are integer values and don't get too high. [/quote] He can do that trick with normals and store just xy (even though he has to be careful in which space they are as z can be negative or positive). See [url="http://aras-p.info/texts/CompactNormalStorage.html"]http://aras-p.info/t...malStorage.html[/url] for several ways of compressing your normals in gbuffer. But since he is talking about inscatter I would guess maybe he means the accumulated direct lighting and in that case we are in the context of manging hdr values. So I would suggest if you are on PC just go for a 16bits frame buffer and use CIE to RGB conversion while tonemapping your luminance and then convert from CIE back to RGB with the adjusted/tonemapped luminance. That will preserve your hue and saturation as it will allow you to work on just the luminance. The need to store or compress values in smaller buffers is more relevant on consoles where the bandwidth problem is more present and, also, in the case in which you don't support floating point blending (which is the case on PS3 if I don't remember wrong). A good approach is described in shaderx7, using LogLuv color space compression to store HDR value in 8888 unsigned. The only disadvantage is that you can't blend in LogLuv space but there is a trick to do it and that is explained in that article. Also you can couple that approach with a light prepass renderer scheme to reduce the bandwidth requested to your gbuffers even more, but at the cost of making two geometry passes. [/quote] Let me clarify this: during the light accumulation phase of the deferred rendering pipeline I'm storing (for every light): (RT1)R,G,B channels: diffuse light accumulation (RT1)A channel: In-Scatter accumulation (monochromatic light scattering) as described before maybe I'll create another RT and go to this scenario: (RT1)R,G,B channels: diffuse light accumulation (RT2)R,G,B: In-Scatter accumulation (colored lights) Regards [/quote] I personally use one render target 16bit fp only as everything get modulated in one go: return dffuseTerm*lightColor diffuseTerm should be what you call in-scatter and light color is the rgb color of a given light. I don't see why you have to use so many render target to store the computed lighting ... any reason for that ? The problem, IMHO, is more relevant when you have to chose the number of gbuffers and their number of bit per channel as that is one thing that can influence your bandwidth.
  13. [quote name='Ashaman73' timestamp='1348737113' post='4984286'] Before doing all this magic, why not use an additional render target ? [/quote] Actually if he is on PC he can also go for a full deferred solution as bandwidth is not as big as in the past. So I guess a minimum of 3 gbuffers is enough ... it then depends on his setup ...
  14. [quote name='Ashaman73' timestamp='1348724434' post='4984233'] Puting it into a 16 float is the hard problem. If you would have a 16 bit int you could use a 5:5:6 distribution. I don't know what your scatter value means and what value ranges they have, but there are other options. One option is, that you can reconstruct one value from the other two (maybe using a mapping to transform the scatter value in a better representation). This way you only have two values, which could be saved as decimal number like "left_value + (right_value/MAX_RIGHT_VALUE)". This way you save the right value as fraction. Though you need to ensure that your base values are integer values and don't get too high. [/quote] He can do that trick with normals and store just xy (even though he has to be careful in which space they are as z can be negative or positive). See [url="http://aras-p.info/texts/CompactNormalStorage.html"]http://aras-p.info/texts/CompactNormalStorage.html[/url] for several ways of compressing your normals in gbuffer. But since he is talking about inscatter I would guess maybe he means the accumulated direct lighting and in that case we are in the context of manging hdr values. So I would suggest if you are on PC just go for a 16bits frame buffer and use CIE to RGB conversion while tonemapping your luminance and then convert from CIE back to RGB with the adjusted/tonemapped luminance. That will preserve your hue and saturation as it will allow you to work on just the luminance. The need to store or compress values in smaller buffers is more relevant on consoles where the bandwidth problem is more present and, also, in the case in which you don't support floating point blending (which is the case on PS3 if I don't remember wrong). A good approach is described in shaderx7, using LogLuv color space compression to store HDR value in 8888 unsigned. The only disadvantage is that you can't blend in LogLuv space but there is a trick to do it and that is explained in that article. Also you can couple that approach with a light prepass renderer scheme to reduce the bandwidth requested to your gbuffers even more, but at the cost of making two geometry passes.
  15. [quote name='mauro78' timestamp='1348687405' post='4984076'] Hi All, During a deferred pass on a D3DFMT_A16B16G16R16F render target I come across this problem: I'm correctly computing a "in-scatter" value which is a float3 where every component are a 16bit float. [b]Is there a good way to store (even with a little loss of precision) those 3 values into a single float (16bit)?[/b] Hints/help/link appreciated....thx EDIT: scatter is a float3 where every component is in the [0,1] range Mauro IoN6 Games [/quote] if you have 3 component in 0,1 range it is most likely that they fit in 8 bits per channel. So 24 bit are necessary to store them and therefore 16bits are not enough. In deferred shading you can store everything in 8888 buffer using a color comprwession scheme (see logluv)