DieHard Wolfers Forum Index DieHard Wolfers
A Wolfenstein 3d Fan Community


  Hosted by: MCS & Areyep.com - Designed by: BrotherTank

Original Yahoo Forum - Die Hard Archives

AReyeP HomepageAreyep Homepage DieHard Wolfenstein BunkerDieHard Wolfenstein Bunker Log inLog in RegisterRegister Banlist FAQFAQ Search ForumsSearch

  Username:    Password:      Remember me       

[idea] Texture magnification dither "ala Unreal Engine&
Page 1 of 1
DieHard Wolfers Forum Index -> Feature Fanatics View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page BottomView Next Topic
Post new topicReply to topic
Author Message
TexZK
DieHard SS
DieHard SS


Joined: 07 Feb 2004
Last Visit: 19 Oct 2016

Topics: 19
Posts: 370
Location: Northern Italy
italy.gif

PostPosted: Tue Apr 29, 2008 1:29 pm
   Subject: [idea] Texture magnification dither "ala Unreal Engine&
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Next PostGoto Bottom of Posts

I'm wondering about how the Unreal Engine (the first one) looked like in software mode. It was nice with that magnification dither!

Let's have a look at this nice article: http://www.flipcode.com/archives/Texturing_As_In_Unreal.shtml, which describes that simple algorythm.

I think something like could be done in Wolf3D by shifting texture [u,v] and screen [x,y] coordinates in ScalePost(). I have to understand the Wolf3D raycastor a bit before, but I know there are people (gurus to be honest) out there who can make it with blind eyes. Rolling Eyes

IMHO this is a nice feature, and doesn't need huge comoutations at all, since it uses only light shifting and masking on coordinates with fixed-point numbers; remember that the tiles precision is 16-bits, while for texels is commonly 6/7-bits, so we have a huge room for interpolation.

Tell me what you think about!
Beer
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 11:34 ago.

Topics: 163
Posts: 8146
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Wed Apr 30, 2008 9:05 pm
   Subject: Re: [idea] Texture magnification dither "ala Unreal Engine&
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

I know for a fact that the raycastor still has some inconsistencies that would keep this feature from working the way it should. I need to look over if that's fixed in Wolf4SDL or not. If I come up with a Negative, it'll be a no-go. Sad

Thanks for the post regardless. It's interesting reading. Smile
Ripper
Code Master - Developer
Code Master - Developer


Joined: 15 Mar 2003
Last Visit: 30 Sep 2008

Topics: 21
Posts: 527
Location: Germany
blank.gif

PostPosted: Sat May 03, 2008 3:40 pm
   Subject: Re: [idea] Texture magnification dither "ala Unreal Engine&
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

That's a really interesting idea.
[Some time later]
Sadly it isn't as good as it sounds: It looks strange and blury. Here are some screenshots (ignore those stupid small versions and click on the pictures to see them full size (640x400)):



It's funny to look at those screenshots at 2x magnification. At least my brain does a pretty good job not letting me see, that the image is dithered that much Wink

Here's some code:
::: CODE :::
// 0x40000 == 1
// 0x10000 == 0.25
int ditherTab[2][2][2] = {
    {{ 0x10000, 0x00000 }, { 0x20000, 0x30000 }},
    {{ 0x30000, 0x20000 }, { 0x00000, 0x10000 }}
};

void ScaleDitheredWall(byte *texture, int x, int wallheight, int u)
{
    int y, ywcount, yoffs, yendoffs;

    u <<= 8;

    ywcount = wallheight >> 3;

    yoffs = (viewheight / 2 - ywcount) * vbufPitch;
    if(yoffs < 0) yoffs = 0;
    yoffs += postx;

    y = viewheight / 2 + ywcount - 1;

    int v = 0;
    int vd = 0x4000000 / wallheight;

    while(y >= viewheight)
    {
        v += vd;
        y--;
    }
    if(v >= 0x1000000) return;

    yendoffs = y * vbufPitch + postx;
    while(yoffs <= yendoffs)
    {
        int curU = (u + ditherTab[y&1][x&1][0]) & 0xffffff;
        int curV = (v + ditherTab[y&1][x&1][1]) & 0xffffff;
        byte col = texture[((curU >> 18) << 6) + 63 - (curV >> 18)];

        vbuf[yendoffs] = col;
        v += vd;
        yendoffs -= vbufPitch;
        y--;
    }
}

void HitVertWall (void)
{
    int wallpic;
    int texture;

    int u = (yintercept + texdelta) & 0xffff;

    texture = ((yintercept+texdelta)>>TEXTUREFROMFIXEDSHIFT)&TEXTUREMASK;
    if (xtilestep == -1)
    {
        texture = TEXTUREMASK-texture;
        u = 0x10000 - u;
        xintercept += TILEGLOBAL;
    }

    lastside=1;
    lastintercept=xtile;
    lasttilehit=tilehit;
    lasttexture=texture;
    wallheight[pixx] = CalcHeight();
    postx = pixx;
    postwidth = 1;

    if (tilehit & 0x40)
    {                                                               // check for adjacent doors
        ytile = (short)(yintercept>>TILESHIFT);
        if ( tilemap[xtile-xtilestep][ytile]&0x80 )
            wallpic = DOORWALL+3;
        else
            wallpic = vertwall[tilehit & ~0x40];
    }
    else
        wallpic = vertwall[tilehit];

    postsource = PM_GetTexture(wallpic) + texture;

    ScaleDitheredWall(PM_GetTexture(wallpic), pixx, wallheight[pixx], u);
}

void HitHorizWall (void)
{
    int wallpic;
    int texture;

    int u = (xintercept+texdelta) & 0xffff;

    texture = ((xintercept+texdelta)>>TEXTUREFROMFIXEDSHIFT)&TEXTUREMASK;
    if (ytilestep == -1)
        yintercept += TILEGLOBAL;
    else
    {
        texture = TEXTUREMASK-texture;
        u = 0x10000 - u;
    }

    lastside=0;
    lastintercept=ytile;
    lasttilehit=tilehit;
    lasttexture=texture;
    wallheight[pixx] = CalcHeight();
    postx = pixx;
    postwidth = 1;

    if (tilehit & 0x40)
    {                                                               // check for adjacent doors
        xtile = (short)(xintercept>>TILESHIFT);
        if ( tilemap[xtile][ytile-ytilestep]&0x80)
            wallpic = DOORWALL+2;
        else
            wallpic = horizwall[tilehit & ~0x40];
    }
    else
        wallpic = horizwall[tilehit];

    postsource = PM_GetTexture(wallpic) + texture;

    ScaleDitheredWall(PM_GetTexture(wallpic), pixx, wallheight[pixx], u);
}


But as I said, I don't like the result.

_________________
Life is an awful game, but the graphics resolution rocks ;D
Tricob
Moderator
<B>Moderator</B>


Joined: 14 Mar 2005
Last Visit: 11:34 ago.

Topics: 163
Posts: 8146
Location: Neo-traditions, Inc.
usa.gif

PostPosted: Sat May 03, 2008 6:14 pm
   Subject: Re: [idea] Texture magnification dither "ala Unreal Engine&
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

It'd probably look better if it's only drawn every other frame for an "earthquake" effect, simulating vibrations in the ground.
doomjedi
DieHard Wolfer
DieHard Wolfer


Joined: 21 Jul 2006
Last Visit: 22:31 ago.

Topics: 106
Posts: 2820
Location: Israel
israel.gif

PostPosted: Sat May 03, 2008 10:59 pm
   Subject: Re: [idea] Texture magnification dither "ala Unreal Engine&
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Next PostGoto Bottom of Posts

Let me quote Duke Nukem:
"Daaaamn, you're ugly!"
Smile
TexZK
DieHard SS
DieHard SS


Joined: 07 Feb 2004
Last Visit: 19 Oct 2016

Topics: 19
Posts: 370
Location: Northern Italy
italy.gif

PostPosted: Sun May 04, 2008 3:41 am
   Subject: Re: [idea] Texture magnification dither "ala Unreal Engine&
   [ IP : Logged ]
Reply with quote
Goto Top of PostsGoto Previous PostGoto Bottom of Posts

I thought it would look better Crying or Very sad Thanks Ripper for your implementation, I know you can make such things in 2 seconds Very Happy

Tricob wrote:
It'd probably look better if it's only drawn every other frame for an "earthquake" effect, simulating vibrations in the ground.

The idea isn't bad, but this algorythm should be applied only on magnification... A similar algorythm could be better when blitting the other frame, and is the
classical mask on the first bit (which is part of the dithering). Nice idea anyway Smile Can also be used for simil-translucent objects, without using a separate palette look-up table.

There's always something to learn and invent with new features... Cool
Display posts from previous:   
Post new topicReply to topic Time synchronized with the forum server time
DieHard Wolfers Forum Index -> Feature Fanatics View Previous TopicRefresh this PageAdd Topic to your Browser FavoritesSearch ForumsPrint this TopicE-mail TopicGoto Page TopView Next Topic
Page 1 of 1
Jump to:  

Related topics
 Topics   Replies   Views   Last Post 
No new posts WOLF4GW
Author: Tricob
110 34265 Thu Oct 08, 2015 9:17 am
Chris View latest post
No new posts "Awesomest Weapon" contest
Author: Dugtrio17
13 3153 Mon Aug 20, 2007 6:08 pm
Anonymous View latest post
No new posts Wolf3D and voxels
Author: Ripper
10 3468 Sat Mar 24, 2007 3:35 pm
Dugtrio17 View latest post
No new posts Stealth Mode and Hostages
Author: Guest
12 339 Tue Nov 07, 2006 12:50 am
Codetech84 View latest post
No new posts Isn't it a bit cloudy today?
Author: Ripper
47 6982 Mon May 24, 2004 12:38 pm
Ripper View latest post
 
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


Copyright ©2003-2008 DieHard Wolfers
A Modified subBunker Theme by BrotherTank
Powered by phpBB © 2001, 2005 phpBB Group