• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
MrOMGWTF

Question about generating rays from camera.

6 posts in this topic

Hey. I just finished doing my ray marcher with distance fields. It supports ambient occlusion, shadows, diffuse lighting. It's pretty basic. Here's render from it: (1024 x 1024)
[spoiler]
[img]http://i.imgur.com/hWqos.png[/img]
[/spoiler]

But ok, let's get to the question. How do you generate eye rays? What's the easiest way to do this?
I'm using this method: http://www.unknownroad.com/rtfm/graphics/rt_eyerays.html
But it distorts my image even at field of view of 45... The fov on render above me is 22.5.
What's the proper method to generate eye rays?
0

Share this post


Link to post
Share on other sites
There will always be some form of distortion with a perspective plane projection, no matter what field of view you use. Higher fields of view will lead to extreme distortion at edges, and smaller fields of view will lead to loss of depth. Are you sure you are using the [eqn]\tan(\mathrm{fov} \times 0.5)[/eqn] factor correctly? In my raytracer, at a field of view of 45 degrees the distortion is not very noticeable except if I had tiny spheres at the edges, and quite acceptable, of course it depends on your standards.

Other solutions involve projecting the scene on a section of a sphere, which eliminate distortion but introduce other artifacts such as straight lines being projected curved and aren't as easy to compute... there is no perfect projection as you necessarily throw away information from a three-dimensional world to a two-dimensional plane.
0

Share this post


Link to post
Share on other sites
@Bacterius:
Here's my camera code:
[code]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenTK;

namespace SphereTracing
{
public class Camera
{
public Scene BaseScene { get; set; }
public Vector3 Position { get; set; }
private float FovX;
private float FovY;
private float TanFovX;
private float TanFovY;

public Camera(Scene sc)
{
BaseScene = sc;
SetFov(MathHelper.PiOver4);
}

public void SetFov(float fov)
{
float width, height;
width = (float)BaseScene.Renderer.Width;
height = (float)BaseScene.Renderer.Height;
FovX = fov;
FovY = height / width * FovX;
TanFovX = (float)Math.Tan(FovX);
TanFovY = (float)Math.Tan(FovY);
}

public float GetFov()
{
return FovX;
}

public Ray GetRay(int x, int y)
{
Ray r = new Ray();
float width, height;
width = BaseScene.Renderer.Width;
height = BaseScene.Renderer.Height;

float dx = (2 * x - width) / width * TanFovX;
float dy = (2 * y - height) / height * TanFovY;

r.Position = this.Position;
r.Direction = new Vector3(dx, dy, -1.0f);
r.Direction = Vector3.Normalize(r.Direction);

return r;
}
}
}
[/code]
Here's simple plane rendered at fov 45:
[img]http://i.imgur.com/LLU57.png[/img]
It doesn't look right for me.
0

Share this post


Link to post
Share on other sites
You are ray-marching, not ray-tracing, so your rays die after a certain distance travelled (as far as I can guess - you haven't mentioned what you do with your rays) so that would explain the arcing horizon. A perspective projection cannot by definition cause straight lines to appear curved, so the curved horizon doesn't come from the camera - as far as I can tell anyway, the camera code looks fine, although the camera position and direction are hardcoded.
0

Share this post


Link to post
Share on other sites
[quote name='Bacterius' timestamp='1346229587' post='4974355']
You are ray-marching, not ray-tracing, so your rays die after a certain distance travelled (as far as I can guess - you haven't mentioned what you do with your rays) so that would explain the arcing horizon. A perspective projection cannot by definition cause straight lines to appear curved, so the curved horizon doesn't come from the camera - as far as I can tell anyway, the camera code looks fine, although the camera position and direction are hardcoded.
[/quote]

The position isn't hardcoded, there is no rotation. To rotate a camera I have to multiply the ray direction vector by rotation matrix, right?

@edit And yes, I increased the max distance from 100 to 1000, and the plane is now flat. Thanks for the help. Edited by MrOMGWTF
1

Share this post


Link to post
Share on other sites
[quote name='MrOMGWTF' timestamp='1346229937' post='4974359']
The position isn't hardcoded, there is no rotation. To rotate a camera I have to multiply the ray direction vector by rotation matrix, right?
[/quote]
Ah, my bad, correct about position. For rotation, yes that will work just fine.

[quote]@edit And yes, I increased the max distance from 100 to 1000, and the plane is now flat. Thanks for the help.[/quote]
You are welcome. Was your original question about field of view solved too, though?
0

Share this post


Link to post
Share on other sites
[quote name='Bacterius' timestamp='1346230448' post='4974363']You are welcome. Was your original question about field of view solved too, though?[/quote]
Yes, I'll use my current method. It's fine. Edited by MrOMGWTF
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0