Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (AndrewAMD, fogman, Grant, juanex), 972 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
pixel_to_bmap for separate channels #343256
10/04/10 19:44
10/04/10 19:44
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline OP
Senior Expert
Pappenheimer  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Maybe, that I am simply too dump to see this in the manual:
First:
I want to write into an alpha channel of a bitmap only.
Can I change a channel of a bitmap without changing the others as well?
Example: We've got the terrain shader where each skin contains a texture as rgb and a blendmap in the alpha channel.
When I want to influence the appearance of the terrain, it makes sense to write into the alpha of one of its bitmaps, because this influences the blending/placing of the texture, but it makes no sense alter anything of the texture in the rgb channels, because it is repeated over the terrain.
Second:
I want to use the terrain shader for a model, because I want to build steep slopes and caves AND blend the textures smoothly.
Is it possible to change it or to add a shader that does the same sort of blending with models as well?

BTW:
Mixing a pixel vector with the given pixels of the bitmap to make the change more fluent were nice, as well.

Last edited by Pappenheimer; 10/04/10 20:19. Reason: additional request
Re: pixel_to_bmap for separate channels [Re: Pappenheimer] #343261
10/04/10 20:26
10/04/10 20:26
Joined: Apr 2010
Posts: 172
W
wdlmaster Offline
Member
wdlmaster  Offline
Member
W

Joined: Apr 2010
Posts: 172
1) it's already possible to change all 4 channels independently. Use pixel_for_bmap + pixel_to_vec to get the "old" values, change one (or more) of them, and use pixel_for_vec + pixel_to_bmap to write the "new" values back to the bitmap.

2) a shader makes no difference between models/blocks/terrain/whatever.

Re: pixel_to_bmap for separate channels [Re: wdlmaster] #343270
10/04/10 21:30
10/04/10 21:30
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline OP
Senior Expert
Pappenheimer  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
1) My guess is that changing a single channel of a pixel is faster than the way that you described.
And it is less cumbersome.
2) Just created a stripped down version:
Quote:
#include <acknex.h> // include these predefined, needed files in our project
#include <default.c>
#include <compat.h>
#include <mtlFX.c>
#include <mtlView.c>

#include <strio.c>

#define PRAGMA_ZERO

#define PRAGMA_PATH "terrains";

function main()
{
level_load(NULL);
detail_size = 12;
// ent_create("terrain.hmp", nullvector,fx_terraintex);//this gets tiled properly
ent_create("terrain.mdl", nullvector,fx_terraintex);//...this isn't tiled at all
}


Re: pixel_to_bmap for separate channels [Re: Pappenheimer] #343302
10/05/10 09:19
10/05/10 09:19
Joined: Jul 2000
Posts: 27,935
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,935
Frankfurt
As to (1), you can directly access the texture by locking it and then write into the bmap->finalbits pointer. See:

http://manual.3dgamestudio.net/abmap_lock.htm

The terrain shader expects the render pipeline set up for terrain, so it does not work for models. But you can write a model shader in a similar way.

Re: pixel_to_bmap for separate channels [Re: jcl] #343335
10/05/10 16:02
10/05/10 16:02
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline OP
Senior Expert
Pappenheimer  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Is there any example in the manual about how to use such a bit pointer?
(Probably, a programmer who knows C and/or C++ is supposed to know how such code looks like, but I only know wdl/C-Script and a bit of Lite-C.)

Re: pixel_to_bmap for separate channels [Re: Pappenheimer] #343411
10/06/10 03:57
10/06/10 03:57
Joined: Mar 2002
Posts: 1,774
Magdeburg
F
FlorianP Offline
Serious User
FlorianP  Offline
Serious User
F

Joined: Mar 2002
Posts: 1,774
Magdeburg
For the 8888 format it would look kinda like this

Code:
bmap_lock(bmap, 0);
		char* bits = (char*)bmap->finalbits;		
		int x, y;
		bits[x * 4 + y * bmap->finalwidth * 4 + 3] = newAlpha;
		bmap_unlock(bmap);




I <3 LINQ
Re: pixel_to_bmap for separate channels [Re: FlorianP] #343528
10/06/10 21:11
10/06/10 21:11
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline OP
Senior Expert
Pappenheimer  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Thank you very much.
I try it as soon as I have some time to do so.


Moderated by  aztec, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1