3D Programming: Experiences and Insights

AI Thread Summary
The discussion centers on experiences and insights related to 3D programming, highlighting various programming languages and APIs like Direct3D and OpenGL. Participants emphasize the importance of understanding foundational concepts such as geometry, lighting, and rendering techniques. They note that while learning 3D programming can be challenging, especially for beginners, it is feasible to study it concurrently with C++. Key advice includes mastering the math behind graphics, understanding GPU architecture, and recognizing the significance of standards and flexibility in design. The conversation also touches on the complexity of 3D engines and the necessity for good design practices, such as standardization and extensibility, to facilitate integration with other software. Overall, the thread offers encouragement for newcomers to explore 3D programming while developing their coding skills.
MurdocJensen
Messages
47
Reaction score
0
Was just wondering if anyone here has tried 3D programming. If you have, what language did you write in, what difficulties did you have, and what did you find interesting about it?

As of now I know of Direct3D and OpenGL, but, if I'm not mistaken, you can use different languages to write shaders for these different APIs. For example, the Cg language can be used to write shader programs for both APIs, while HLSL is used for Direct3D specifically, and GLSL for OpenGL specifically.

That's the extent of what I 'think' I know.
 
Technology news on Phys.org
I very briefly did some exploration working directly with OpenGL, but it seemed like a ton of work to handle things at that level. So then I learned 3D in Java using java3d. I found a tutorial and very diligently followed it step by step. A few days in, I was able to do some cool stuff from scratch.

This was several years ago, so I'm sure a lot has changed. But the key concepts that one should know, like what a "scene graph" is, how to handle lighting, building surfaces with triangles, etc... stuck with me and I think translates from one environment to another.
 
MurdocJensen said:
Was just wondering if anyone here has tried 3D programming. If you have, what language did you write in, what difficulties did you have, and what did you find interesting about it?

As of now I know of Direct3D and OpenGL, but, if I'm not mistaken, you can use different languages to write shaders for these different APIs. For example, the Cg language can be used to write shader programs for both APIs, while HLSL is used for Direct3D specifically, and GLSL for OpenGL specifically.

That's the extent of what I 'think' I know.

I used to do this kind of thing daily in a job. Here's my advice:

Understand the math

Things involving geometry like:

Convex Hulls, different types of projections (orthographic,perspective),Splines in different dimensions (curves,surfaces,volumes),other interpolation techniques (Catmull-rom,Hermite,etc),matrix and vector techniques, and quaternions are things you should know.

Although you don't have to do this anymore, its helpful to understand triangle rendering, sampling techniques (texture sampling that is) things like filtering (anti aliasing) and if you're keen ray-tracing and radiosity (not required by any means though).

Understand the architecture of GPU's and standards

DirectX and OpenGL do have differences but the fact is that rendering a triangle in OpenGL is going to be the same as rendering one in DirectX and both standards are often motivated by the same ideas (both have a matrix pipeline, both have shader standards and so on).

One thing that is different is when you get into extensions (like in OpenGL). When a GPU adheres to a standard its guaranteed to have all of the functionality in that standard. But GPU cards also offer extra things that are on top of the standard. One example is with Doom 3: The nVidia cards like Geforce 2 offered a texture operation called DOT3 which is basically a vector dot product operation. You use this for the normal mapping technique which takes the dot product of a lighting vector and another texture to give the sense that a surface "looks like a complex surface" rather than a plane.

Using something like Cg can greatly speed up development time and I don't hesitate in recommending something like that.

One last piece of advice: simulation engines (whether its a game engine like Unreal or some scientific visualization package) are complex systems. When you're writing these kinds of things try to think about the right kind of interfacing/encapsulation that say a renderer should have and say a geometric primitive should have.

For example a geometric primitive should have a function that exports its geometric structure to triangles since that is the standard primitive that GPU's use. You would probably also benefit by adding a standardized ray-intersection function that returns the point of intersection and the reflection vector from that surface.

When GPU's offer support for non-linear objects (ie objects other than triangles) like for example splines, then you can add something in your renderer to override behaviour for spline rendering.

Its a lot to take in I know, but if you get your hands dirty, you'll understand what I mean and you'll no doubt get better with progression of time.
 
Awesome. Thanks for the great information.

Would it be silly to think that I could learn the basics of 3d programming while still working my way through c++? Which is to say I'm still a beginner in c++, but I know the basics of functions and variables and different statements. Did you find that knowledge of a prior knowledge helped out a lot?
 
MurdocJensen said:
Awesome. Thanks for the great information.

Would it be silly to think that I could learn the basics of 3d programming while still working my way through c++? Which is to say I'm still a beginner in c++, but I know the basics of functions and variables and different statements. Did you find that knowledge of a prior knowledge helped out a lot?

Absolutely, I see no problem learning 3D specific stuff, while you hone your skills in programming.

There are quite a few open source projects that are 3D engines that are well designed and coded.

One piece of advice though: 3D engines are complex projects. If all you do is display an object rotating in a window you could get away from using something like GLUT (OpenGL Utility Library), but if you want to use your 3D code as part of something else (like say a game, 3D editing software like 3DSMAX, or for visualization for some other purpose), then you will need to design something that is complete, yet flexible enough to do what you want to do and integrate into your other code.

If you asked my what is the most important thing in design, I would say standardization and flexibility. It may seem like an oxymoron answer but I'll explain it.

In programming we typically have standards. It could be a network protocol like FTP or HTML, or it could be a standard for GPU rendering primitives (ie triangles).

You have to be aware of current standards when you are designing things. If you want to take advantage of the hardware on graphics cards, you need to know the standards. You are already aware of this since you know about OpenGL and DirectX. Explore these standards to get a feel for the standard rendering process and use that to design your appropriate data structures.

The next is flexibility. An example of this is say a primitive class and a class factory. Your primitive class will convert your geometric object to a set of triangles which the renderer will use to render the object on the screen. But the real reason to use a primitive class is to allow you to use custom objects where say in a Sphere class you use parametric formula to generate triangles with some specified resolution level.

Now the class factory part helps you have a system that is extendable. For example if you have a plugin system that is integrated with a class factory system, you can for example create a SDK (software development kit) that allows other users to extend the system without needing to touch the main engine executable.

The kind of extensibility I'm talking about is crucial to any decent application. You learn this kind of thing by looking at standards like COM, OLE, CORBA and similar frameworks.

While you are learning C++, I would look at something like COM and look at the main interfaces that are used. You will see a lot of concepts that are the result of designers getting better with newer systems.

I wish you the best of luck. Sometimes you will hit walls and bang your head, but there's nothing like the feeling of getting everything to work and seeing the result of a program you made actually work the way it was intended.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top