SgDecalProjector != distance fog
by Caylo Gypsyblood · in Torque Game Engine · 11/26/2006 (5:11 am) · 31 replies
#22
12/04/2006 (1:14 am)
Thank you much for this Alex, i have fresh angles to explore now, some old assumptions to toss out, and a few new mystery's to ponder over.
#23
Trying to get the decal's position, but it is returning the world box center... I cant find anything that gives up the decal's location. And i do not know how to get data from the data block...
12/04/2006 (1:07 pm)
I am using :F32 dist = (getObjBox().len_x() + getObjBox().len_y() + getObjBox().len_z()); Point3F cameraOffset; mObjToWorld.getColumn(3,&cameraOffset); cameraOffset -= state->getObjPosition(); dist = cameraOffset.len(); F32 fogAmount = state->getHazeAndFog(dist,cameraOffset.z);
Trying to get the decal's position, but it is returning the world box center... I cant find anything that gives up the decal's location. And i do not know how to get data from the data block...
#24
I must admit i was totally deceived by the "PROJECTOR" part of decal projector. It dont ACT like a projector, you know project an image ONTO something.
Well, thanks for the help folks. Even if i had to kick it down the hill like a catherine wheel with a fat witch tied to it....
(PS: ya it is alot more overhead, but now that the 'projection' image fog out correctly, also occlusion works, it is actually a big boost to my overall in game frame rate.)
12/04/2006 (4:32 pm)
Ok, i got what i wanted. But i used Melvyn May's fxRenderObject, its not at all hacked into the rendering system, and so much easier to get control over, plus i learn a bit more about the mainstream way Torque render things. I must admit i was totally deceived by the "PROJECTOR" part of decal projector. It dont ACT like a projector, you know project an image ONTO something.
Well, thanks for the help folks. Even if i had to kick it down the hill like a catherine wheel with a fat witch tied to it....
(PS: ya it is alot more overhead, but now that the 'projection' image fog out correctly, also occlusion works, it is actually a big boost to my overall in game frame rate.)
#25
So im back to the projector... And i have scaled back my hopes and dreams for it. ALL i want now is to turn the projector OFF when the fog level reach 33%.
I have placed THIS: into the top of void DecalManager::renderObject(SceneState* state, SceneRenderImage*)
THIS:
But it is caculating from world space 0,0,0. What silly little thing am i overlooking here?
12/04/2006 (11:35 pm)
UGH. Mel's renderobject was neat and fun to fiddle with. But it only took a little bit of time converting my missions over from the Decal Projector to the render object, for me to realize how futile that task was. Placeing the render objects just where i want them took alot of work and time. So im back to the projector... And i have scaled back my hopes and dreams for it. ALL i want now is to turn the projector OFF when the fog level reach 33%.
I have placed THIS: into the top of void DecalManager::renderObject(SceneState* state, SceneRenderImage*)
THIS:
Point3F cameraOffset;
getRenderTransform().getColumn(3,&cameraOffset);
cameraOffset -= state->getCameraPosition();
F32 dist = cameraOffset.len();
if (dist < 0.01)
dist = 0.01;
F32 fogAmount = state->getHazeAndFog(dist,cameraOffset.z);
if (fogAmount>0.33f)
return;But it is caculating from world space 0,0,0. What silly little thing am i overlooking here?
#26
12/05/2006 (12:03 am)
The decal manager renders decals, but it is not itself a decal. All decals are stored by the decal manager in mDecalQueue, and are rendered in DecalManager::renderDecal(). Therefore, you must do fogging calculations inside the loop which actually renders decals, and you must do them for each and every individual decal.
#27
So, what can a person do that is using the decal projector to add signs, scruff marks, weeds in my grass, and a big bunch of other things, but they are glowing from beyond the fog making all the neat little details stick out in an ugly way, what can i do to lessen the unforeseen side effect?
And if i am not using the projector the way it was expected.. What is it there for?
12/05/2006 (12:13 am)
Oh my! This do not sound very efficient. So i guess this is where one would also test for occlusion? Why didnt someone say this days ago? Oh this is funny. So, what can a person do that is using the decal projector to add signs, scruff marks, weeds in my grass, and a big bunch of other things, but they are glowing from beyond the fog making all the neat little details stick out in an ugly way, what can i do to lessen the unforeseen side effect?
And if i am not using the projector the way it was expected.. What is it there for?
#28
Just figure i should now ask before spending a few more hours experimenting on it....
12/05/2006 (12:19 am)
How do the decal aging work? Could i plug some type of fog level cut off into the DecalManager::prepRenderImage? Just figure i should now ask before spending a few more hours experimenting on it....
#29
Regarding the render transform, you'll need to get the distance from the current scenegraph camera position and the decal position - the scenegraph info is passed into the decal manager render call (see SceneState::getCameraPosition()).
You need to get the fog amount based on camera and decal position (also available in SceneState), then set the fog coord in OpenGL. It should be relatively efficient, at least compared to the rest of decal rendering.
12/05/2006 (8:01 am)
You're probably better off adding fog into the rendering pass. I did mention the rendering pass earlier - from above:Regarding the render transform, you'll need to get the distance from the current scenegraph camera position and the decal position - the scenegraph info is passed into the decal manager render call (see SceneState::getCameraPosition()).
You need to get the fog amount based on camera and decal position (also available in SceneState), then set the fog coord in OpenGL. It should be relatively efficient, at least compared to the rest of decal rendering.
#30
It do not seem to matter where i plug this code in, i can not seem to get a hold of the the projectors location, i keep ending up at the world box center, (and i must say it works great when i put the projector within sight of the worldbox center, and run back/forth getting the projector to fog off.)
But it dont matter anymore. I went back to Mel's render object and spent the night repositioning all my PROJECTORS as render objects, in my now just one 'demo' mission. I have 5.5 more hours to polish up what i can before showing it off to a publisher later today, and 3 of that must be wasted with sleep.
12/05/2006 (8:32 am)
Thank you. I do have the ability to get the fog amount information that i seek. Point3F cameraOffset;
getRenderTransform().getColumn(3,&cameraOffset);
cameraOffset -= state->getCameraPosition();
F32 dist = cameraOffset.len();
F32 fogAmount = state->getHazeAndFog(dist,cameraOffset.z);
if (fogAmount>0.33f)
return;It from tsStacic.cc and i have used it in several other places to cull things out before they actually pass beyond the distance fog(so i can have LONG line of sight, and still turn some not so noticeable things 'off'). The problem here is i can READ code just fine, and i understand WHAT is going on- but dont understand HOW it is doing it. It do not seem to matter where i plug this code in, i can not seem to get a hold of the the projectors location, i keep ending up at the world box center, (and i must say it works great when i put the projector within sight of the worldbox center, and run back/forth getting the projector to fog off.)
But it dont matter anymore. I went back to Mel's render object and spent the night repositioning all my PROJECTORS as render objects, in my now just one 'demo' mission. I have 5.5 more hours to polish up what i can before showing it off to a publisher later today, and 3 of that must be wasted with sleep.
#31
Anyhow, thanks for all the help with the projectors, i may get back to them down the road a bit.
12/05/2006 (3:23 pm)
Just a quick follow up. I feel my 'demo' went smooth. They may hire me for contract work, but are not interested in my game, as they called it a 'kids' game and they do not do 'kids' games. Anyhow, thanks for all the help with the projectors, i may get back to them down the road a bit.
Associate Alex Scarborough
All renderable objects must inherit from SceneObject. ShapeBase is the first object that does useful stuff in addition to rendering, but not is a requirement for rendering. See TSStatic for an example (engine/game/tsStatic.cc).
A specialized decal system is used because decals really don't need all that much, and having a specialized system allows us to do things much much faster than running it through ShapeBase would. Imagine how much it would suck if all of your Decals were ShapeBase objects. Tons and tons of resources down the drain right there for things decals don't need and will never use.