| Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
| Shading the volume... I need help http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=86 |
Page 3 of 3 |
| Author: | paycheck [ Mon Nov 15, 2010 4:57 am ] |
| Post subject: | Re: Shading the volume... I need help |
Attachment: ![]() 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 |
|
| Author: | beyzend [ Mon Nov 15, 2010 5:21 am ] |
| Post subject: | Re: Shading the volume... I need help |
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. |
|
| Author: | paycheck [ Mon Nov 15, 2010 5:55 am ] |
| Post subject: | Re: Shading the volume... I need help |
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. |
|
| Author: | David Williams [ Mon Nov 15, 2010 7:06 pm ] |
| Post subject: | Re: Shading the volume... I need help |
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 |
|
| Page 3 of 3 | All times are UTC |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|