--- Begin Message ---
> And I thought you was against optimization... ;-)
Well, I hesitated a long time before adding the fog table :-)
> >Changelog:
> > Added fogging for transformed vertices
> >
> Do you have any app that computes fog factors manually ?
Yes, otherwise I would not have submitted a patch :-)) It's Drakan which is
using the alpha component of the specular color to do fogging.
> The "manual" fog takes effect when :
>
> 1) transformed vertices : pixel fog is disabled
> 2) untransformed vertices :
> - pixel fog and vertex fog are disabled
> - no lighting takes place (lit vertex, lighting disabled or
> DD3DV_DONOLIGHT specified)
> (this is due to the lighting stage which is responsible of the vertex
> fog calculation and overrides
> the fog factors given by the application)
>
> Here you don't handle untransformed vertices.
> You don't test if pixel or vertex fogs are enabled or not.
OK. In my case, as the only application that actually has this problem is
using transformed vertices, so I only did this test.
>
> >
> >+ }
> >+ } else {
> >+ if (This->state_block.render_state[D3DRENDERSTATE_FOGTABLEMODE - 1] !=
>D3DFOG_NONE) {
> >+ switch (This->state_block.render_state[D3DRENDERSTATE_FOGTABLEMODE -
>1]) {
> >+ case D3DFOG_LINEAR: glFogi(GL_FOG_MODE, GL_LINEAR); break;
> >+ case D3DFOG_EXP: glFogi(GL_FOG_MODE, GL_EXP); break;
> >+ case D3DFOG_EXP2: glFogi(GL_FOG_MODE, GL_EXP2); break;
> >+ }
> >+ if (vertex_lit == FALSE) {
> >+ glFogf(GL_FOG_START,
>*(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGSTART - 1]);
> >+ glFogf(GL_FOG_END,
>*(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGEND - 1]);
> >+ } else {
> >+ /* Special case of 'pixel fog' */
> >+ glFogf(GL_FOG_START, ZfromZproj(This,
>*(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGSTART - 1]));
> >+ glFogf(GL_FOG_END, ZfromZproj(This,
>*(float*)&This->state_block.render_state[D3DRENDERSTATE_FOGEND - 1]));
> >+ }
> >
> What happened to D3DRENDERSTATE_FOGVERTEXMODE ?
> Morover, pixel fog can be used for transformed vertices.
Hmpf, did not read the test properly :-) Did not see that both tests were on
two different variables (FOGTABLE and FOGVERTEX).
> >-inline static void handle_diffuse_and_specular(STATEBLOCK *sb, DWORD *color_d,
>DWORD *color_s, BOOLEAN lighted) {
> >+inline static void handle_diffuse_and_specular(STATEBLOCK *sb, BYTE *fog_table,
>DWORD *color_d, DWORD *color_s, BOOLEAN lighted) {
> > if (lighted == TRUE) {
> >+ DWORD color = *color_d;
> > if (sb->render_state[D3DRENDERSTATE_FOGENABLE - 1] == TRUE) {
> >- /* Special case where the specular value is used to do fogging. TODO */
> >+ /* Special case where the specular value is used to do fogging */
> >+ BYTE fog_intensity = *color_s >> 24; /* The alpha value of the specular
>component is the fog 'intensity' for this vertex */
> >+ color &= 0xFF000000; /* Only keep the alpha component */
> >+ color |= fog_table[((*color_d >> 0) & 0xFF) << 8 | fog_intensity] << 0;
> >+ color |= fog_table[((*color_d >> 8) & 0xFF) << 8 | fog_intensity] << 8;
> >+ color |= fog_table[((*color_d >> 16) & 0xFF) << 8 | fog_intensity] << 16;
> >
> You must make sure that pixel fog is not active.
See before for the reason of the non-test here :-)
Well, I think the easiest would be for you to send a cumulative patch over
mine as I think it's easier to track for Alexandre (and as I will do for
your Light 'merging' patch that I did not have time to comment before
committing due to vacations :-) ).
Lionel
PS: I think it's better to comment on wine-patches submission on wine-devel
itself rather than here.
--
Lionel Ulmer - http://www.bbrox.org/
--- End Message ---