Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I'm having an issue with creating a skyBox scene node using the c++ win32player source code. I have partial success but the skybox textures have a "whitewash" effect or over exposed to almost white. I can see the skybox is created and the textures are loading. Using the following code below within the CPlayer.cpp constructor method:
Also, why is it not possible to create scene nodes in javascript instead of the editor, to create say cubes and spheres or even watersurfaces and skybox etc.. Is it for any reason ? The above code works without any problems when using the Irrlicht sdk directly but an almost white sky texture when compiled with Coppercube sdk. Any ideas or solutions anyone ?? Thanks! |
||||
|
Maybe you've already solved the problem. Nevertheless, I am throwing in some questions & ideas (since I don't have access to the CopperCube game-client C++ code): - Could the "raw" Irrlicht SceneNode creation be bypassing some setup in the CopperCube framework? - Can you check if there is a class named "CFlaceSkyBoxSceneNode" that can be used to create the skybox? - Another clue: check the C++ CopperCube code base for references to "EFSNT_FLACE_SKY_BOX" - In Irrlicht there was a class named "CDefaultSceneNodeFactory" that contained valuable info on how to spawn SceneNodes. Try to find a similar class (probably starting with or containing the string "CFlace") for the CopperCube framework and use it as inspiration. - Is the initialization phase of the engine already completely finished when your code gets executed? Is it possible that follow-up init code from the CopperCube SDK runs right after this and overwrites your material or scene settings or introduces unwanted changes to your setup? Is it possible that the CopperCube SDK spawns a default light or skybox or modifies the fog and global light settings without your knowledge? Note: In Irrlicht & CopperLicht, skybox materials appear to be initialized with specific material settings and in both systems, skyboxes also use a special rendering path. - Is it possible that the compiled custom exe loads a default scene without your knowledge? - Is an unintended light source overexposing the skybox? An effect matching your description can be recreated in vanilla CopperCube by enabling "Dynamic Lighting" on a default skybox and dropping a point light with a large radius (> 6000) into the scene. - Does the issue persist across DirectX & OpenGL rendering drivers? |
||||
|
Guest2 wrote: Maybe you've already solved the problem. Nevertheless, I am throwing in some questions & ideas (since I don't have access to the CopperCube game-client C++ code): That's quite a few possible reasons and I will go through each of them and see if any of them help. I would not be doing this in C++source code if it was possible to do using javascript. Thanks for your input on this and you appear to have to great knowledge of the engine and source code. How do you know all this without having the C++ client engine code ?? |
||||
|
Ok, I've made some progress with this but the results are still not what expected (skybox texture is still overexposed white washed) The client C++ sourcecode file CSpidermonkeyScriptEngine.cpp contains the following line that was commented out from use in javascript:
I've uncommented this line and other places in code where it was commented out and I can now successfully call this function from Javascript to create most of the default node types. So to create a cube I use:
To create a water surface I use:
And to create a skybox I use:
I still work out a way to add the textures to these node objects though. But it makes me wonder why the developer (Niko) left out this very useful script function ??? |
||||
|
Forgot to mention that the numbers (0,0,0) in those function calls above are the x,y,z position values. I don't think the issue is with lighting as I have a default skybox already in the scene that I can disable and enable perfectly fine without the whitewashed textures. Appears to be with the colors as the skybox textures are visible and loading. |
||||
|
A single line of code has fixed the problem by changing the material type as follows:
The code comments for this function explain this:
I still don't understand why this material type works but EMT_SOLID does not ?? |
||||
|
Excellent write-up, gazzauk! It seems strange that you need to manually adjust material settings. One would expect that everything should work out-of-the-box, like it did in your Irrlicht tests. Keep in mind that the default skybox may use specific material flags! Leverage ccbAddSceneNode() and check how it works internally when creating the skybox. This will hopefully reveal the exact configuration steps expected by CopperCube. If you really want to go further with the manual material setup approach: Try something like this with material type EMT_SOLID (the code below is untested and based on Irrlicht 1.7.3):
For context, here is how the original Irrlicht 1.7.3 source sets some important default CSkyBoxSceneNode material settings:
|
||||
|
Guest2 wrote: Excellent write-up, gazzauk! It seems strange that you need to manually adjust material settings. One would expect that everything should work out-of-the-box, like it did in your Irrlicht tests. Keep in mind that the default skybox may use specific material flags! Hey, thanks for the code snippets but none of your suggested code methods worked at setting the texture correctly. The only material types that have worked so far are:
and
I've tried every possible one of them in many different orders and places. Including your suggestions above. I've no idea how the editor adds a skybox to the scene or what initialization materials and flags are used. If I use the same skybox code in pure Irilict SDK it works out of the box like you say, without changing any materials or flags. |
||||
|
At this point, the idea with using the EMT_SOLID_2_LAYER and EMT_LIGHTMAP seems to be the right course of action. You have discovered a solid workaround and narrowed down the cause of this issue. Notes on the material types: EMT_SOLID: Modulates the texture with lighting, material & vertex colors. Leads to the over-exposure effect on the skybox. Modifying material settings doesn't seem to have any effect. EMT_SOLID_2_LAYER: Uses the vertex alpha channel to blend 2 textures. EMT_LIGHTMAP: Blends 2 textures (color texture, lightmap). Both material types focus strictly on texture blending. No influence from material colors, lighting, vertex RGB colors. Without a second texture, both material types should cleanly draw the first texture. Note: Contrary to the code comment about EMT_SOLID_2_LAYER not being implemented in OpenGL, it appears to be fully implemented in Irrlicht 1.7.3. Since you have uncovered the ccbLibAddSceneNode() function in "CSpidermonkeyScriptEngine.cpp", examine the function body in the C++ source code to see how the engine handles the node creation. At each of the following steps, check if the skybox SceneNode is modified by the framework. 1. ccbLibAddSceneNode() - Check how it parses the javascript arguments and extracts the "skyBox" string via attr->getAttributeAsString(argument_index) (useful for receiving filepath strings in your own script-functions). Check the code section handling the "skyBox" string. Does ccbLibAddSceneNode call a special SceneNodeFactory or the SceneManager (smgr)? 2. SceneNodeFactory->addSceneNode("skyBox") - this will likely only call the SceneManager (smgr) next 3. SceneManager->addSkyBoxSceneNode() - Check if the framework calls the standard Irrlicht constructor or a custom one: Irrlicht: new CSkyBoxSceneNode(...) CopperCube: new CFlaceSkyBoxSceneNode(...) 4. Also, check what is happening inside the SkyboxSceneNode constructor method. This call path must contain a clue on how the framework handles the skybox initialization. Compare it to your initial code. If there is nothing handled differently, the framework appears to bypass / break the standard Irrlicht pipeline without hinting this to the C++ user via clarifying comments. The game-client may rely on ccb-files & the editor to provide readily configured SceneNodes - and your workaround remains to be the only viable option when dynamically creating skybox nodes. This would also indicate that one would need to find the correct base config for each SceneNode type, which seems a bit off. |
||||
|
Guest2 wrote: At this point, the idea with using the EMT_SOLID_2_LAYER and EMT_LIGHTMAP seems to be the right course of action. You have discovered a solid workaround and narrowed down the cause of this issue. the framework appears to bypass / break the standard Irrlicht pipeline without hinting this to the C++ user via clarifying comments. The game-client may rely on ccb-files & the editor to provide readily configured SceneNodes - and your workaround remains to be the only viable option when dynamically creating skybox nodes. This would also indicate that one would need to find the correct base config for each SceneNode type, which seems a bit off. Yes, you are correct to see that the framework is not using the standard Irrlicht pipeline in some cases. Since you have uncovered the ccbLibAddSceneNode() function in "CSpidermonkeyScriptEngine.cpp" Yes, I discovered this in the source code but it was commented out and not fully implemented. I added all those extra node string functions. They are boiler plate code at the moment. |
||||
|
One more idea. Build a minimal custom C++ "myAddSceneNodeCube" function and expose it to the javascript engine. The code snippets below are untested, may contain improper syntax and will probably not compile as-is. They are meant as inspiration and to give you a starting point. Sources: YouTube tutorials by Saturn7/Robbo & Glitched Velocity/JIC/just_in_case, and forum posts by "Any Guy" (highly recommended!) Warning: Without access to the CopperCube C++ game-client code I was unable to properly test & validate any of this. Scope & namespaces may be problematic. Expect compiler warnings & errors. Also, the sources I used may have demonstrated heavily modified codebases, so some things in the snippets below may simply not exist in the vanilla CopperCube framework. Make sure to add proper safety- & pointer-checks everywhere. General info: Executing javascript-snippets from C++: With access to a valid Scripting-object, it seems like you should be able to run javascript from the C++ side. Looks like a powerful tool, but I don't know if this is safe to use in the scope of a C++ scripting function.
Building the skeleton "myAddSceneNodeCube"-function: The goal is to expose the following scripting-function in javascript: myAddSceneNodeCube(custom_name, size, x, y, z, parentnode_name, texture_path);
Open up the "CSpidermonkeyScriptEngine.cpp" file. Function registration: Add this to the list where the other registration-calls are in "CSpidermonkeyScriptEngine".
Add the C++ function declaration to the header-file ("CSpidermonkeyScriptEngine.h"). Check if the following declaration is correct. If not, adjust the follow-up code accordingly.
Start of the function:
|
||||
|
Part2. Get the parameters from javascript:
Get SceneManager and video driver:
Create the node & adjust it. This probably creates an "unmanaged" loose Irrlicht SceneNode, not properly registered in CopperCube. Physics & properties may or may not work. Possible clues for proper implementations (probably needs deep digging into the functions): ccbCloneSceneNode(), ccbRemoveSceneNode(), ccbLibAddSceneNode()
|
||||
|
Part3. Texture loading. This uses a relative file-path and probably creates an "unmanaged" texture. - A better way to resolve local assets must exist. - Proper implementations can probably be found in the C++ implementations of the js-functions ccbLoadTexture() and ccbSetSceneNodeMaterialProperty()
End of the function:
Well, that's all. |
||||
|
One thing: I commented out the following line in Part 3:
This will prevent the following snippet from working as expected:
Why did I do this? Because I think it may be safer to not use the setReturnValue() until one can be sure that the node is created correctly. Instead, while debugging it may be better to rely on ccbGetSceneNodeFromName() in javascript to get a reference to the node. |
||||
|
I like it, not tried any of what you suggested yet but as an initial idea I can't see why the code wouldn't work. I will look into what other coppercube functions return for nodes given your suggestion about the return value from scriptEngine->setReturnValue(node); I'm having a little coding break at the moment and working on some model designing, it's much less frustrating. Thanks for the advice. |
||||
|
|