PSPGU Lightmapping ?
PSPGU Lightmapping ?
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 !
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 !
the palette/texture format shouldn't have any influence on the depth. but the topology and position of your mesh does.KoalaDB wrote:same geometry positions ? and same palette/texture format ? and it must work ?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.
btw. some games use just per-vertex colors instead of lightmaps, sometimes that's sufficient and you can render it in one pass.
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 :$ )
it's how the vertices are connected to triangles.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" ?
e.g.
Code: Select all
+----+
| /|
| / |
| / |
+----+
Code: Select all
+----+
|\ |
| \ |
| \|
+----+
if you would post a screenshot we might better see what's going wrong, maybe it's not z-fighting
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
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
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) :)
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)
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)
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 ..charnold wrote:thanks!
how is Vertex Racing doing? a new demo coming soon? :-)
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 :).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 :)
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? :)
Hey ! as promised, here are some screenshots of Vertex Racing using lightmapping :
More infos (and a forum) on www.vertexorigin.net :)
More infos (and a forum) on www.vertexorigin.net :)