Pete´s Messageboard... No ISO/BIOS requests!

Homepage Members Register Login Search Old board


Neuer Thread ...


AuthorTopics » Book an abo for this threadClose Thread Move Thread Fix the thread Print view Delete this thread

gomtuu 



...

Status:Offline
Date registered: 02.11.2008
Post:2
Send Message
...   Created on 02.11.2008 - 16:25Jump to top Quote this post Report this post Edit Delete


I've been working on a mesh viewer for Final Fantasy Tactics for a while now. I'm using the the normal vectors and light color/position data from the mesh files, but the lighting has always been too dark compared to what I see in epsxe. At first, I solved this by drawing everything twice with blending turned on, which helped, but it made dark things a bit too bright.

I've decided to try to solve this problem using GLSL, but I'm just starting out and I'm not having much success so far. I can't find the right balance where it's bright enough, but not too bright. (There are a few ridiculously bright lights in some meshes. Most lights have brightnesses of around 2000-3000 in each channel, but some are 10x brighter than that.)

If I could find shader that produces accurate PSX-like output, I'd be very happy. Or, if I'm barking up the wrong tree, I'd appreciate it if someone could point me toward the right one.

Thanks,
-gomtuu

[Dieser Beitrag wurde am 02.11.2008 - 16:26 von gomtuu aktualisiert]




gomtuu 



...

Status:Offline
Date registered: 02.11.2008
Post:2
Send Message
...   Created on 03.11.2008 - 03:27Jump to top Quote this post Report this post Edit Delete


I took a look at Everything You Have Always Wanted to Know about the Playstation But Were Afraid to Ask. Decyphering it was easier than I expected, but it turned out that the lighting calculation (NCCS) is basically the same as what I was using. So here are the shaders I settled on:

Code:
1:
2:
3:
4:
5:
6:
7:
 
/* Vertex Shader */
varying vec3 normal;
void main() {
    normal = normalize(gl_NormalMatrix * gl_Normal);
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_Position = ftransform();
}


Code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
 
/* Fragment Shader */
varying vec3 normal;
uniform sampler2D tex;
void main() {
    vec3 ct, ambient, color;
    vec4 texel;
    float at;

    texel = texture2D(tex,gl_TexCoord[0].st);
    ct = texel.rgb * 255.0;
    at = texel.a;

    ambient = gl_LightModel.ambient;
    color = ambient * ct;
    for (int i=0; i<3; i++) {
        vec3 lightDir = vec3(gl_LightSource[i].position) / 4096.0;
        float intensity = max(dot(lightDir, normal), 0.0);
        vec3 diffuse = min(gl_LightSource[i].diffuse, vec3(1.0)) * intensity;
        diffuse = max(diffuse, vec3(0.0));
        color += diffuse * ct * 2;
    }
    gl_FragColor = vec4(color / 255.0, at * vec3(1.0));
}


The only real deviations from the PSX formula are:

1. Capping "gl_LightSource[ i ].diffuse" at 1.0 to prevent super-bright lights. (Most lights in the mesh files have less than 1.0 brightness, but some have values of 6 or 7.)
2. Multiplying the "diffuse * ct" term by 2 to increase the brightness of the diffuse lighting. (Otherwise the entire scene is too dark.)

It produces fairly accurate output now, but I'm not sure why I have to do either of those steps. Any ideas?

Thanks,
-gomtuu

[Dieser Beitrag wurde am 03.11.2008 - 03:30 von gomtuu aktualisiert]





Similarly threads:
Topics Created by Replies Boardname
Natural Vision Shader + AA Shader v2.o = Best Shader for 2d !! zaykho 10 pete_bernert
Is a pixel accurate ePSXe 2x Mode possible? JohnPeterson 1 pete_bernert
Was ist ein Mesh gast 5 bluesims
wie erstellt man ein Mesh Nicy 2 bluesims
CS:S bot navigation-mesh tutorial (in german) CoCoNUT 0 coconut
Neuer Thread ...





Masthead

This forum is a free service of razyboard.com powered by:
Geizkragen Price Comparison. Top product in the price comparison: Krups Nespresso Essenza (XN2001)
Do you want a free forum in less than two minutes? Then click here!



Verwandte Suchbegriffe:
psx shader | epsxe shaders | psx shaders | epsxe shaders tutorial | pcsx shader | epsxe dark brightnes | epsxe dark shader | ps1 shader
blank