Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  environmental mapping  (Read 1003 times)
0 Members and 1 Guest are viewing this topic.
Offline phu004

Senior Member


Projects: 8


NoSuchPersonException


« Posted 2012-12-27 00:52:27 »

Hi guys, i am trying to write my own algorithm for environmental mapping. My approach is use a 6 faces cube map as the environment,  map the vertex of the polygon to the cube map, and then interpolate the texture position across the polygon during rasterization. My questions is how to deal with the situation where the vertices from a polygon were mapped in different faces of the cube map? Should I split the polygon to make sure all the vertices mapped in a single face or use some clever algorithm to cope with interpolation between 2 vertices that are mapped to different faces of the cube map?

Thanks in advance!
Pan

Offline theagentd
« Reply #1 - Posted 2012-12-27 04:48:40 »

Isn't the whole point of the cube map texture type to just allow you to render a cube and have the texture automatically mapped to it?

Myomyomyo.
Offline phu004

Senior Member


Projects: 8


NoSuchPersonException


« Reply #2 - Posted 2012-12-27 11:00:10 »

the main point of cube mapping is to create fake reflection of a shinny object with arbitrary shape. Traditionally realistic reflection is achieved by ray tracing, however this ray tracing is too slow for real time application.

With cube mapping, you map a surface from an object to a per-rendered cube map texture which was generated by rendering the scene 6 times from the view point of the object. This create an effect that the object is reflecting its surrounding environment.
 
Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline Danny02

JGO Knight


Medals: 36



« Reply #3 - Posted 2012-12-27 11:36:14 »

what the agent ment is that opengl provides you with an cube map texture type, which you provide with the six faces and which handles all the interpolation for you.

You don't upload six textures and then decide in the shader which one to use by yourselve.


Just google a bit around and you will find how to use it.
Offline phu004

Senior Member


Projects: 8


NoSuchPersonException


« Reply #4 - Posted 2012-12-27 13:54:45 »

Yeah, i know there are 3d APIs out there that will do it for you. But I would like to "reinvent" the wheel by writing my own cube mapping algorithm.  Just to kill time during Christmas break  Smiley
Offline matheus23

JGO Wizard


Medals: 72
Projects: 3


You think about my Avatar right now!


« Reply #5 - Posted 2012-12-27 14:26:22 »

Seeing all the projects of phu004, it looks like he is writing a software renderer or something similar. He tries to implement Cube maps in his engine, which is supposed to be some kind of software-opengl.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline phu004

Senior Member


Projects: 8


NoSuchPersonException


« Reply #6 - Posted 2012-12-28 15:29:03 »

I am thinking about building  my environment map using Spherical coordinate system.  Interpolation between 2 points on a sphere is a lot easier than on a 6 faces cube map (since we no longer need to worry about the case where 2 reflection rays hit on different faces).    Environment map in Spherical coordinate can be easily generated by firing 360 * 360 rays at the center of the cube map.

Offline phu004

Senior Member


Projects: 8


NoSuchPersonException


« Reply #7 - Posted 2013-01-02 14:36:11 »

I gave up the idea of building the environment map with spherical coordinate system. It turns out that interpolating 2 points on a sphere is a lot harder than i thought. 
Offline Orangy Tang

JGO Kernel


Medals: 48
Projects: 11


Monkey for a head


« Reply #8 - Posted 2013-01-02 15:25:08 »

It turns out that interpolating 2 points on a sphere is a lot harder than i thought. 

Have you tried using quaternions?

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Roquen

JGO Ninja


Medals: 66



« Reply #9 - Posted 2013-01-03 08:11:49 »

You don't need to do anything special.  To sample a diffuse texture on the sphere, the normal points to the sample.
Pages: [1]
  ignore  |  Print  
 
 

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (72 views)
2013-05-17 21:29:12

alaslipknot (83 views)
2013-05-16 21:24:48

gouessej (113 views)
2013-05-16 00:53:38

gouessej (108 views)
2013-05-16 00:17:58

theagentd (119 views)
2013-05-15 15:01:13

theagentd (108 views)
2013-05-15 15:00:54

StreetDoggy (153 views)
2013-05-14 15:56:26

kutucuk (176 views)
2013-05-12 17:10:36

kutucuk (173 views)
2013-05-12 15:36:09

UnluckyDevil (182 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.089 seconds with 21 queries.