Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

2365 Excellent

About apatriarca

  • Rank
    Advanced Member

Personal Information

  • Interests
  1. The easier way to define the type correctly is to first create a typedef for your function type and then define your function returning that type. getfunc can't set his own value in its implementation. And it can't be a function pointer if you are trying to implement it as a function getting a char and returning a function pointer. getfunc would also have a different type than add or sub.. typedef int (*op_func)(int, int); // .. define add and sub op_func getfunc(char op) { switch(op) { case '+': return add; case '-': return sub; } } int main() { fprintf("5 + 7 = %d", getfunc('+')(5, 7)); fprintf("5 - 7 = %d", getfunc('-')(5, 7)); }
  2. Not really interpolation. That's a simple sum over the non-zero functions.
  3. I can't open your link but the basic approach is to define your field as a sum of basis functions centered at the maximum and minimum points. Many different functions can be used. Some additional examples include rational functions like 1/(1 + x^2) or piece-wise polynomial or trigonometric functions like F(x) = cos(x) + 1 in [-pi, pi] and zero outside. What other properties do you want from your peaks?   A cubic B-spline basis function is a piece-wise polynomial function which is used as the basis for B-spline curve and surfaces. It is defined recursively and they can be defined for any order/degree. The cubic B-spline basis functions are the more common ones. The local support property can be useful in this case since it means the function is zero outside some distance from these points (thus reducing the amount of computation required).
  4. I am not sure what you mean by the field to be uniform. You can use any function with a peak in the point to create production or consumption. Different functions will obviously look different. A good candidate can probably be cubic B-spline basis functions. They are quite fast to evaluate and they have a local support. Their derivative is also very easy to compute (which makes it easier to compute the flow).
  5. apatriarca

    Image compositing

    Nothing I have read in this post can actually be considered PBR. You have in fact just took the intuitive meaning of all those concepts and mixed them. A physically based approach should instead start from the ways a particular material interact with light. The formulas and meaning of the various terms are actually completely wrong. The specular light is computed in an incorrect way and it does not behave like specular light at all. The metallic term is not shininess, but a parameter used to interpolate between two very different material responses. A metal is very specular (even at normal incidence), it has a colored specular reflection and there is no diffused light. A dielectric has instead a mostly diffused response at normal incidence (only about 4% is reflected) and the reflection is white. There is no patina (not sure what you mean here). There are probably also other things.    While I agree implementing the concepts is the best way to learn, I think you should still try to read good resources on the subject and implement the concepts properly. If you just try to write things before really understanding them you risk to learn them wrong.
  6. apatriarca

    Icosphere and height map

    In the shader you can do many different things to improve the details: 1. Increase the tessellation dynamically using the tessellation shader, 2. Use displacement mapping to give the impression of details without actually adding more geometry.
  7. apatriarca

    Game Engine Containers - handle_map

    This sort of implementation is actually useful in a more general settings than game development. This is not however a complete alternative to std::unordered_map since the handles are generated by your handle_map and not by the user. Considering the ECS system for example, the handles of the components will be all different. You can't use a single ID to retrieve all the components of an entity from the various systems.
  8. apatriarca

    Icosphere and height map

    A few observations: 1. Do you really need to compute the radius each time? Isn't it a known quantity? 2. Why are you converting every angle to degrees? That's useless and you then have to convert them back to radians (or other range) to be able to use them. 3. The normal of each vertex is the vertex itself normalized. You can thus simply multiply the vector by some value to get the displaced one. If the vector has lenght R and you want its height to be H, you simply have to multiply by H/R. 4. This is probably all best done in a shader. The base displacement can be done in a vertex shader and you can probably also use a tessellation shader to increase details when needed. Finally lighting can do a great work in adding details. 5. I still have to check the correctness of your formulas.
  9. apatriarca

    fast sin approx algo not faster than sin() ?

    My problem with volatile was its use inside the loop. In this case the compiler can't rely on the fact the variable has not changed between the various iterations and it has to load&store each time the variable is used. An alternative solution, I think, can be to write to a big array. 
  10. apatriarca

    fast sin approx algo not faster than sin() ?

    The volatile keyword basically prevents any optimization in the loop. Moreover, each loop iteration depends on the previous one which means low pipeline usage in the CPUs and no chance for SIMD auto-vectorization. This isn't a particularly meaningful benchmark and I think it is not representative of the real performances of these functions.   I would simply use sin or sinf. In most cases it should use the correct cpu instruction, eventually also using SIMD ones or treating them as constant expressions.
  11. What video player library you are using on the other platforms?
  12. Why an artist should choose you instead of other people? You are mostly listing your skills, but there is no way to actually understand your level in each skill. Moreover, you are not showing any project you have done and you said you have problems completing your projects. If I were someone looking for a patner for making a project that skill would actually be quite important. Even projects you are not particularly proud of can be important to find someone.
  13. apatriarca

    Calculating used space on a gaming board

    You can subdivide the regions with axis aligned rectangles (it seems the section of your cuts are either vertical or horizontal) and quite easily compute the area of the regions by summing all the areas of the rectangles.  
  14. apatriarca

    Approximating Diffuse Indirect Illumination

    If you do not understand the mathematics (and physics?) of indirect illumination, why are you trying to come up with a real-time algorithm for it? The first step to solve any problem (and thus also creating an algorithm for that) is indeed to understand it in depth. You should have at least looked for algorithms doing the same thing!    I find your description very confusing. I am not sure I understand what you mean by "photon" in your algorithm. A photon is simply light, there is no direct or indirect contribution. It also look quite expensive since you probably need to render your scene for a lot of photons and (I guess) store these render buffers in several textures. You will then need to retrieve all these information in some way in the final pass. 
  15. I personally find your two cons to be actually bigger problems than the pros. I never had much problems with public namespace pollution. I had problems with some code not compiling because I changed what was included in an header file, but if some code break because it relied on some implementation details then that code is buggy. I don't think it is a library fault. It is also a very easy problem to solve. Compile time is instead a very big problem in C++ for me. You should really try to reduce it or it will skyrocket when the project grow bigger. You also spend a lot more time maintaining the code than writing it.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!