Jump to content
  • Advertisement
Sign in to follow this  
rockz

Programming a renderer

This topic is 4952 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im new with programming i start learn some languages in this year but im not new with 3d. I wanna know what i need to programming a renderer (i know its difficult but i can start =P). I start with c++ and opengl but someone said to me that opengl is only a scanline render, if i wanna add some features like a raytrace or a global illumination, can i use opengl and c++? Or i need other thing to make this, like a library? I found some stuffs about renderer, raytrace but the basic, what applications, softwares, librarys and other stuffs i need to start programming a renderer i dont found. Please someone help me. Sorry for my english.

Share this post


Link to post
Share on other sites
Advertisement
Raytracing works backwards by starting at your eye, and moving outward until they intersect with something. For any light sources, you can generate a normal vector from the light source to the intersection point, calculate the dotproduct between that and the normal of the intersection point, and use that to shade it. You can also cast a ray from the intersection point to the light to see if there's anything casting a shadow on that point. For reflections, reverse your ray and rotate it around the intersection point's normal, and continue. You repeat this for every pixel. You can also use multiple rays per pixel and average them together to create a nice smooth antialiased image.

You can do all that with just C++, although you'll want some way to see what you've done. If you want to use OpenGL to display the result, that's fine. It won't be so much rendering as drawing little dots on the screen for each of the rays you calculated.

Share this post


Link to post
Share on other sites
I use c++ to calculate the rays (reflections, intersections, etc.) of light source and i use opengl to draw pixel per pixel, is it?

Share this post


Link to post
Share on other sites
OpenGL isn't particularly good at drawing things pixel by pixel, unless you render to a texture and then render that. If you want to have manual control of the pixel plotting, go with something like SDL or DirectDraw (or the non-3d part of DirectX Graphics). So, you CAN do it with OpenGL, it's just harder to do than if you do it with other APIs.

My advice: if you're going to do something OTHER than polygon graphics, then use SDL for the actual rendering.

Share this post


Link to post
Share on other sites
The only way to get a 3d scene and render a image like a .tga is make this image pixel per pixel?

Share this post


Link to post
Share on other sites
Quote:
Original post by Oberon_Command
OpenGL isn't particularly good at drawing things pixel by pixel, unless you render to a texture and then render that. If you want to have manual control of the pixel plotting, go with something like SDL or DirectDraw (or the non-3d part of DirectX Graphics). So, you CAN do it with OpenGL, it's just harder to do than if you do it with other APIs.

My advice: if you're going to do something OTHER than polygon graphics, then use SDL for the actual rendering.


I think it's easier to do in OpenGL. You don't have to use textures in OpenGL to plot pixels. Just render with the GL_POINTS primitive. Drawing pixel by pixel is annoying no matter what you use. I find that DirectDraw / SDL is worse than OpenGL. You have to lock a surface and pass data through a pointer. Locking surfaces is very slow too. I recommend OpenGL / Direct3D for everything, and using DirectDraw/2D SDL graphics for absolutely nothing.

Rockz, I implemented a raycaster two years ago using OpenGL (no reflections, just direct illumination and shadows) with GL_POINTS and I might be able to dig up if you want to it.

Share this post


Link to post
Share on other sites
If you are just starting 3D programming I suggest you decide exactly what kind of renderer you want to make.

A ray tracer is typically not a feature incorporated into a functional renderer. It is a complete means to draw 3D scenes. If you want to make a ray tracer all you need is a library to draw individual pixels. I haven't worked with SDL but it sounds like a good option for that. The rest is up to your code.

If you want to create a scanline renderer you have two options. You can create one from scratch in which case your requirements are the same as with the ray tracer, or you can use the OpenGL or DirectX library to take advantage of video acceleration hardware (video card).

If you don't know the difference between scanline rendering and ray tracing I suggest you Google them before starting.

Share this post


Link to post
Share on other sites
SDL doesn't really have a function to draw pixels.

It goes:

- Lock surface
- Figure out where your pixel is - buffer+x+y*pitch
- Copy bpp/8 bytes to the pixel's address.
- Unlock surface.

Share this post


Link to post
Share on other sites
Quote:
Rockz, I implemented a raycaster two years ago using OpenGL (no reflections, just direct illumination and shadows) with GL_POINTS and I might be able to dig up if you want to it.


Please it help me very much.



Share this post


Link to post
Share on other sites
It took me a while to find it... but I found it. Make sure to look at the readme.

ray caster

By the way... I'm embarrassed looking at my coding style from back then. Also keep in mind that this NOT an optimal implementation. And keep in mind that this is not an optimal implementation. I probably won't be paying attention to this thread, so if anything goes wrong, just PM me.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!