It is currently Sat Aug 22, 2020 12:24 pm


All times are UTC




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: Shading the volume... I need help
PostPosted: Mon Nov 15, 2010 4:57 am 

Joined: Wed Nov 10, 2010 7:15 pm
Posts: 43
Attachment:
textureatlasdone.jpg
textureatlasdone.jpg [ 126.01 KiB | Viewed 2417 times ]

So I have the texture atlas done now (thanks in large part to the members of this forum, and LBDude from the ogre community) I am however still unable to use the alpha channel of the png for some reason. This is the cg code I'm using now:
Code:
void ColouredCubicVoxelVP(
    float4 inPosition    : POSITION,
   float2 inMaterial    : TEXCOORD0,
   
    out float4 outClipPosition        : POSITION,
    out float4 outWorldPosition    : TEXCOORD0,
   out float2 outMaterial        : TEXCOORD1,
   
    uniform float4x4 world,
    uniform float4x4 viewProj
    )
{   
    //Compute the world space position
    outWorldPosition = mul(world, inPosition);   
   
    //Compute the clip space position
    outClipPosition = mul(viewProj, outWorldPosition);
   
   //Pass through the material
    outMaterial = inMaterial;
}

void ColouredCubicVoxelFP(
    float4 inPosition        : POSITION,
    float4 inWorldPosition    : TEXCOORD0,
    float4 inMaterial    : TEXCOORD1,

    uniform sampler2D heightMap : TEXUNIT0,
   
    out float4 result        : COLOR)
{   
   
   float3 worldNormal = cross(ddy(inWorldPosition.xyz), ddx(inWorldPosition.xyz));
   worldNormal = normalize(worldNormal);
   
    //World position is used as texture coordinates. Choose which
    //two components of world position to use based on normal. Could
    //optionally use a different texture for each face here as well.
   
   float2 uv;
   
   float materialID = inMaterial.x * 256.0 ;
   float atlasYOffset = floor(materialID / 16);
   float atlasXOffset = materialID - (atlasYOffset * 16);
   
   //testing
   //atlasXOffset = 5;
   //atlasYOffset = 1;
   
   
   if(worldNormal.x > 0.5){
        uv = inWorldPosition.yz;
    }
   
    if(worldNormal.x < -0.5){
        uv = inWorldPosition.yz;
    }
   
    if(worldNormal.y > 0.5){
        uv = inWorldPosition.xz;
    }
   
    if(worldNormal.y < -0.5){
        uv = inWorldPosition.xz;
    }
   
    if(worldNormal.z > 0.5){
        uv = inWorldPosition.xy;
    }
   
    if(worldNormal.z < -0.5){
        uv = inWorldPosition.xy;
    }
   uv = frac(uv / 16 + .5);
    uv = (float2(atlasXOffset, atlasYOffset) + float2(uv));
    uv = uv / 16;
   
   result = tex2D(heightMap, uv);
}


I need to clean up the edges, not sure how so if anyone has advice I would be grateful. I'm am just using
Code:
filtering anisotropic
                max_anisotropy 8

in my material, which I was under the impression wouldn't cause any bleeding. (I also tried it without the filtering and the bleeding is the exact same).

Also, I had a question about the MaterialDensityPair44 object - where is it declared in the polyvox stuff, I can't even seem to find it even though I'm using it. I really need more than 4 bits for the material, and probably only 1 bit for the density (either it's there or it''s not right?) Honestly, I'm pretty sure I'll want at least 16 bits per voxel, probably more. (around 10-12 for material (need to think of expandability in the future) 1 for density, and the rest for state (think powered, pathable, any other states you would want to store on a per-voxel basis). Anyways, if you could tell me where to look to start digging into the MaterialDensityPair stuff that would be awesome.

Things are really starting to take shape :P


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Shading the volume... I need help
PostPosted: Mon Nov 15, 2010 5:21 am 

Joined: Sat Sep 18, 2010 9:45 pm
Posts: 189
MaterialDensity44 is a typedef in MaterialDensity.h....
If you are using Texture Atlas there are some issues invovled with mip mapping and fliltering (see: http://www.google.com/#hl=en&expIds=172 ... 9919fbb9a2). You can solve some of the issues by...I've yet to look into this in any depth myself so I can't say much except that you can get around some of the issues but it takes work. These problems are inherent with texture atlases. If you don't care about backward compatibility you can try the OpenGL texture array extension (I'm not sure what the equivalent of this is for directx; perhaps directx 10 and 11 has something similar).

....I can't get the alpha to work either. I guess I never had alpha working either. that's weird. Google Ogre3d alpha texturing or something.

BTW this is LBDUde from Ogre3d forums.

Update: I don't know, I see a black background where it is supposed to be transparent. I need to look up how Ogre3d does transparency. You may have to mess with render queues. I assume that it should just work with depth testing though. Also, PNG is little bit weird when it comes to transparency...apparently.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Shading the volume... I need help
PostPosted: Mon Nov 15, 2010 5:55 am 

Joined: Wed Nov 10, 2010 7:15 pm
Posts: 43
ah thanks. I'm not quite sure how I should act about dx10... dx10 = no xp support right? Kind of fail... and actually for some reason my program just 100% crashes under openGL, I never could figure out the reason, but since it works perfectly with directX I'm fine with it. my alpha is doing the same thing (black) and I really have no idea. I may just switch to arrays though, because it does seem to be the "right" way to do things.... I probably will. Anyways, thanks for all your help. I'm probably done programing for the night, more updates tomorrow I guess.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Shading the volume... I need help
PostPosted: Mon Nov 15, 2010 7:06 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
paycheck wrote:
I also tried it without the filtering and the bleeding is the exact same.


By 'without the filtering', do you mean you simply removed that command from the script or that you actually set it to 'none'? Simply removing it will cause Ogre to use the default, which is 'bilinear'. See http://www.ogre3d.org/docs/manual/manual_17.html#SEC89

paycheck wrote:
Also, I had a question about the MaterialDensityPair44 object - where is it declared in the polyvox stuff, I can't even seem to find it even though I'm using it. I really need more than 4 bits for the material, and probably only 1 bit for the density (either it's there or it''s not right?) Honestly, I'm pretty sure I'll want at least 16 bits per voxel, probably more. (around 10-12 for material (need to think of expandability in the future) 1 for density, and the rest for state (think powered, pathable, any other states you would want to store on a per-voxel basis). Anyways, if you could tell me where to look to start digging into the MaterialDensityPair stuff that would be awesome.


Instead of MaterialDensityPair44 you can use Material8. This doesn't store a density at all, as the getDensity() member computes a density based on the material (Material 0 is empty and any other material is solid). You can also create your own custom types though I haven't gone above 8 bits.

beyzend wrote:
....I can't get the alpha to work either. I guess I never had alpha working either. that's weird. Google Ogre3d alpha texturing or something.


You should make sure you set the scene_blend mode appropriatly so that Ogre knows what to do with the alpha value. You probably want 'alpha_blend'. See http://www.ogre3d.org/docs/manual/manual_16.html#SEC45


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2, 3

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net