forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PSPGU Lightmapping ?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
KoalaDB



Joined: 06 Aug 2007
Posts: 20

PostPosted: Mon Aug 06, 2007 8:46 pm    Post subject: PSPGU Lightmapping ? Reply with quote

Hello ! :)

It seems that that the only way to manage lightmaps is to use multiple passes. So .. when i render (for example) a wall with the wall texture and the second time with the lightmap texture (+alpha blending) ... everything is blinking (i think coplanar triangles make the GPU to be confused :p) ...

so i decided to apply a little offset (translation+rotation) to my lightmap geometry preventing the coplanar issue ... but there ... it seems that the wall (with the rock texture) through the alpha blending texture (lightmap) becomes totally transparent :/ and i see everything behind but i can see the correct texture between the first wall geometry and the lightmap wall geometry(the offset ...)

However ... Alpha blending works well at others place... (i know .. it doesn't make sense)

I need some help (pseudo code ?) to make my multipass working (or if there is another lightmap solution ... i will get it too)

or maybe a way to generate at runtime texture+lightmap in only one texture and apply it to the wall ? ...

and if someone has a sample code ... it would be great ...

Thanks !
Back to top
View user's profile Send private message
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Mon Aug 06, 2007 10:08 pm    Post subject: Reply with quote

you need to use exactly the same positions and topology in both passes to get it working. otherwise there will be allways z-fighting.
Back to top
View user's profile Send private message
KoalaDB



Joined: 06 Aug 2007
Posts: 20

PostPosted: Mon Aug 06, 2007 10:47 pm    Post subject: Reply with quote

rapso wrote:
you need to use exactly the same positions and topology in both passes to get it working. otherwise there will be allways z-fighting.


same geometry positions ? and same palette/texture format ? and it must work ?

ok i will try that :)

thanks :)
Back to top
View user's profile Send private message
ufoz



Joined: 10 Nov 2005
Posts: 86
Location: Tokyo

PostPosted: Mon Aug 06, 2007 10:59 pm    Post subject: Reply with quote

use sceGuDepthOffset to get rid of z-fighting maybe?
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
KoalaDB



Joined: 06 Aug 2007
Posts: 20

PostPosted: Mon Aug 06, 2007 11:11 pm    Post subject: Reply with quote

ufoz wrote:
use sceGuDepthOffset to get rid of z-fighting maybe?


It may be a solution ... (thanks for all these hints ! :)

:)
Back to top
View user's profile Send private message
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Mon Aug 06, 2007 11:18 pm    Post subject: Reply with quote

KoalaDB wrote:
rapso wrote:
you need to use exactly the same positions and topology in both passes to get it working. otherwise there will be allways z-fighting.


same geometry positions ? and same palette/texture format ? and it must work ?
the palette/texture format shouldn't have any influence on the depth. but the topology and position of your mesh does.

btw. some games use just per-vertex colors instead of lightmaps, sometimes that's sufficient and you can render it in one pass.
Back to top
View user's profile Send private message
KoalaDB



Joined: 06 Aug 2007
Posts: 20

PostPosted: Mon Aug 06, 2007 11:41 pm    Post subject: Reply with quote

rapso wrote:
the palette/texture format shouldn't have any influence on the depth. but the topology and position of your mesh does.

btw. some games use just per-vertex colors instead of lightmaps, sometimes that's sufficient and you can render it in one pass.




Humm what do you mean by "topology" ? i'm not sure to understand ... The geometry is exactly the same .. only UV coords are different -for lightmap texture :) .. and position exactly the same too :)

Sample for per-vertex color or any ressource ? i will try to find help about that

(thank you for wasting your time for me :$ )
Back to top
View user's profile Send private message
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Tue Aug 07, 2007 12:03 am    Post subject: Reply with quote

KoalaDB wrote:
rapso wrote:
the palette/texture format shouldn't have any influence on the depth. but the topology and position of your mesh does.

btw. some games use just per-vertex colors instead of lightmaps, sometimes that's sufficient and you can render it in one pass.




Humm what do you mean by "topology" ?

it's how the vertices are connected to triangles.

e.g.
Code:

+----+
|   /|
|  / |
| /  |
+----+

in this case you cannot use a lightmap geometry that looks like
Code:

+----+
|\   |
| \  |
|   \|
+----+


both will look like quads when rendered, but they will have sligthly different depth-values.

if you would post a screenshot we might better see what's going wrong, maybe it's not z-fighting
Back to top
View user's profile Send private message
KoalaDB



Joined: 06 Aug 2007
Posts: 20

PostPosted: Tue Aug 07, 2007 1:15 am    Post subject: Reply with quote

yes i will post a screenshot as soon as i get back to home :)

thanks !
Back to top
View user's profile Send private message
charnold



Joined: 10 Sep 2005
Posts: 10

PostPosted: Tue Aug 07, 2007 4:48 am    Post subject: Reply with quote

you can render lightmaps like this:

1. pass (normal texture) with

sceGuDepthFunc(GU_GEQUAL);
sceGuDepthMask(GU_FALSE);
sceGuDisable(GU_BLEND);

2. pass (same poly, lightmap texture)

sceGuDepthFunc(GU_EQUAL); // only pixels with same depth pass the test
sceGuDepthMask(GU_TRUE); // no depth buffer writes
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_FIX, 0x00000000, 0x00000000); // multiply texture color by lightmap color
Back to top
View user's profile Send private message
KoalaDB



Joined: 06 Aug 2007
Posts: 20

PostPosted: Tue Aug 07, 2007 5:34 am    Post subject: Reply with quote

charnold wrote:
you can render lightmaps like this:

1. pass (normal texture) with

sceGuDepthFunc(GU_GEQUAL);
sceGuDepthMask(GU_FALSE);
sceGuDisable(GU_BLEND);

2. pass (same poly, lightmap texture)

sceGuDepthFunc(GU_EQUAL); // only pixels with same depth pass the test
sceGuDepthMask(GU_TRUE); // no depth buffer writes
sceGuEnable(GU_BLEND);
sceGuBlendFunc(GU_ADD, GU_DST_COLOR, GU_FIX, 0x00000000, 0x00000000); // multiply texture color by lightmap color



Works like a charm ! (i have done it working but with these parameters it looks better :)

Charnold ? can you recommend me a software tool/plugin to generate lightmaps ? i'm using Light Map Maker but maybe there is a better one ?

thanks (to all) :)
Back to top
View user's profile Send private message
charnold



Joined: 10 Sep 2005
Posts: 10

PostPosted: Tue Aug 07, 2007 4:07 pm    Post subject: Reply with quote

I havn't used external tools for this (I'm generating the lightmaps in my prog.). Don't some editors have integrated lightmap creation?
Back to top
View user's profile Send private message
KoalaDB



Joined: 06 Aug 2007
Posts: 20

PostPosted: Tue Aug 07, 2007 6:05 pm    Post subject: Reply with quote

charnold wrote:
I havn't used external tools for this (I'm generating the lightmaps in my prog.). Don't some editors have integrated lightmap creation?


ho ok ... i thought that the "LMP" file was generated by a third party software :)

You have a good link for a lightmap calculation tutorial ? :)
Back to top
View user's profile Send private message
charnold



Joined: 10 Sep 2005
Posts: 10

PostPosted: Tue Aug 07, 2007 8:45 pm    Post subject: Reply with quote

I shouldn't have called this file "LMP" :-)

This is not the lightmaps file (they are stored with the geometry in the mapfile).

I needed some texture for the lights, so I placed a light directly in front of a wall, calculated the lightmap for the wall (added transparency values), saved it as "LMP", and used this texture for all the lights in the gallery.

There were several tutorials, I've read, all from the internet (google..., I don't have the links on this pc here)
Back to top
View user's profile Send private message
KoalaDB



Joined: 06 Aug 2007
Posts: 20

PostPosted: Tue Aug 07, 2007 8:51 pm    Post subject: Reply with quote

ok ! great ! :)

Thanks for your patience and explanations :)

i can't wait for your releases ! ;) soon ? :)
Back to top
View user's profile Send private message
charnold



Joined: 10 Sep 2005
Posts: 10

PostPosted: Tue Aug 07, 2007 9:05 pm    Post subject: Reply with quote

:-) I'm working on it...
Back to top
View user's profile Send private message
MikeMax



Joined: 05 Apr 2007
Posts: 5

PostPosted: Tue Aug 07, 2007 9:40 pm    Post subject: Reply with quote

charnold wrote:
:-) I'm working on it...


Great !

Congratulations for your demo. It's very clean.
_________________
MikeMax,
Lead developper
Vertex Origin Studios
www.VertexOrigin.net
Back to top
View user's profile Send private message
charnold



Joined: 10 Sep 2005
Posts: 10

PostPosted: Tue Aug 07, 2007 10:20 pm    Post subject: Reply with quote

thanks!

how is Vertex Racing doing? a new demo coming soon? :-)
Back to top
View user's profile Send private message
MikeMax



Joined: 05 Apr 2007
Posts: 5

PostPosted: Tue Aug 07, 2007 11:18 pm    Post subject: Reply with quote

charnold wrote:
thanks!

how is Vertex Racing doing? a new demo coming soon? :-)


sure ! maybe in few days... i'm still working on car physics engine (car's physics are maybe the most complicated physics to accomplish .. ) and the designer is working on tracks and cars ... We are working on it everyday ... lot of things to do ..

Also working on rendering engine and we were working on lightmaps few days ago ... that's why this topic has took all my attention :)
_________________
MikeMax,
Lead developper
Vertex Origin Studios
www.VertexOrigin.net
Back to top
View user's profile Send private message
charnold



Joined: 10 Sep 2005
Posts: 10

PostPosted: Wed Aug 08, 2007 12:08 am    Post subject: Reply with quote

sounds good !!!
Back to top
View user's profile Send private message
rapso



Joined: 28 Mar 2005
Posts: 147

PostPosted: Wed Aug 08, 2007 12:35 am    Post subject: Reply with quote

MikeMax wrote:

Also working on rendering engine and we were working on lightmaps few days ago ... that's why this topic has took all my attention :)
o'rly :).

I'm very interested in the memory consumption, the texture format and how you handle the UV sets. could you elaborate on that? can u maybe even post a screenshot of that? :)
Back to top
View user's profile Send private message
MikeMax



Joined: 05 Apr 2007
Posts: 5

PostPosted: Wed Aug 08, 2007 7:38 pm    Post subject: Reply with quote

Hey ! as promised, here are some screenshots of Vertex Racing using lightmapping :







More infos (and a forum) on www.vertexorigin.net :)
_________________
MikeMax,
Lead developper
Vertex Origin Studios
www.VertexOrigin.net
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group