Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Nov 2005
Offline Last Active Yesterday, 07:59 PM

#5183346 Rendered Object disappears under Perspective Projection

Posted by dpadam450 on 27 September 2014 - 02:46 PM

Your near plane is 1.0, your object is at 0.0    meaning it is behind your eyeball. Change your z = 0.0 for your verts to -10

#5183213 matrix/coordinates?

Posted by dpadam450 on 26 September 2014 - 03:53 PM

I skipped over your initial problem. If you are trying to render 2D with openGL  You dont want persepctive (which implies a 3D world) you want orthographic.


Should be a function something like that. Depth will still matter but you can work in 2D. Ortho(0,screenwidth, 0, screenheight)  <-- allows you to call glVertex3f() with 2d pixel coordinates + some z-depth.


With Ortho there is no perspective division to warp stuff away from the camera. The z value doesnt effect perspective, the input x,y  will be the output x,y

#5183182 Reading a texture inside if statement

Posted by dpadam450 on 26 September 2014 - 12:33 PM

No idea what either of you are talking about. You can sample a texture how ever you want whenever you want. Are you suggesting "stage3d" (no idea what this is), will not let you do it? If so then maybe that's a restriction on that language.

#5182711 Nvidia GI Hardware Support

Posted by dpadam450 on 24 September 2014 - 01:45 PM

I saw the Nvidia moon landing GI demo and the corresponding GI demo on the Nvidia youtube channel.


They mention this is coming with their new gpu, is this some hardware supported feature? Does anyone know how it will integrate with other software if that is the case?

Also, in the demo with the sphere, they show the voxel data. I'm assuming that the pixel shader performs a raycast into the voxel data to find the closest voxel? I've never messed with voxels before. I'm not sure how that works. Is the data on the gpu a 3d texture and it will just ray cast  from the fragments world position + normal until it hits a non blank texel in the 3d texture and then use that information?

If so, wouldn't that 3d texture be pretty big? for that small scene it looks like it is about 64x64x64 if it is a 3d texture. Maybe I just don't know enough about voxels. I remember the latest Crysis tech pdf mentioning their GI stuff. Were they doing the same type of thing then?

#5179470 Rendering large meshes in OpenGl

Posted by dpadam450 on 10 September 2014 - 08:15 PM

Also depends on how big the object is on screen. If you render a million triangles that are drawing to 1/50th of the screen, tons of pixels will be drawn too and will incur very bad performance.

#5179439 screen view to 3d space

Posted by dpadam450 on 10 September 2014 - 03:57 PM

Yes. postive z (0,0,1) is pointing from your montiro towards your head.  (0,0,-1) is from head to monitor. So you start looking down -1.

#5166221 (Super) Smart Pointer

Posted by dpadam450 on 11 July 2014 - 09:42 AM

Imagine an RTS game, you have 20 marines shooting at one building and it blows up. All the marines have AI pointers "targetedEnemy" pointing at the building. The building blows up and is removed from the world and deleted.

Is there any good design for this?----> Updating the 20 marines "targetedEnemy" pointers that is to be NULL so they can go looking for new enemies?

shared_ptr doesn't seem to work because that is reference counted. It WOULD work if I decide that the marine AI checked their enemies health and if health < 0, call reset on the pointer. After the 20 marines all call reset() then the object would officially be deleted.

The other option I thought of was creating a new pointer type (unless one exists), where anytime I deconstruct a copy of the pointer, it has maintainted a list of people pointing to it and sets all pointers in the list to NULL.

Something like this:


template <class T>;
class SuperPointer


       T*  data;
       vector<T**> owners;
       ~SuperPointer(){ // loop through owners setting them to NULL };


Anyone can essentially delete the data, it will update all respective pointers who are pointing to the data. Maybe there is a better way to think about this or there is some other pointer that does this?

#5165735 c++ function pointers

Posted by dpadam450 on 08 July 2014 - 11:38 PM

Going to apply that to my actual code now..........does anyone know what that actually unrolls into? I don't mind typdef's for this case, I just hate typdef everything to a typdef item with a a typdef vector etc. I usually avoid them for readability.

// Obviously this doesnt work. Just curious what the signature without the typdef would be
int (*function_type)(int) GiveMeFunctionPointer()





#5165731 c++ function pointers

Posted by dpadam450 on 08 July 2014 - 11:11 PM

8 Years never needed a function pointer and I can't find a good example.

#include <iostream>
using namespace std;

// Basic Function
int AddOne(int a)
    return a + 1;

// I want a function that returns a pointer to AddOne so I can call it

// This declaration does not work, what is the delcaration to return the function as a pointer.
int (*)(int) GiveMeFunctionPointer()
    return &AddOne;

void main()
    int (*foo)(int) = &AddOne; // Cool foo is a pointer to a function taking an int

    int (*foo2)(int) = GiveMeFunctionPointer(); // This is what I want to use...

    cout << foo(2);

#5140338 Uniform grid traversal

Posted by dpadam450 on 19 March 2014 - 10:04 AM

the ray starts to intersect a wall of a box and exists another wall of that box. Do some ray to plan intersection, determine if its the left up down etc wall, from there you know the next box this ray is going to go into.

#5140330 Assets for tech demos

Posted by dpadam450 on 19 March 2014 - 09:33 AM


but me being a good 3D modeller isn't going to improve how good I am at writing an efficient renderer for it, or implementing dynamic illumination effects.

This is wrong thinking. I'm one of the few (skilled) artists and programmers out there. It blows my mind how any graphics engineers or just game engineers have 0 art abilities. They miss the big picture.

#5139110 Debugging Graphics

Posted by dpadam450 on 14 March 2014 - 06:12 PM


and debugging by guessing never works out.

It always works out. Beginning graphics is all about guessing

My biggest takeaway from when I started, was never program stuff without source control. Once you break something especially in graphics, it could take hours. Don't have people put everything into the scene. Create a box first, apply a texture second, put 1 more item, put another texture. Verifying each time that it works helps to know exactly what line is breaking it. Then its a matter of taking the breaking code and moving it around to see if it works in different areas.

#5139105 Depth pre-pass: does OpenGL still execute fragment shader if depth not writte...

Posted by dpadam450 on 14 March 2014 - 05:44 PM


does OpenGL still execute fragment shader if depth not written and color mask is GL_NONE?


And what exactly did I say......... I will add you to the list of people I choose not to help, which will be 1 person for the last 8 years I've been on here.

I gave you some logical thinking which is: who cares. If the GPU does or doesn't run the pixel shader, then whatever shader you have bound wont run anyway (Even if its 1 million executions). If the contrary to that is it does run, then give it the simplest shader possible. Same result, and you don't even need to know the answer to your question................because it doesn't matter. Its either going to execute your 0 or 1 instruction pixel shader or not. Its out of your control, but if you assume it has to run a pixel shader, then you are safe. NOT TO MENTION it could be vendor/card specific under the hood to decide to use the pixel shader or not.

How hard is if for you to write a pixel shader that does 20 texture fetches with glDrawBuffers(GL_NONE) and see if your performance is horrible.....well then its running your pixel shader......


Do you have a problem with reading comprehension?

When people (who work in the industry already) reply to you and give you a decent answer and tell them they are too stupid that they can't even read your question, so they shouldn't help you.....

#5139087 Depth pre-pass: does OpenGL still execute fragment shader if depth not writte...

Posted by dpadam450 on 14 March 2014 - 04:45 PM

Kind of a useless question.

If it does execute: then keep your fragment shader as gl_FragColor = vec4(0,0,0,0);  OR you may not even need it. leaving a blank main() that returns immediately even though it is executed.

If it doesn't execute for GL_NONE: then keep the same stripped down fragment shader. It just wont run.....

I don't believe you can have a shader object without a vertex + pixel shader. Not sure though.

#5138147 Same model, different UV's

Posted by dpadam450 on 11 March 2014 - 11:39 AM

Make sure when dealing with GL_TEXTURE matrices, that each texture coord has its own matrix. glActiveTexture(GL_TEXTURE0 - 8) you can set matrices for all of those, so make sure if you do that you reset them or all your textures will get F'd.