random hemisphere (tlrcam related

Discuss stuff not about Indigo.
User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Mon Sep 10, 2007 12:36 pm

ok, new copy of TLRcam, this time the file format is a bit different, and the phong works. its also got some minor speed increases in stuff like normalization. oh, and the camera model used is a thin lense camera which can simulate spherical distortion (it was actualy a complete accident).
Attachments
tlrcam.zip
TLRcam
(95.68 KiB) Downloaded 192 times
a shiny monkey is a happy monkey

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Thu Sep 13, 2007 1:02 am

Image

new Version: this one has an accelerator tree and has memory issues solved. i've created images as large as 2000*2000 (didnt try any larger). the new camera types can be auto (in which case the second double is replaced by a point, manual, in which there is a second double, and simple, which has no dof, even though the first double is still there.
Attachments
tlrcam.zip
(411.82 KiB) Downloaded 427 times
a shiny monkey is a happy monkey

User avatar
zsouthboy
Posts: 1395
Joined: Fri Oct 13, 2006 5:12 am

Post by zsouthboy » Thu Sep 13, 2007 1:08 am

oodmb:

Why the 4x increase in filesize between the last two versions you posted?

Is the last one compiled in debug mode?

User avatar
Kram1032
Posts: 6649
Joined: Tue Jan 23, 2007 3:55 am
Location: Austria near Vienna

Post by Kram1032 » Thu Sep 13, 2007 1:32 am

looks pretty good :D

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Thu Sep 13, 2007 3:30 am

the new one has a scene file in it called monkey.tlr and scene.tlr (monkey is the newest picture and scene is the cornel box) . it also has a .bat that you should edit manualy if you want to load monkey or render a large image. to edit the .bat open it up in notepad and change the first line's jdk to the location of your newest downloaded jdk

Code: Select all

@set javadir="C:\Program Files\Java\jdk1.5.0_09"
@set mem=1G
@%javadir%\bin\java -Xmx%mem% -Xss200k -server -jar TLRcam.jar %*
@if %errorlevel% neq 0 pause
a shiny monkey is a happy monkey

User avatar
Kram1032
Posts: 6649
Joined: Tue Jan 23, 2007 3:55 am
Location: Austria near Vienna

Post by Kram1032 » Thu Sep 13, 2007 3:33 am

I saw it, already^^

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Sun Sep 16, 2007 1:26 am

hey, what do people usualy do about normal smoothing in an unbiased renderer? my method doesnt seem to work.
a shiny monkey is a happy monkey

User avatar
zsouthboy
Posts: 1395
Joined: Fri Oct 13, 2006 5:12 am

Post by zsouthboy » Sun Sep 16, 2007 6:09 am

You should be able to simply interpolate across a tri.

What are you doing now?

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Sun Sep 16, 2007 7:20 am

interpolating across a tri. the only problem with that is that because in a diffuse mat, the rays are getting shot at completely random angles, sometimes they go under the actual normal and within the mesh so that i have to check them with the actual normal and reshoot them if they are wrong. this doesnt seem to create the smooth look that normal smoothing is supposed to accomplish
a shiny monkey is a happy monkey

User avatar
zsouthboy
Posts: 1395
Joined: Fri Oct 13, 2006 5:12 am

Post by zsouthboy » Sun Sep 16, 2007 12:40 pm

Consider me confused then.

Ray:
Camera -> into some tri -> if normal smoothing on, ray is bounced in a direction that is weighted by the surrounding normals

Even though diffuse mats bounce in random directions anyway, it's important that they bounce in the correct *spot*, and not necessarily the correct "direction" - with smoothing on, rays will end up bouncing slightly in front of or slightly behind of the defined mesh.

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Mon Sep 24, 2007 4:59 am

i got tlrcam to compile to a .exe and it might be a bit faster depending on your computer. i think it still might depend a little on some java stuff, but it seems to be mostly binary and stuff.

this version has a new path tracing algorithm that i am eventually going to add MLT. the new algorithm mutates a little slower but converges faster so the speed differences you notice between the older versions and this versions you can not measure in seconds/mutation

because of the issue of having time to write a scene api type thing i am going to include the scene loader source. its sorta legible if you know java.

note: i realy realy want to avoid legal issues (my parents are lawyers) so please dont use this code for anything until i open source the program. you should be able to wait a couple more months.

Code: Select all

package ThinLenseReflex;
import java.util.Vector;
/**
 * Thin Lense Reflex
 *
 * Description: java unbiased renderer
 *
 * Copyright: Copyright (c) 2007
 *
 * author Matthew Mirman version 0.1b
 */
public class Loader {
  public static Tracer Loader(int X, int Y, String path, String imagePath, int osi) {
    Camera bounce = new SimpleCamera();
    Vector<TreeRoot> jam = new Vector<TreeRoot> (0, 1);
    MaterialVector mats = new MaterialVector();
    try {
      Parser scene = new Parser(path);
      while (true) {
        String a = scene.getNextToken();
        if (a.equals("o")) {
          String b = scene.getNextToken();
          if (b.equals("sphere")) {
            String name = scene.getNextToken();
            jam.add(new PrimitiveObject(new SpherePrim(scene.getNextDouble(), new Point3(scene)),
                               mats.findMat(name)));
          }
          if (b.equals("mesh")) {
            Vector<Double> verts = new Vector<Double> (0, 3);
            Vector<Double> norms = new Vector<Double> (0, 3);
            Vector<Integer> tris = new Vector<Integer> (0, 7);
            Vector<Material> innermats = new Vector<Material> (0, 1);
            int currentMat = -1;
            String c = scene.getNextToken();
            try {
              while (!c.equals("}")) {
                if (c.equals("v")) {
                  verts.add(new Double(scene.getNextDouble()));
                  verts.add(new Double(scene.getNextDouble()));
                  verts.add(new Double(scene.getNextDouble()));
                }
                else if (c.equals("vn")) {
                  norms.add(new Double(scene.getNextDouble()));
                  norms.add(new Double(scene.getNextDouble()));
                  norms.add(new Double(scene.getNextDouble()));
                }
                else if (c.equals("mat")) {
                  String name = scene.getNextToken();

                  currentMat++;
                  innermats.add(mats.findMat(name));
                  System.out.println(mats.m.get(mats.get(name)).name);
                }
                else if (c.equals("f")) {

                  tris.add(new Integer(scene.getNextInt() - 1));
                  tris.add(new Integer(scene.getNextInt() - 1));
                  tris.add(new Integer(scene.getNextInt() - 1));
                  tris.add(new Integer(scene.getNextInt() - 1));
                  tris.add(new Integer(scene.getNextInt() - 1));
                  tris.add(new Integer(scene.getNextInt() - 1));
                  tris.add(new Integer(currentMat));
                }
                c = scene.getNextToken();
              }
              Mesh prick = new Mesh(verts, norms, tris, innermats);

              //Octree tar=new Octree(new Vector<TreeRoot>( prick.meshBreak()), prick.getBounds());
             // jam.add(tar);
             jam.addAll(prick.meshBreak());
            }
            catch (Exception e) {
            }
          }
        }
        else if (a.equals("m")) {
          mats.read(scene);
        }
        else if (a.equals("camera")) {
          System.out.println("cam");
          String b = scene.getNextToken();
          if (b.equals("auto")){
            Point3 origin = new Point3(scene);
            Point3 destination = new Point3(scene);
            Vector3 dir= new Ray(origin, destination).Direction.normalized();
            Vector3 up=new Vector3(scene).normalized();
            bounce = new ThinLenseCam(origin,
                                      dir,
                                      up,
                                      scene.getNextDouble(),
                                      new Vector3(origin, new Point3(scene)).norm(),
                                       X, Y,
                                      scene.getNextDouble());

          }else if(b.equals("simple")){

            Point3 origin = new Point3(scene);
            Point3 destination = new Point3(scene);
            bounce = new SimpleCamera(origin,
                                      new Ray(origin, destination).Direction.normalized(),
                                      new Vector3(scene).normalized(),
                                      scene.getNextDouble(),
                                      scene.getNextDouble(), X*osi, Y*osi,
                                      scene.getNextDouble());

          }else{


            Point3 origin = new Point3(scene);
            Point3 destination = new Point3(scene);
            bounce = new ThinLenseCam(origin,
                                      new Ray(origin, destination).Direction.normalized(),
                                      new Vector3(scene).normalized(),
                                      scene.getNextDouble(),
                                      scene.getNextDouble(), X*osi, Y*osi,
                                      scene.getNextDouble());

          }
        }
      }
    }
    catch (Exception e) {
    }
    return new SimpleTracer(RenderBegginer.X,RenderBegginer.Y, jam, bounce, osi);
  }



}

class MaterialName {
  public Material m;
  public String name;
  MaterialName() {
  }
}

class MaterialVector {
  Vector<MaterialName> m = new Vector<MaterialName> (1, 1);
  public void add(MaterialName p) {
    m.add(p);
  }
  public void read(Parser scene) throws Exception{
    System.out.println("mat");
    MaterialName mat = new MaterialName();
    mat.name = scene.getNextToken();
    String type = scene.getNextToken();
    if (type.equals("emit")) {

      Texture diffuse = new TexSolid(Colour.black);
      Texture reflect = new TexSolid(Colour.black);
      Texture refract = new TexSolid(Colour.black);
      double gloss = 0;
      Colour m2=new Colour(scene);
      Texture emit = new TexSolid(m2);
      mat.m = new Material(diffuse, reflect, refract, emit,
                               gloss, true);
      scene.getNextToken();
      System.out.println("completed mat "+m2.toString()+"   "+mat.name);
      add(mat);
    }else{
      Texture diffuse = new TexSolid(Colour.black);
      Texture reflect = new TexSolid(Colour.black);
      Texture refract = new TexSolid(Colour.black);
      Texture emit = new TexSolid(Colour.black);
      double gloss = 0;
      while (!type.equals("}")) {
        if (type.equals("d")) {
          diffuse = new TexSolid(new Colour(scene));
        }
        if (type.equals("rl")) {
          reflect = new TexSolid(new Colour(scene));
        }
        if (type.equals("rf")) {
          refract = new TexSolid(new Colour(scene));
        }
        if (type.equals("em")) {
          emit = new TexSolid(new Colour(scene));
        }
        if (type.equals("g")) {
          gloss = scene.getNextDouble();
        }
        type = scene.getNextToken();
      }
      mat.m = new Material( diffuse, reflect, refract, emit,
                            gloss, false);

      System.out.println("");
      System.out.println("completed mat "  + "   " +
                         mat.name);
      add(mat);
    }
    /*
    if (type.equals("diff")) {
      mat.m =new DefaultMat(new BSDF(scene));
      Colour m2=new Colour(scene);

      System.out.println("completed mat "+m2.toString()+"   "+mat.name);
      add(mat, m2);
    }
    else if (type.equals("emit")) {
      mat.m = new Emmiter();
      Colour m2=new Colour(scene);

    System.out.println("completed mat "+m2.toString()+"   "+mat.name);
      add(mat, m2);

    }
    else if (type.equals("phong")) {
      mat.m =new DefaultMat(new BSRDF(scene));
      Colour m2=new Colour(scene);

    System.out.println("completed mat "+m2.toString()+"   "+mat.name);
      add(mat, m2);

    }*/

  }
  public Material get(int index) {
    return m.get(index).m;
  }

  public Material findMat(String s) {
    for (int i = 0; i < m.size(); i++) {
      if (m.get(i).name.equals(s)) {
        return m.get(i).m;
      }
    }
    return null;
  }
  public int get(String s) {
    for (int i = 0; i < m.size(); i++) {
      if (m.get(i).name.equals(s)) {
        return i;
      }

    }
    return -1;
  }

  public Material[] getArray() {
    Material[] list = new Material[m.size()];
    for (int i = 0; i < m.size(); i++) {
      list[i] = m.get(i).m;
    }
    return list;
  }
  }
Attachments
tlrcam.zip
not the exe version - that was too big, i'll post that somewhere else
(505.32 KiB) Downloaded 173 times
a shiny monkey is a happy monkey

IanT
Posts: 153
Joined: Fri Aug 25, 2006 3:13 am

Post by IanT » Mon Sep 24, 2007 5:06 am

Whooooa .. you've been making some excellent progress since I last looked :) Keep it up...

Ian.

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Mon Sep 24, 2007 5:08 am

can anybody suggest a file uploader i can use to post my exe. its 12 mb and too big for this forum, and my website has been put down by the man (who wants money).
a shiny monkey is a happy monkey

IanT
Posts: 153
Joined: Fri Aug 25, 2006 3:13 am

Post by IanT » Mon Sep 24, 2007 5:08 am

interpolating across a tri. the only problem with that is that because in a diffuse mat, the rays are getting shot at completely random angles, sometimes they go under the actual normal and within the mesh so that i have to check them with the actual normal and reshoot them if they are wrong. this doesnt seem to create the smooth look that normal smoothing is supposed to accomplish

Sorry, I meant to reply to this one...

What I do is just reject the path if it goes underneath the geometry. Maybe not the best way but no problems with smoothing artifacts (well, smoothing artifacts that aren't caused by too rough a mesh anyway)

Ian.

User avatar
oodmb
Posts: 271
Joined: Thu Oct 26, 2006 5:39 am
Location: USA
Contact:

Post by oodmb » Mon Sep 24, 2007 5:11 am

i do that too, except rather than rejecting the path, i reshoot it about 50 times till it works (gets slow and bugy in theory with smoothed ultra reflective surfaces). i might have solved my problem, but i dont think it's solved fully, i realy dont know. its alot harder to tell at this point.
a shiny monkey is a happy monkey

Post Reply
85 posts

Who is online

Users browsing this forum: Bing [Bot] and 70 guests