Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

SuperVGA

Member Since 10 Sep 2008
Offline Last Active May 16 2013 10:52 PM
-----

Topics I've Started

Nested Projections & Transforms

30 April 2013 - 02:19 PM

Hi guys!
 
I'm at a point with my GUI framework exercise where I'd like to extend with an element that acts as a view into a 3D scene.
My secondmost basic element for now can do rotation, scaling and translations.
I'd like to be able to embed this new element into the more advanced one, meaning my otherwise simple projection-capable element
will be transformed along with its parent in the plane. I want it to be part of the transformation stack.
 
At the same time, I'd like whatever contents of the scene to be rendered onto this new, rectangular element as it normally would.
Do I push the viewport and projection bit attributes? What would be a decent way to accomplish this?
 
Thanks in advance, smile.png


Identifying noises from my rig.

06 March 2013 - 03:47 PM

Hi Guys,

 

I have become aware of ... something emitting a sound from my case, and I wonder what it could be.

 

Usually when I work with graphics or games, (especially when I have disabled vertical synchronization) I can hear noises from my GPU. I've always heard noises from it when it's working, so I don't think that is a big deal.

 

There's not a lot of noise in the room, my speakers are turned off and the loudest noise is from my case fans, which create a constant humming sound, The rest of my machine is relatively quiet (No writes to my SSD, GPU is taking a break).

 

Just ten minutes half an hour ago, I was messing around with SFMT, some code and allocated a lot of memory upon the initialization of a std::vector.

 

A firm 100ms "chirp" sounds upon allocation. But I'm not sure if it's really my DIMMS that produce the noise...

I have consumed a 50cl caffeine-rich beverage an hour ago, but I'm convinced I would hear the noise either way.

I have stripped my code down to the parts that cause the sound (and i do realize that I'm not even using the SFMT library, but this is apparently still making a difference.)

 

Goes "Chirp!"

#include <vector>
#include <cstdlib>
#include <SFMT.h>
 
const unsigned pop_size = 10000000;
const unsigned seed = 12345;

int main(int argc, char* argv[])
{
    sfmt_t sfmt;
    sfmt_init_gen_rand(&sfmt, seed);

    std::vector< unsigned > pop(pop_size, 0 );    
    return EXIT_SUCCESS;
}

 

Noise is lower (how would sfmt interfere with the allocation?)

#include <vector>
#include <cstdlib>
const unsigned pop_size = 10000000;
int main(int argc, char* argv[])
{
    std::vector< unsigned > pop(pop_size, 0 );    
    return EXIT_SUCCESS;
}

 

Does not go "Chirp!" (there is some noise, but it's low and seems to be much shorter). 

#include <vector>
#include <cstdlib>
int main(int argc, char* argv[])
{
    std::vector< unsigned > pop(10000000, 0 );
    return EXIT_SUCCESS;
}

-Removing the allocation silences the unknown noisy component completely during runtime.

 

I compile with -O3 -msse2 (And using SFMT, i also use -DHAVE_SSE2 -DSFMT_MEXP=607)

Changing to O2 does little to change the sound.

 

Now as far as I'm aware, there aren't any mechanical parts prone to moving due to executing my program.

I have two things that I'm curious in finding out:

Why removing SFMT changes the sound of my otherwise independent(?!) initialization; and

What component produces the noise and why.

 

They didn't cover this in either signal processing or CPU architecture at uni, and I'm no hardware expert.

What could be causing this sound?

 

(And yeah, it's sort of a silly concern, and I have no idea where else to post about it smile.png )


Multiply blending with exception of the alpha channel?

03 February 2013 - 02:08 PM

Hi Guys!

 

After having used simple blending techniques together with fragment shader effects that could easily accomplish this,
it somehow seems silly to ask. Although, I'd appreciate if i could, for once (biggrin.png), accomplish something simple with a simple approach.

I'm trying to create an effect identical to the blend mode in photoshop called multiply.

 

I use (GL_DST_COLOR, GL_ZERO) or (GL_ZERO, GL_SRC_COLOR) with Equation GL_FUNC_ADD to accomplish a basic multiply effect.

I thought all channels would be multiplied, maybe they do, but in that case it's like i see the clear color without anything on it,

and as that isn't really stored anywhere, there must be something else I'm doing wrong.

 

If I try to compute the result myself. (given that the transparent regions of src are black with an alpha value of 0.00)

(Rs * Sr + Rd * Dr, Gs * Sg + Gd * Dg, Bs * Sb + Bd * Db, As * Sa + Ad * Da) // - All channels should be treated the same.
// My resulting colour in the transparent region of src, on the grass (Let's say it's 0.5, 0.5, 0.25)
 
// would be
(0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.50 + 0.50 * 0.00, 0.00 * 0.25 + 0.25 * 0.00, 0.00 * 1.00 + 1.00 * 0.00)
// effectively
(0.00, 0.00, 0.00, 0.00) // - which as i see it should be transparent. It comes out black, however.

 

I read somewhere that it's just not doable with ordinary blending, and I guess a nice thing to have here would be a
per-channel glBlendFunc. After not getting the desired result, I immediately resolved to shotgun surgery and tried out all combinations, with no luck.

If I cannot manage to do this, I guess I'd just leave this part as it is, it's not a gamestopper, but it does irritate me a bit. :-)

 

These images should illustrate what I'm going for, - and I must admit, i haven't tried with actual textures yet,
I merely change the alpha component when setting glColour4f(). I expect the result to be similar with texturing.


Src. (What I draw to the colour buffer)

src_small.png

Dst. (What's already in the colour buffer)

dst_small.png

Desired. (I'd really like to see this result)

wanted_small.png

Achieved. (I'm getting this result. sad.png )

unwanted_small.png

 

Have any of you been past this? I guess a common use for texture multiplications would be for lightmaps,
and here using alpha probably won't make much sense, as revealing more of the previous layer only

means approaching a white lightmap value (at which point the surface appears unlit).

I intend to use this for my GUI, however. For simple overlay effects, dialogs and HUDs. (Should become nice and generic. smile.png )

Without lerping between any colour and white, I'd like to be able to have the overlayed GUI element fade out, while still keeping the effect.

Say, I have a red light filter taking up the entire screen, resembling the player having been shot, fading out slowly, and things gradually come back to their original colours.


Multi-level stencil buffers or other ways to cut away child GUI elements?

19 January 2013 - 09:03 AM

Hi everyone!

 

Since I've began implementing my GUI I've known that I wanted to be able to cut away parts of gui elements that are outside the boundaries of the parent element.

I've always just thought: "I'll deal with that through stencils". But now I've found that my approach may be more difficult than so.

 

In this example I have 3 elements to draw (I'll end up not knowing about the number of levels or elements). On the first level, I have one rectangle in which I'd like the contents to be cut if they exceed its bounds.
(Familiar to CSS overflow:false) I also have a triangle which is placed somewhere close to the edge of the screen.

Inside the rectangle, on the next level, I have a circle which lies just on the boundary of the rectangle. It should be "cut in half" once rendered. 

 

stencil_gui_tree.png

It looks like this when rendered:

 

stencil_puzzle.png

 

The rectangle is the only element with "stenciling = true", painting and enabling the stencil buffer before its children are drawn.

 

As the Triangle is drawn after the rectangle. (right after the circle actually, when using a regular recursive approach where an element is rendered, then it's children)

It is completely invisible due to the stencil "created by" the rectangle.

If the circle had its stenciling enabled rather than the rectangle, the circle itself would be completely visible, but the Triangle would still be invisible.

 

I hope this explains my situation.

As possible solutions, I've thought of passing a rectangle to the element fragment shader, allowing discards when the element is outside the bounds. -That might actually be a better approach...

Something else I thought of, still using stencils, is rendering a layer of children sequentially, and then rendering the following layers afterwards (sort of defying the tree structure I have created)

 

I intend to be able to rotate elements as well, which I think seems doable, and something else that would be really cool with this stencil sort of option is if the

child elements would have their fragment alpha multiplied by the ones of the parent in the given screen space coordinate.

This does seem very elaborate for a "simple gui", but I'm sure I can find a way to make it work, although I might have to change the way I accomplish things.

 

If you have any  suggestions or experience with this, you're encouraged to tip in! biggrin.png

 

EDIT: I typed "I have 3 elements to draw" which lead responders to think that it's the only scenario (obviously, because that's what I said!)

Unfortunately, I won't have so much knowledge about the elements and transforms involved...


Are segfaults normal when project hasn't been cleaned for a while?

14 January 2013 - 03:02 AM

Hi everyone,

I'm working on a project from three machines, using one machine most of the time.
Yesterday, after adding a new member variable to a class, the project compiled but then crashed.
Usually, I wouldn't hesitate to take the blame.

It's very-very rare I make the compiler or environment behave wrong.
I code stupid, make things easy for myself when possible.

I tried debugging to find the source of the segfault. I found that it seemingly occurred in std::map::insert(val, key), and traced upwards. Everything had been initialized. Val referenced something created elsewhere, I thought it looked good. Key was a copy since the parameter. I hadn't touched this area of my code for over two months...
There were no dangling pointers (no pointers, even) to be found in my main units, so I thought it had something to do with the member variable. (Being the last change I committed, this should be the prime suspect)

The class that I added the variable to contained an object which in turn contained the std::map, so I thought to myself, that maybe the change in the header file didn't trigger a build of new .os that should depend on it. When I created my own build tool, I didn't check the headers for modifications, and unless I changed the implementation file too, I'd often end up with having to clean build, or everything would crash.

Sure enough, a clean build fixed the error. But is Netbeans supposed to miss a significant change like a new member variable, without recompiling the unit+dependent units?

Do you guys experience this too from time to time? It's been weeks since I last encountered a segfault,
and now I'm worried that perhaps I'm doing something wrong.

PARTNERS