joseph.howell Posted May 31, 2016 Share Posted May 31, 2016 Hi, I have an ObjectGui in my scene that is playing a video stream. It is taking on the lighting of the scene...how do I make it unlit such that I just see the video as it exist in the file with no additional lighting. (The lighting is currently blowing out the video). Thanks Link to comment
silent Posted June 1, 2016 Share Posted June 1, 2016 Hi Joseph, Could you please provide a minimal test scene with that issue? I can't reproduce it with built-in GUI samples in <SDK>/data/samples/objects/gui_00. No matter how many lights I in scene I always get the same result for video. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
joseph.howell Posted June 1, 2016 Author Share Posted June 1, 2016 Hi Silent, I looked at some of the sample apps, and yeah, you're right the video isn't getting blown out. I guess I had assumed it was the lighting blowing things out. A minimal sample app would be a little tricky to give you. Let me tell you what we're doing. Ok, the ObjectGui doesn't actually have a WidgetSpriteVideo on it, just a WidgetSprite. The video we are feeding to it is actually coming from a camera. We are using OpenCV to capture video from the camera and feeding it to Unigine. For some reason this is blown out and I must have incorrectly assumed it was coming from the lighting. I'll see if I can figure where else it is coming from. Thanks Link to comment
joseph.howell Posted June 1, 2016 Author Share Posted June 1, 2016 I have confirmed that this is not caused by lighting, as I removed all the lights in my scene and the image comes in as the same, blown out image. I have also confirmed that the pixels I am reading from the image frame in OpenCV are the same as my source material. I did this by taking a screen capture of my video feed in another app, and opening it in Microsoft Paint and looking at the RGB values of the pixels, and comparing that to the pixels as they come from OpenCV, that I feed into the Image I use in my WidgetSprite. So my thought is -- could this be gamma correction? Could this be HDR? Link to comment
joseph.howell Posted June 1, 2016 Author Share Posted June 1, 2016 Ok, I have an example for you. The following code indicates the problem. I created a fresh project in the browser and just use the default world the browser creates. Look at my code below. I am creating a texture that should have colors from 0 to 255 in each channel. When you look at this in-game, it looks ok, but if you take a screen capture and use an color-grabber tool in a paint program, you'll find that the colors get saturated long before they reach the right side of the texture. #include <UnigineEngine.h> #include <UnigineObjects.h> #include <UnigineWidgets.h> #include <UnigineMathLib.h> #include "AppSystemLogic.h" #include "AppWorldLogic.h" #include "AppEditorLogic.h" using namespace Unigine; using namespace Unigine::Math; /* */ #ifdef _WIN32 int wmain(int argc,wchar_t *argv[]) { #else int main(int argc,char *argv[]) { #endif Unigine::EnginePtr engine(UNIGINE_VERSION,argc,argv); ObjectGuiPtr object_gui; WidgetSpritePtr sprite; ImagePtr image; bool markerFound = false; const int IMAGE_WIDTH = 256; const int IMAGE_HEIGHT = 3; object_gui = ObjectGui::create(IMAGE_WIDTH / 100.0, IMAGE_HEIGHT/10.0); object_gui->setMaterial("gui_base", "*"); object_gui->setProperty("surface_base", "*"); GuiPtr gui = object_gui->getGui(); sprite = WidgetSprite::create(gui); gui->addChild(sprite->getWidget(), Gui::ALIGN_EXPAND); image = Image::create(); image->create2D(IMAGE_WIDTH, IMAGE_HEIGHT, Image::FORMAT_RGB8); for (int y = 0; y < IMAGE_HEIGHT; y++) { for (int x = 0; x < IMAGE_WIDTH; x++) { image->set2D(x, y, Image::Pixel(y == 0 ? x : 0, y == 1 ? x : 0, y == 2 ? x : 0, 255)); } } sprite->setLayerImage(0, image, 1); object_gui->setWorldTransform(translate(0,-1,.5)*rotateX(90.0)); while (!engine->isDone()) { engine->update(); engine->render(); engine->swap(); } return 0; } Link to comment
joseph.howell Posted June 1, 2016 Author Share Posted June 1, 2016 Ah, here's an even better example. If you just change this line in my code above to be a solid color, like this: image->set2D(x, y, Image::Pixel(200, 200, 200, 255)); And then take a screen grab of the image, and then use a color grabber tool in a paint program, you'll see that the RGB values are 249,249,249 instead of 200,200,200. Is there a way to get rid of any kind of gamma correction/HDR lighting etc on a particular object? I just want that gui object to be the exact color of our video feed. Thanks Link to comment
silent Posted June 2, 2016 Share Posted June 2, 2016 Hi Joseph, I'm afraid - this is correct behavior. WidgetSprite object that placed in scene will take in account all the post effects that currently enabled. So, to get the correct image pixel values you can force disable all the post effects by console command - render_skip_post_materials 1. In that case you will currently have 206 206 206 value on your WidgetSprite due to small bug in GUI shader (incorrect sRGB correction). How that WidgetSprite is used in scene? Could you please give us some screenshot with current usage? I assume that it placed in the background and doesn't interact with the scene? Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
joseph.howell Posted June 2, 2016 Author Share Posted June 2, 2016 Um yeah, I can't actually send a screen shot today because I'm working from home. But we're basically making a composite. We have a video feed coming in from a camera that we are putting in the background. I do this by basically sizing the ObjectGui and rotating it such that it always fills the entire screen. Then we render objects in front of it. If we align our 3D camera with the position and orientation of our actual camera, we are able to put 3D objects into our camera feed. Anyways, I have a "fix" for the problem. I output a texture like the one I showed above, just a grayscale image with all the colors from 0-255. This allows me to create a map. So, say I want the color 255, I index into the array map[255], and it gives me 192. Then unigine takes that and brightens it back up to 255 again. This isn't ideal, but it does work, making our video stream the same intensity as it is in the input. The disadvantage is that there isn't as much color resolution this way. It turns 24 bit RGBs into colors that look to be about 16 bit. I don't know if I can remove all post processes since that would have the same darkening effect on our entire scene, but I'll ask what the bosses prefer -- decreased color resolution in the video feed, or darker 3D objects. Thanks Link to comment
deepak.tripathi Posted June 6, 2016 Share Posted June 6, 2016 Use object_gui->setmaterialstate("mode",2,0) for object gui's Link to comment
Recommended Posts