PSPGU Lightmapping ?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
KoalaDB
Posts: 20
Joined: Mon Aug 06, 2007 8:32 pm

PSPGU Lightmapping ?

Post by KoalaDB »

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 !
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

you need to use exactly the same positions and topology in both passes to get it working. otherwise there will be allways z-fighting.
KoalaDB
Posts: 20
Joined: Mon Aug 06, 2007 8:32 pm

Post by KoalaDB »

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 :)
ufoz
Posts: 86
Joined: Thu Nov 10, 2005 2:36 am
Location: Tokyo
Contact:

Post by ufoz »

use sceGuDepthOffset to get rid of z-fighting maybe?
KoalaDB
Posts: 20
Joined: Mon Aug 06, 2007 8:32 pm

Post by KoalaDB »

ufoz wrote:use sceGuDepthOffset to get rid of z-fighting maybe?
It may be a solution ... (thanks for all these hints ! :)

:)
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

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.
KoalaDB
Posts: 20
Joined: Mon Aug 06, 2007 8:32 pm

Post by KoalaDB »

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 :$ )
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

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: Select all

+----+
|   /|
|  / |
| /  |
+----+
in this case you cannot use a lightmap geometry that looks like

Code: Select all

+----+
|\   |
| \  |
|   \|
+----+
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
KoalaDB
Posts: 20
Joined: Mon Aug 06, 2007 8:32 pm

Post by KoalaDB »

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

thanks !
charnold
Posts: 10
Joined: Sat Sep 10, 2005 9:32 pm

Post by charnold »

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
KoalaDB
Posts: 20
Joined: Mon Aug 06, 2007 8:32 pm

Post by KoalaDB »

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) :)
charnold
Posts: 10
Joined: Sat Sep 10, 2005 9:32 pm

Post by charnold »

I havn't used external tools for this (I'm generating the lightmaps in my prog.). Don't some editors have integrated lightmap creation?
KoalaDB
Posts: 20
Joined: Mon Aug 06, 2007 8:32 pm

Post by KoalaDB »

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 ? :)
charnold
Posts: 10
Joined: Sat Sep 10, 2005 9:32 pm

Post by charnold »

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)
KoalaDB
Posts: 20
Joined: Mon Aug 06, 2007 8:32 pm

Post by KoalaDB »

ok ! great ! :)

Thanks for your patience and explanations :)

i can't wait for your releases ! ;) soon ? :)
charnold
Posts: 10
Joined: Sat Sep 10, 2005 9:32 pm

Post by charnold »

:-) I'm working on it...
MikeMax
Posts: 5
Joined: Thu Apr 05, 2007 8:32 pm

Post by MikeMax »

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
charnold
Posts: 10
Joined: Sat Sep 10, 2005 9:32 pm

Post by charnold »

thanks!

how is Vertex Racing doing? a new demo coming soon? :-)
MikeMax
Posts: 5
Joined: Thu Apr 05, 2007 8:32 pm

Post by MikeMax »

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
charnold
Posts: 10
Joined: Sat Sep 10, 2005 9:32 pm

Post by charnold »

sounds good !!!
rapso
Posts: 140
Joined: Mon Mar 28, 2005 6:35 am

Post by rapso »

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? :)
MikeMax
Posts: 5
Joined: Thu Apr 05, 2007 8:32 pm

Post by MikeMax »

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

Image

Image

Image

More infos (and a forum) on www.vertexorigin.net :)
MikeMax,
Lead developper
Vertex Origin Studios
www.VertexOrigin.net
Post Reply