Showing posts with label 3d. Show all posts
Showing posts with label 3d. Show all posts

Monday, September 17, 2012

Update: More raytracer images

I haven't posted in a while. Today I will not post much except some more of images of my C# raytracer. I have added reflection, transparency, and textures.
Here are the images:

Monday, August 27, 2012

C# raytracer from scratch

I am building a complete C# raytracer. It uses my own math library and it will be part of the Disque Engine. The raytracer is close to completion. Right now it can render the basic shapes such as spheres, cubes, cones, cylinders, disks, rectangles, and triangles. I am also trying to implement a ply file reader so that I can render the Stanford bunny or other standard models. After I finish the raytracer I will post tutorials on how to build your own.

Here are some samples(time format is h:m:s.ms) :

Simple image rendered at 256 samples per pixel, total render time: 00:09:43.838

An image of 1000 random spheres rendered at 121 samples per pixel, total render time: 02:13:45.002



I will provide more samples as the raytracer advances.

Thursday, July 12, 2012

How to create a sphere programmatically in XNA


I "discovered" an easy but silly way to create a sphere programmatically in XNA, it is very simple. The idea came to me when I wanted to create huge planets in XNA to make an endless map. Any way the method is very simple, I don't know If someone knows it or it was used before, but till now it is working and efficient. You can control the resolution or how "round" the sphere is.
The code is written in C# with microsoft's XNA 4.0.
Here is a high resolution sphere in wire frame:
The sphere contains 8100 vertices and 48600 indices.

Code:

    public class Sphere
    {
        VertexPositionColor[] vertices; //later, I will provide another example with VertexPositionNormalTexture
        VertexBuffer vbuffer;
        short[] indices; //my laptop can only afford Reach, no HiDef :(
        IndexBuffer ibuffer;