How to deal with transparent objects?

View previous topic View next topic Go down

How to deal with transparent objects?

Post  Hector_2009 on Mon Sep 14, 2009 4:34 pm

Currently solid object disables alpha tests. Is there a good way to have some objects with alpha test enabled?


Thanks

Hector_2009

Posts : 9
Join date : 2009-06-20

View user profile

Back to top Go down

Re: How to deal with transparent objects?

Post  Francescu on Mon Sep 14, 2009 4:54 pm

Have you checked tutorial04 (video & code)?

Francescu

Posts : 136
Join date : 2009-03-18

View user profile

Back to top Go down

Re: How to deal with transparent objects?

Post  Hector_2009 on Mon Sep 14, 2009 7:06 pm

Yes. The problem is in the following function:

//================================
//================================
//================================
void sio2ObjectUpdateType( SIO2object *_SIO2object )
{
unsigned int i = 0;

SIO2object *tmp = _SIO2object->_SIO2instance ? ( SIO2object * )_SIO2object->_SIO2instance : _SIO2object;

_SIO2object->type = SIO2_OBJECT_SOLID;

while( i != tmp->n_vgroup )
{
if( tmp->_SIO2vertexgroup[ i ]->_SIO2material )
{
if( tmp->_SIO2vertexgroup[ i ]->_SIO2material->blend &&
!tmp->_SIO2vertexgroup[ i ]->_SIO2material->alvl )
{
sio2DisableState( &_SIO2object->type, SIO2_OBJECT_SOLID );
sio2EnableState ( &_SIO2object->type, SIO2_OBJECT_TRANSPARENT );
}

else if( tmp->_SIO2vertexgroup[ i ]->_SIO2material->alvl )
{
//sio2DisableState( &_SIO2object->type, SIO2_OBJECT_SOLID );
sio2EnableState( &_SIO2object->type, SIO2_OBJECT_ALPHA_TESTED );
}
}

++i;
}
}
//================================
//================================
//================================

Had to comment out the line as indicated above to have stuff shown. (//sio2DisableState( &_SIO2object->type, SIO2_OBJECT_SOLID )Wink
After that the screen flicking sometimes, especially when scenes change.

Hector_2009

Posts : 9
Join date : 2009-06-20

View user profile

Back to top Go down

Re: How to deal with transparent objects?

Post  sio2interactive on Mon Sep 14, 2009 7:23 pm

Check the source code of tutorial04 you are definetly missing the point... you shoudn't change that function AT ALL... there's 3 type of object


solid
transparent
and alpha tested...

Check the sio2ResourceRender masks...

_________________
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: How to deal with transparent objects?

Post  Hector_2009 on Wed Sep 16, 2009 4:01 pm

Tutorial 4 does work. However when I test my character, which has transparent parts, in tuturial 15, nothing shows. After I comment out the line

//sio2DisableState( &_SIO2object->type, SIO2_OBJECT_SOLID );

the scene does showup.
Also tried sio2ResourceRender with SIO2_RENDER_ALPHA_TESTED_OBJECT in tutorial 15 and the display is totally black ...

Hector_2009

Posts : 9
Join date : 2009-06-20

View user profile

Back to top Go down

Re: How to deal with transparent objects?

Post  sio2interactive on Wed Sep 16, 2009 5:05 pm

First of all do you understand the difference between the 3? 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: How to deal with transparent objects?

Post  Hector_2009 on Wed Sep 16, 2009 5:23 pm

solid : No alpha
transparent : Alpha blend
and alpha tested... : alpha test

rt?

Hector_2009

Posts : 9
Join date : 2009-06-20

View user profile

Back to top Go down

Re: How to deal with transparent objects?

Post  sio2interactive on Wed Sep 16, 2009 5:44 pm

Ok now do you understand the rendering order of these? 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: How to deal with transparent objects?

Post  Hector_2009 on Thu Sep 17, 2009 1:29 am

solid : No alpha, no sorting necessary
transparent : Alpha blend, sorted by distance (usually)
and alpha tested... : alpha test, no sorting necessary if using the same alpha test value

Hector_2009

Posts : 9
Join date : 2009-06-20

View user profile

Back to top Go down

Re: How to deal with transparent objects?

Post  sio2interactive on Thu Sep 17, 2009 4:08 am

Ok then you're all set Wink

Make sure that you're objects have the good properties and render them 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: How to deal with transparent objects?

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