Jump to content

Transparency and Background Rendering problem


darrenc182
 Share

Recommended Posts

I am trying to render an outdoor scene with terrain, a skybox and my simple HUD. I can render the HUD in the transparency world with the Terrain, but I cannot render the skybox, terrain and HUD together. I can also render the skybox and terrain just fine by themselves also. I am putting my HUD in the transparency world like this:

 

fw.GetTransparency().SetWorld();
CreateAmmoHUD();
CreateHealthHUD();
fw.GetMain().SetWorld();

 

I am rendering the skybox like this:

fw.GetRenderer().SetSkybox(LoadMaterial("abstract::FullskiesBlueClear0016_2_L.mat"));

 

When that is commented out terrain and HUD render fine. When it is uncommented then I get a black screen with the HUD display but no skybox and no terrain, however everything renders fine for the first frame and after that I get a black screen with the HUD only. Does anyone have an idea on how I can fix this, or is this potentially a bug? All help will be greatly appreciated.

Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5.

Link to comment
Share on other sites

what are you using for your HUD ?

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

what are you using for your HUD ?

 

I'm using plane meshes and textures with alpha channels if I remember correctly and I'm parenting all of the plane meshes to the camera.

Intel 2nd Generation i5 Quad Core Running at 3.30GHz. 8GB RAM, GeForce GTX 460 1024MB DDR5.

Link to comment
Share on other sites

  • 3 weeks later...
  • 6 months later...

This is old thread, but i dont want to create new one with the same problem.

 

Looking like this dont works for particles

 

SetBlend(BLEND_ALPHA);

TEmitter emitter = CreateEmitter(20,800,Vec3(0,0.2,0),1, _parentEnt);
PaintEntity(emitter, g_gunSmoke);  
SetEmitterRadius(emitter,0.005,0.1);

SetBlend(0);

Working on LeaFAQ :)

Link to comment
Share on other sites

http://www.leadwerks.com/wiki/index.php?title=Worlds#SetWorld

 

There is not too many info... I saw tutorial on transparency, there is creation of new worlds, changing them and so on... Isnt it done in TFramework ?

 

In another words, is there defined-in-TFramework transparent world?

 

PS: Here it is ;)

http://www.leadwerks.com/wiki/index.php?title=Framework#GetFrameworkLayer

Working on LeaFAQ :)

Link to comment
Share on other sites

Anyway, this also don't works

 

SetWorld(GetLayerWorld(GetFrameworkLayer(1)));

TEmitter emitter = CreateEmitter(20,800,Vec3(0,0.2,0),1, _parentEnt);
           PaintEntity(emitter, g_gunSmoke);  
           SetEmitterRadius(emitter,0.005,0.1);

SetWorld(GetLayerWorld(GetFrameworkLayer(0)));

Working on LeaFAQ :)

Link to comment
Share on other sites

Are you sure that your emitter doesn't work? At first glance you are using a one-shot emitter, so may be it's "quick" and you don't see it, try to using a looping ones, the following code works for me:

 

TFramework fw = CreateFramework();
TCamera camera = GetLayerCamera( GetFrameworkLayer(0) );

TModel crawler = LoadModel("abstract::crawler.gmf");
TModel crawler2 = LoadModel("abstract::crawler.gmf");
MoveEntity(crawler2, Vec3(-2,0,0));
TMaterial mat = LoadMaterial("abstract::dust.mat");
TEmitter emitter = CreateEmitter(50,3000,Vec3(0,4,0));
PaintEntity(emitter, mat);
SetEmitterRadius(emitter,0.005,0.1);
PositionEntity(emitter, EntityPosition(crawler));
EntityParent(emitter, crawler);

PositionEntity(camera, EntityPosition(crawler));
MoveEntity(camera, Vec3(0,0,-3));

flt mx = 0, my = 0;
HideMouse();
TVec3 camrotation = Vec3(0);

while( !KeyHit() && !AppTerminate() )
{
mx=Curve(MouseX()-GraphicsWidth()/2,mx,6);
my=Curve(MouseY()-GraphicsHeight()/2,my,6);
MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2);
camrotation.X=camrotation.X+my/10.0;
camrotation.Y=camrotation.Y-mx/10.0;
RotateEntity(camera,camrotation);

if (KeyHit(KEY_C))
{
	mx = 0;
	my = 0;
	camrotation = Vec3();
	PointEntity(camera, crawler);
}
if (KeyHit(KEY_X))
{
	TEmitter newEmitter = CreateEmitter(50,3000,Vec3(0,4,0));
	PaintEntity(newEmitter, mat);
	EntityColor(newEmitter, Vec4(0,0,1,1));
	SetEmitterRadius(newEmitter,0.005,0.1);
	PositionEntity(newEmitter, EntityPosition(crawler));
	MoveEntity(newEmitter, Vec3(0, 0, 2));
	EntityParent(newEmitter, crawler);
}

TVec3 pos = EntityPosition(crawler);
if (KeyHit(KEY_D))
	pos.X += 0.5f;
   if (KeyHit(KEY_A))
       pos.X -= 0.5f;
   if (KeyHit(KEY_W))
       pos.Y += 0.5f;
   if (KeyHit(KEY_S))
       pos.Y -= 0.5f;
   if (KeyHit(KEY_Q))
       pos.Z += 0.5f;
   if (KeyHit(KEY_E))
       pos.Z -= 0.5f;
PositionEntity(crawler, pos);

UpdateFramework();
RenderFramework();
Flip();
}

?? FRANCESCO CROCETTI ??

http://skaredcreations.com

Link to comment
Share on other sites

Thanks, ZioRed, but i was talking about making particles transparent and gave code of my trying to set transparent world.

 

In tutorial, there is

//Render the world
SetBuffer(gbuffer);
RenderWorld();
//Render lighting
SetBuffer(BackBuffer());
RenderLights(gbuffer);

 

But as far as i know, framework already manages worlds and buffers.

 

So, thats what i'm stucked in: how can i render transparent entity (probably particles, not 2d text) in framework?

Working on LeaFAQ :)

Link to comment
Share on other sites

This is taken from my engine's fire object class and the smoke emitter is using a transparent material for the particles. This definitely works for me. I'm using framewerk rather than framework (and a modified version to allow direct buffer access) but this should work just as well with framework. Hope this helps:

 

void fire::createEmitters(void)
{
float intensity;
float lifetime;

// Set transparent world
m_pFramewerk->GetTransparency().SetWorld();

//  Create the smoke emitter
intensity = 25+(m_fSmokeWidth*50);
lifetime = (m_fSmokeHeight/m_fSmokeSpeed)*1000;
TEmitter smoke = CreateEmitter(50,lifetime,Vec3(0,m_fSmokeSpeed, 0)); 
EntityColor(smoke,Vec4(1,1,1,0.25));
PaintEntity(smoke,LoadMaterial("abstract::softdust.mat"));
SetEmitterRadius(smoke,0.3,0.3);  // 0.5,0.5
SetEmitterWaver(smoke,0.4);
SetEmitterRotationSpeed(smoke,0.5);
SetEmitterArea(smoke,Vec3(m_fSmokeWidth));  // 0.5 
PositionEntity(smoke,Vec3(getObjectPosition().X,getObjectPosition().Y + (m_fFireHeight*0.5),getObjectPosition().Z),1);  

// Create the fire emitter
intensity = 100+(m_fFireWidth*100);
lifetime = (m_fFireHeight/m_fFireSpeed)*1000;
TEmitter fire = CreateEmitter(intensity,lifetime,Vec3(0,m_fFireSpeed,0));
EntityColor(fire,Vec4(1,0.5,0,0.3));
PaintEntity(fire,LoadMaterial("abstract::fire.mat"));
SetEmitterRadius(fire,0.25,0.15);
SetEmitterWaver(fire,0.25);
SetEmitterRotationSpeed(fire,0.5);
SetEmitterArea(fire,Vec3(m_fFireWidth));  // 0.4
PositionEntity(fire,getObjectPosition(),1);

// Create the heat haze emitter
TEmitter heat = CreateEmitter(20,1000,Vec3(0,m_fFireSpeed,0));
TMaterial material=LoadMaterial("abstract::heathaze.mat");
m_pFramewerk->GetRenderer().SetHeatHazeTexture(material);
PaintEntity(heat,material);
SetEmitterRadius(heat,0.50,0.50);
SetEmitterWaver(heat,0.5);
SetEmitterRotationSpeed(heat,0.1);
SetEmitterArea(heat,Vec3(0.25));
PositionEntity(heat,getObjectPosition(),1);

// Set main world
m_pFramewerk->GetMain().SetWorld();
}

 

You also need to ensure you have the line:

 

blend=alpha

 

in your material file or you won't get the transparency.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Having looked at the Wiki page on Framework your previous code looks correct: SetWorld(GetLayerWorld(GetFrameworkLayer(1)));

 

So assuming this is not bugged is there an issue with your mat file or the texture itself?

 

What exactly are you seeing when the emitter runs ? Transparent areas being rendered non transparently ? Do you have a graduated transparency or are the transparent areas 100% transparent in the texture?

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

I see something like this

 

I use:

SetWorld(GetLayerWorld(GetFrameworkLayer(1)));

TEmitter emitter = CreateEmitter(20,800,Vec3(0,0.2,0),1, _parentEnt);
PaintEntity(emitter, g_gunSmoke);  

SetEmitterRadius(emitter,0.005,0.1);
EntityColor( emitter,Vec4(1,1,1,0.1) );
SetEmitterRotationSpeed(emitter,0.1);

SetWorld(GetLayerWorld(GetFrameworkLayer(0)));

 

PS: about smoke appearance point i ask in this thread ( http://leadwerks.com/werkspace/index.php?/topic/3036-getvertexposition-usage/ ), but this is another thread :(

post-648-030829500 1288394810_thumb.png

Working on LeaFAQ :)

Link to comment
Share on other sites

Well although I've never used framework that code looks ok.

 

However, the pic you've attached shows transparency working! Its a strange banded type of transparency which is not ideally suited for smoke but its transparency none the less. You might want to look at the alpha channel in your underlying texture. Does it display the same banded transparency?

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Sorry but I have no idea what's going on then. If your texture and mat file are ok then either framework is broken or something else in your code is interfering with this for some reason.

 

I believe alpha test (only full on transparency) works in the main world but alpha blend (graduated transparency) requires the transparent world to render correctly.

 

I think you need to talk to someone who is using framework rather than framewerk to confirm transparent emitters are working correctly for them. Then maybe they could try your mat and texture files.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...