Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - aZen

Pages: 1 ... 3 4 [5] 6 7
61
Projects / Re: VoxelShop - voxel editor
« on: December 03, 2013, 03:27:22 pm »
Before I start implementing complicated optimization techniques (I have some cool stuff coming up!), I'd like to ask a few questions.

The following shows profiling done for the same scene rendered with a small frame buffer (200 x 200) and a large frame buffer (2000 x 1000). About the same amount of triangles are visible for both renders. The first number shows the absolute time spend, the second number indicates how often this code snipped was executed, etc.

Code: [Select]
buffer.clear([COLOR]); : 1425 / 564 = 2
buffer.display(gr); : 1283 / 564 = 2
drawLinkedOverlay((Graphics2D) buffer.getGraphics()); : 1281 / 564 = 2
buffer.update(); : 1300 / 564 = 2
world.draw(buffer); : 4396 / 564 = 7
world.renderScene(buffer); : 5895 / 564 = 10

buffer.display(gr); : 1928 / 565 = 3
drawLinkedOverlay((Graphics2D) buffer.getGraphics()); : 2830 / 565 = 5
buffer.update(); : 6940 / 565 = 12
buffer.clear([COLOR]); : 8080 / 565 = 14
world.draw(buffer); : 13954 / 565 = 24
world.renderScene(buffer); : 18313 / 565 = 32

Interestingly the Framebuffer.clear(Color) method "blows up". I was thinking that is must be possible to buffer the content and restore it much faster (e.g. with a low level memcpy). Is this something that you could help me with? Since this is independent of the amount of triangles in the scene (tested that), it's something I'd like to look at first.

Which times do you think will go down (and by how much) if I reduce the overall triangle count (while keeping the exact same rendering area), i.e. low poly model version?

62
Projects / Re: VoxelShop - voxel editor
« on: December 03, 2013, 12:31:51 pm »
Made two new screenshots (click to enlarge):

 

 

And here the 240*y versions:

 

 

63
Projects / Re: VoxelShop - voxel editor
« on: November 27, 2013, 10:40:39 pm »
I'm using two for each project and they will be rather small. So if you care about these things, make sure that they will look good in 240*y.

Ok, great. I'll get back to you!

64
Projects / Re: VoxelShop - voxel editor
« on: November 26, 2013, 10:47:00 pm »
Sure, will get back to you in a few days when I have access to my laptop again. Is there a limit to the amount of screenshots?

65
Support / Re: Side detection for cube
« on: November 22, 2013, 12:25:59 am »
Considering that you're using voxel and you probably want to be efficient, I'd just generate a walking "grid"  for each hight layer of voxel. You can generate it on the fly and it should be extremely fast and reliable. Let me know if you need further clarification! Btw You should use a ray test to prevent clipping through corners.

66
Support / Re: Side detection for cube
« on: November 21, 2013, 03:43:35 am »
Cool! Do you have anything to show yet?

The code I posted is much more efficient than generating more objects and testing collision. I'm actually not sure how your approach works...?

I've written a voxel editor with jpct, so if you have any questions feel free to ask! I should know most quirks =)

67
Support / Re: Side detection for cube
« on: November 21, 2013, 12:38:30 am »
Here you go:

Code: [Select]
        SimpleVector dir = this.getDirection(point.x, point.y);
        Object[] res = world.calcMinDistanceAndObject3D(camera.getPosition(), dir, 10000);
        if (res[1] != null) { // something hit
            Object3D obj3D = ((Object3D)res[1]);
            Voxel hitVoxel = data.getVoxel(world.getVoxelId(obj3D.getID()));
            if (hitVoxel != null) {
                voxelPos = hitVoxel.getPosAsInt();
                // find collision point
                SimpleVector colPoint = camera.getPosition();
                dir.scalarMul((Float)res[0]);
                colPoint.add(dir);
                colPoint.sub(obj3D.getOrigin());
                // find side that it hits
                int lastActiveSide = 0; // assume it's zero (no need to check)
                float dist = colPoint.distance(directionVectors[0]);
                for (int i = 1; i < directionVectors.length; i++) {
                    float tempDist = colPoint.distance(directionVectors[i]);
                    if (dist > tempDist) {
                        dist = tempDist;
                        lastActiveSide = i;
                    }
                }
            }
        }

For the direction I use Interact2D.reproject2D3DWS

Please let me know if you have any questions.

Just curious, what are you up to?

68
Projects / Re: VoxelShop - voxel editor
« on: November 14, 2013, 03:06:31 pm »
In case that you haven't done this already, you can try to set


http://www.jpct.net/doc/com/threed/jpct/Config.html#useMultiThreadedBlitting


to true. It might help, it might not. It highly depends on the system.

Ah, yeah I had experimented with that setting in the past, but didn't really see any benefit. Will try again and report back. It sounds like it's exactly what I need.

Edit: I think it might have caused some issues, but it's definitely smoother. I've enabled it for now and will see what people report.

69
Projects / Re: VoxelShop - voxel editor
« on: November 14, 2013, 02:56:13 pm »
In reality it's more complicated, but the basic idea is:

Code: [Select]
World world = ...;
FrameBuffer buffer = ...;

buffer.clear(BGCOLOR);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();

Graphics2D igr = (Graphics2D) buffer.getGraphics();
[...] (draw on the igr)

Graphics2D gr = (Graphics2D) BufferedImage.getGraphics();
buffer.display(gr);

I already did some profiling and most time is spend on draw(...) and update(), but not sure what exactly happens when the canvas enlarges, so I'll need to test that again.

70
Projects / Re: VoxelShop - voxel editor
« on: November 14, 2013, 12:42:48 pm »
Thank you for the reply!

The software renderer is already multi-threaded. The problem is that the refresh rate goes down significantly when one expands the viewport (e.g. 2560x1440). I think the drawing onto the canvas is just taking too long.

Is there a way to improve that?

71
Projects / VoxelShop - voxel editor
« on: November 11, 2013, 06:01:18 pm »
This project relies on JPCT on a large scale and I'm very grateful for it!

>> VoxelShop - a voxel editor with animation support



This currently uses the software renderer and I'm still planning to change that.

Please consider using the Blackflux forum if you want to give feedback. I will probably not be able to check this thread regularly in the future.

Regards,
flux

72
Support / Performance Questions
« on: May 18, 2013, 07:00:38 pm »
Two questions:

A) Would it be possible to render only certain parts of the whole FrameBuffer in software mode? I'm updating only certain, well defined areas and would like to avoid re-rendering everything every time I do an update. I've already experimented with moving the camera, but that is extremely tricky to get right.

B) Hit testing is a performance problem for me at a certain point (when I have a lot of objects). I'm assuming you're using some kind of index for all the triangles and then doing a hit-test with the ray? I'm using http://www.jpct.net/doc/com/threed/jpct/World.html#calcMinDistanceAndObject3D%28com.threed.jpct.SimpleVector,%20com.threed.jpct.SimpleVector,%20float%29. Would it be possible/helpful to support this function with a set of possible objects or an area (using my own index)?

Thank you!

73
Support / Re: Flat Shading + Culling = Black
« on: May 17, 2013, 07:54:42 pm »
It's fixed! Thank you!

74
Support / Re: Flat Shading + Culling = Black
« on: May 17, 2013, 11:54:51 am »
I've created a minimal test cast:

Code: [Select]
package vitco;

import com.threed.jpct.*;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 * Testing problem where object is rendered black.
 */
public class BlackJPCT extends WindowAdapter implements MouseMotionListener {
    static FrameBuffer buffer;
    static World world;
    Object3D box;
    JFrame frame;

    public BlackJPCT() {
        // set up frame
        frame = new JFrame("Hello Black!");
        frame.setSize(800, 600);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

        // set up world
        world = new World();
        world.setAmbientLight(0, 0, 0);
        world.addLight( new SimpleVector(500,-500,500), new Color(20,20,20) );
        Config.fadeoutLight = false;

        // ==========================

        box = Primitives.getBox(10f, 1f);

        box.setAdditionalColor(Color.RED);

        // ###############################
        // ###############################
        // if I comment out either of these two lines
        // the object is no longer rendered as black
        box.setShadingMode(Object3D.SHADING_FAKED_FLAT);
        box.setCulling(false);
        // ###############################
        // ###############################
       
        box.build();

        world.addObject(box);

        // ==========================

        // set up camera
        world.getCamera().setPosition(50, -50, -5);
        world.getCamera().lookAt(SimpleVector.ORIGIN);

        // set up frame buffer
        buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);

        // set up event handler
        frame.addMouseMotionListener(this);
        frame.addWindowListener(this);
    }

    @Override
    public void windowClosing(WindowEvent e) {
        // clean up when closing
        buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
        buffer.dispose();
        frame.dispose();
        System.exit(0);
    }

    @Override
    public void mouseDragged(MouseEvent e) {}

    @Override
    public void mouseMoved(MouseEvent e) {
        box.rotateY(0.01f);
        // animate and redraw
        buffer.clear(Color.LIGHT_GRAY);
        world.renderScene(buffer);
        world.draw(buffer);
        buffer.update();
        buffer.display(frame.getGraphics());
    }

    // constructor
    public static void main (String[] args) {
        new BlackJPCT();
    }
}

The essence from that test case:
Code: [Select]
// if I comment out either of these two lines
// the object is no longer rendered as black
box.setShadingMode(Object3D.SHADING_FAKED_FLAT);
box.setCulling(false);

Thank you for your help!

75
Support / Re: Flat Shading + Transparency = Black
« on: May 16, 2013, 01:50:48 pm »
Oh... it's also black.

So the culling is the problem?

Pages: 1 ... 3 4 [5] 6 7