
Advertisement
apatriarca
Member
Content Count
875 
Joined

Last visited
Community Reputation
2365 ExcellentAbout apatriarca

Rank
Advanced Member
Personal Information

Interests
Art
Programming

Function that returns a function pointer
apatriarca replied to ICanC's topic in For Beginners's Forum
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)); } 
An "energy" field simulation with flows and energy production/consumption
apatriarca replied to Alexey Makarov's topic in Math and Physics
Not really interpolation. That's a simple sum over the nonzero functions. 
An "energy" field simulation with flows and energy production/consumption
apatriarca replied to Alexey Makarov's topic in Math and Physics
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 piecewise 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 Bspline basis function is a piecewise polynomial function which is used as the basis for Bspline curve and surfaces. It is defined recursively and they can be defined for any order/degree. The cubic Bspline 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). 
An "energy" field simulation with flows and energy production/consumption
apatriarca replied to Alexey Makarov's topic in Math and Physics
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 Bspline 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). 
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.

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.

Game Engine Containers  handle_map
apatriarca commented on y2kiah's article in General and Gameplay Programming
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. 
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.

fast sin approx algo not faster than sin() ?
apatriarca replied to isbinil's topic in Math and Physics
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. 
fast sin approx algo not faster than sin() ?
apatriarca replied to isbinil's topic in Math and Physics
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 autovectorization. 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. 
Linux: Coding a video player for a game?
apatriarca replied to Zingam's topic in General and Gameplay Programming
What video player library you are using on the other platforms? 
Looking for an artist with ideas for a game.
apatriarca replied to Jaay_'s topic in Hobby Project Classifieds
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. 
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.

Approximating Diffuse Indirect Illumination
apatriarca replied to StanLee's topic in Math and Physics
If you do not understand the mathematics (and physics?) of indirect illumination, why are you trying to come up with a realtime 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. 
Making Your C++ Namespace Solid and FutureProof
apatriarca commented on DemonDar's article in General and Gameplay Programming
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