Dot3 Normal Bump Mapping + Per Pixel Lighting

View previous topic View next topic Go down

Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  sio2interactive on Thu Apr 23, 2009 10:18 pm

Take a look at the link above:

http://www.vimeo.com/4309315

Basically Im switching between 4 mode of lighting the first one being the default OpenGL one and 3 other mode controlled by combiners... You can also invert the side of the bumps and control the lighting conditions via combiners callbacks, I think its pretty flexible Wink

A tutorial will be added in 1.3.6 to show you how it work basically its 2 SIO2 call so it should be easy to integrate within your project(s).

Code:


      if( !init_tbn )
      { sio2ObjectSetTBN( _SIO2object, inverted ); }
      
      
      sio2ObjectDot3Lighting( _SIO2object,
                        sio2->_SIO2camera,
                        _SIO2lamp );

Now I know what you guys are asking yourself: "That's all great but what about performance?"

I test 80 objects like this:

object/Cube ( 72:372:81% ) ( 213:372:43% )

So basically its a total of: 10k or triangles and it run at 30 ~ 42 fps on my iPod Touch 2nd Gen, all the lighting is done in the main thread so there's plenty enough space for optimization there such as calculating the lighting in another thread etc...


Last edited by sio2interactive on Fri Apr 24, 2009 5:37 am; edited 4 times in total

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  fleg on Thu Apr 23, 2009 10:26 pm

Dude. DUDE. AWESOME.

fleg

Posts : 4
Join date : 2009-04-20

View user profile

Back to top Go down

Was beddin'

Post  goldfrapp0x0309 on Thu Apr 23, 2009 11:19 pm

Dragged myself out of bed n.... WOW!!! Hope it performs quick and fast too...
avatar
goldfrapp0x0309

Posts : 43
Join date : 2009-02-28

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  sio2interactive on Thu Apr 23, 2009 11:36 pm

The ligthing calculation need to be executed in per frame, but it can easily be calculated in a separate thread... I'll create a tutorial showing how to do it...

Im also doing a quick hack and avoid make sure that the vector are exactly perpendicular so like that its like a lot less calculation and with work fine with convex shapes so, but it is not mathematically fully accurate... If I had access to shaders it would be but... Wink

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  Francescu on Fri Apr 24, 2009 12:07 am

Very very nice! Shocked

Francescu

Posts : 136
Join date : 2009-03-18

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  finthamoussu on Fri Apr 24, 2009 7:59 am

Can't see the video Crying or Very sad : "Sorry, you do not have permission to watch this private video."
avatar
finthamoussu

Posts : 10
Join date : 2009-03-30
Age : 34
Location : Montevideo, Uruguay

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  uprise78 on Fri Apr 24, 2009 9:13 am

I get the "private video" message too. How can we view the video?

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  autology on Fri Apr 24, 2009 11:11 am

try again - video is working for me.

As for the demo.... I can't wait to play. This engine is going to be leaps and bounds ahead of where it was when I took a break from coding.

autology

Posts : 22
Join date : 2008-12-29

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  _-MADMAN-_ on Fri Apr 24, 2009 2:04 pm

Just brilliant! One of the best iPhone cg effect I have ever seen - players will get crazy!

What with materials? Any plans for integration that feature with blender? Texture binding and set - same way as with lm in actual sio2 sdk. I'm talking about export ofcourse Smile

Regards!

_-MADMAN-_

Posts : 52
Join date : 2009-04-23

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  sio2interactive on Fri Apr 24, 2009 5:23 pm

Have you guys been able to watch the video?

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  uprise78 on Fri Apr 24, 2009 5:33 pm

works now and it looks great!

uprise78

Posts : 228
Join date : 2008-10-31

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  Neo on Sat Apr 25, 2009 6:32 pm

Man this looks awesome! cant wait to see the tutorial

Neo

Posts : 1
Join date : 2009-04-02

View user profile

Back to top Go down

sio2ObjectDot3Lighting source?

Post  sgreenwalt on Thu Jun 18, 2009 9:55 pm

Is it possible to get the source for sio2ObjectDot3Lighting and sio2ObjectSetTBN before release of 1.3.6? Like maybe . . . right now?

sgreenwalt

Posts : 18
Join date : 2009-04-24
Location : Layton, Utah

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  sio2interactive on Fri Jun 19, 2009 12:47 am

Actually, you can get it up and running by simply doing this...

1. Simply use tutorial08 and arrange the texture of the ground so the first texture channel is the normal map and the second is the diffuse, make sure that you set the 2 UV channel properly (or simply duplicate them).

2. In the code simply add the following block:

Code:


      glActiveTexture( GL_TEXTURE0 );
      glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
      glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB );

      glTexEnvf(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
      glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);

      glTexEnvf(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR );
      glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);

      
      glActiveTexture( GL_TEXTURE1 );
      
      glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
      glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE );
      
      glTexEnvf( GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE );
      glTexEnvf( GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PREVIOUS );

      glTexEnvf( GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR );
      glTexEnvf( GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR );   


Here's the normal map for the stone wall:

http://sio2.dreamhosters.com/stone_wall_normal_map.jpg

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  MistaED on Sat Jun 20, 2009 10:17 pm

Very nice demo indeed! The video works fine but I think the normal map looks inverted?

I'm curious though, would animated models (ones with md2 morph targets or the hybrid armature system, things with moving vertices) need to have bitangent data assigned to its vertices so that dot3 would work on deformed models and if so, would this be possible at a decent framerate? Also I'm not too sure if this was asked before but was sphere mapping at all possible with the iphone or was it a limitation that you needed the cpu to do the mapping? I'm thinking it would be really cool to mix that with the dot3 and make animated water effects Smile

MistaED

Posts : 4
Join date : 2008-11-08

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  yarri on Thu Aug 20, 2009 4:00 am

Hi, has anyone been able to get this to work with 1.4? Including the OpenGL code into the Tutorial08 templateRender() function with the normal map added doesn't seem to work...


Any thoughts?

Thanks,
--yarri

yarri

Posts : 81
Join date : 2009-04-10

View user profile

Back to top Go down

Re: Dot3 Normal Bump Mapping + Per Pixel Lighting

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum