Light problems nwjs and threejs - dll

I'm having problems with the lighting in my proyect, I'm just using normal direct light.
light = new THREE.PointLight( 0xfefffe);
But the problem is that with the 0.12.3 version of nwjs the objects in the scene are black (like if there was no lights) and sometimes the start flickering in red, black and green.
If I change the original libEGL.dll and libGLESv2.dll with the ones in the 0.13.0 version of nwjs it works fine but only in some hardware... I don't know whtas going on, what can I do to make everything work just fine?
Thanks

So, this is what hardware limitation it seems. I used PowerVr device driver *.dll ( EGL and opengles ) for solution. Curious to know this problem happen on ubuntu/linux devices?
Since you are creating material which take light vector as input check on the basic material and see the result.
Plus try to make the custom material shader which has (ambient,specular, (diffused optional) ) and then see result on machine.
Since the dll contains the implemenation of gles stuff onto window machine I believe you see this issue on window itself.
Black only comes when it require light vec into fragment shader and it is not been passed so texture2D result with light of undefined give you blackish output

Related

Fullscreen mode not working in D3D12 raytracing samples

Presently I'm learning the basics of real-time raytracing with the DXR API in DirectX 12 Ultimate. I'm studying the D3D12 raytracing samples on the official GitHub and am using an i9/Intel Iris Xe/RTX3070 laptop and building the programs in VS2022.
Since the samples were written for Windows 10 and I'm using a hybrid graphics PC, a Debug build will run in Windows 11 after adding D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_COMMAND_LIST_TYPE to D3D12_INFO_QUEUE_FILTER during device creation (see DirectX 12 application is crashing in Windows 11). The only trouble is that none of the sample programs change to fullscreen (i.e. borderless windowed) mode when pressing the Alt+Enter key combination. The programs always stay in windowed mode.
This hasn't worried me so far, because I've been copying the raytracing code over to a template (based on DirectX Tool Kit for Windows desktop) where fullscreen toggling works properly. In this way, I was able to run the HelloWorld and SimpleLighting samples successfully in both windowed mode and fullscreen (2560x1440 monitor resolution).
However, this hasn't been so successful for the ProceduralGeometry sample, which introduces intersection shaders. Once again, the original sample program renders the scene properly, but only in a bordered window. But when the code is reproduced in the template where I can toggle to fullscreen, the raytraced scene does not render properly.
In the scene, the triangle geometry used for the ground plane of the scene renders ok, but a translucent bounding box around the fractal pyramid is visible, and all other procedural geometry also appears translucent. Every couple of seconds, the bounding box for the metaballs also appears briefly, then vanishes.
I was able to determine that by freezing the scene, the reason for the translucency was that the following frames were being presented in sequence:
triangle ground plane quad only
floor geometry plus opaque fractal pyramid bounding box
all of the above plus opaque metaball bounding box
completed scene with opaque geometry and no bounding boxes
At the native framerate (165Hz on my machine), this results in both the procedural geometry and bounding boxes always being visible, but 'see-through' due to all the partially complete frames being presented to the display. This happens in both windowed and fullscreen modes, but it's worse in fullscreen, because the scene gets affected by random image corruption not seen in windowed mode.
I've been grappling with this issue for a few days and can't work out the problem. The only changes I've made to the sample program are the Windows 11 fix, and using a template for proper fullscreen rendering, which the original sample ignores or doesn't implement properly.
Hopefully someone can shed light on this perplexing issue!
I found the problem. Each sample has a header file called DXSampleHelper.h. For the ProceduralGeometry sample, this header file was updated with a helper class to manage structured buffers, which is very similar to the helper class for constant buffers.
The CopyStagingToGpu() method, which consists of a one line memcpy operation in both classes, is slightly different for the structured buffer class:
memcpy(m_mappedBuffers + instanceIndex * NumElementsPerInstance(), &m_staging[0], InstanceSize());
The same method in the constant buffer class is:
memcpy(m_mappedBuffers + instanceIndex, &m_staging[0], InstanceSize());
I.e. I was missing instanceIndex * NumElementsPerInstance() and thus the procedural geometry instances within the structured buffer were not correctly aligned in GPU memory.

Cocos2d - 4inch screen displace the game

i developed a game for the iphone4. Now i got problems with the iphone5 and the 4inch screen. My game is on the left side of the 4inch screen and i have a big black border on the right side. But the buttons from the game are in the middle of screen, they have same position like on the iphone4. I checked everythin but i dont know why the background-images and the sprites are on the left side and the buttons are in the middle. I want that everything is in the middle or on the left side. It would be great if anybody could help me!! Thanks!!
COCOS2d-iPhone:
If you're using the latest beta, the only change you should need to
make is export all your images at twice the size and use the "-hd"
suffix, similar to Apple's "#2x". The documentation also says you need
to set the content scale factor of the director.
You can find the documentation here.
and more detail here.
COCS2d-X:
Cocos2D-x has a very easy solution for multi-resolution problem.
In fact you just need to set your DesignResolution and then just imagine your target device will has this resolution.
If target device really has this resolution ( or some other but with same ratio) cocos2d will handle to fix screen and your game looks same in all devices.
And when ratio of target device is different, you have many option ( as cocos2d language, policy) to manage that.
For example if you use Exact fit policy, cocos2d will force your game ( and design) to fit target device screen (without that black boarder).
Exact fit
The entire application is visible in the specified area without trying
to preserve the original aspect ratio. Distortion can occur, and the
application may appear stretched or compressed.
For more detail just take a look at this link : http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support

Detect Winks in front facing camera using CIFaceFeature

I have an app which uses AVFoundation and tracks the face, eyes, and mouth position. I use the CIFaceFeature to detect these and mark them on the screen.
Is there a simple way to detect a wink using the framework?
For iOS 7, Yes, now you can do it with CoreImage.
Here is the API diff in iOS 7 Beta 2:
CoreImage
CIDetector.h
Added CIDetectorEyeBlink
Added CIDetectorSmile
Before iOS 7:
No, there is no way with iOS frameworks (AVFoundation or CoreImage) for now.
You can check out with OpenCV... but it's more of a researchy topic, not guarantee to work well in different situations:
First, you need to build a eye close/open classifier, afaik, there is no build-in eye wink classifier in OpenCV, so you need to collect enough "close" and "open" samples, and train a binary classifier. (I would suggest using Principle Component Analysis + Support Vector Machine. Both are available in OpenCV)
Then in iOS, use CoreImage to detect the locations of both eyes. And cut a square patch image around the eye center. The size of the patch should be normalized in terms of the detected face bounds rectangle.
And then you need to convert UIImage/CIImage to OpenCV IplImage or CvMat format, and feed them into your OpenCV classifier to determine the eyes are open or close.
Finally, determine if there is a wink based on the sequence of eye open and close.
(You also need to check if the processing frame rate is able to pick a wink action: say the wink happens within 0.5 frame... then you'll never detect it...)
It's a hard problem... otherwise Apple would have already included them in the framework.

Rendering with D3D device in external DLL used in a WinPRT Xaml/DirectX sample has constant black flickering

I have a C++ DirectX-based third-party game engine compiled into a Windows Phone Runtime Component DLL. I'm working on integrating it into a project based off of a Windows Phone Direct3D with XAML App. The game engine DLL uses the the D3D device, context and render view texture provided by the application's Direct3DBackground::Draw() method.
The built-in renderer from the sample is gone and replaced by the game engine's.
I can render but there is constant black flickering. Every other frame is black. To prove to myself that it wasn't the renderer (which has been proven to work elsewhere), I cut out all the rendering code from the game engine DLL to a simply setting a clear color. The result is still the same.
At first I thought it was because the Direct3DXamlAppComponent generated by the sample was maybe running in a different thread from the game engine DLL, but that's not the case. They're on the same thread.
What rendering problem could this configuration be causing?
Does the game engine's renderer need a separate d3d device?
Does the game engine's renderer need a separate d3d device context?
Things I haven't tried yet:
creating a second d3d device on the DLL
converting the game engine to provide its own IDrawingSurfaceManipulationHandler. But I'm not sure if it'll just have the same problem as above.
The problem came from the render target view. I didn't realize that the pointer to it gets updated every frame. I had just set it to the game engine renderer once at start up. Now I update the render view target pointer every frame and now the black flickers are gone.

How do I stop Cocos2D from requiring standard definition resources (SD images)?

I am developing an iPhone game with Cocos2d-iphone.
I want my game to only be available to the iPhone 4 AND iPad. Retina enabled for iPhone 4. I don't want the game to run on older devices.
Cocos2d will always ask me for -hd and non-hd files. If I don't provide the SD files, I get errors. I don't want that: is there a way to disable Cocos2d from trying to retrieve SD files, and only get -hd suffixed files by default?
Oh, and when the game is run by an iPad, the graphics will be the -hd ones as well. So the point is, I only want to have -hd files in my project.
What are the proper steps to edit Cocos2d's source for such?
If you are using cocos2d version >= 2.0, then you can change the value of a global variable found in CCFileUtils.h:
static NSString *__suffixiPad =#"-hd";
(Its default value is #"-ipad".)
If you are using cocos2d version < 2.0, then you can find here a category that I wrote to be able to transparently use -hd images created for the iPhone 4 on the iPad 1/2.
Actually, it does more than that, but if you add it to your project, then "-hd" images will be "automagically" used on the iPad 1/2 instead of their SD versions (which you could also not include in your project).
Let me know if you have any issues integrating this code.
If I would have been at your place.. I would have played with a trick.. Don't down vote the answer if you don't like.. But Its just a thing in my mind.
Use -hd images in the code directly.. iPhone 4 will handle it easily.. Older iPhones will show it much larger and it doesn't matter as you are not supporting them...
So instead of using Background.png , directly use Background-hd.png as it will work fine for iPhone 4.. Instead of wasting time on all these SD stuff.. I will directly use my -hd images for my work...
I can not say about new iPad.. But old iPad can easily use -hd images in code as you want.. For iPad I have directly used in my code earlier..
Hope this helps.. :)
This tutorial might help.
If you only provide -hd assets, you should only get errors regarding missing SD assets when running on iPad. The iPad doesn't have a Retina display, but it certainly is high resolution enough to be treated like one.
Since cocos2d passes all filename requests through the fullPathFromRelativePath function in CCFileUtils it may be enough to modify this function to treat the iPad like an HD device and force it to load -hd assets on iPad.
the 1st idea i can think of is to use #2x suffix for images (UIKit style) and you wont need to enable retina display in app.The problem is that on the ipad you'll have to write your own method to remove #2x suffix
the 2nd idea was to make a SD image..but only 1x1 pixels... it takes virtually no space at all ( 119 bytes with white pixel). Should work on ipad as-is
3rd idea:don't enable (or enable..doesn't make any difference) retina display but have the HD images as SD images.I've tested this on cocos2d v1.0.1 and it seems to work.Also..it should work on ipad
4th idea forcefully enable retina display in ccConfig.h (so that director won't ask you for the SD images on ipad) .I'm not sure about this one because there are quite a few tests that check for resolution, device and if it's retina and you'd have to edit all of them
these are just ideas off the top of my head..they may be wrong..but they're just ideas