I'm working at galery on o3d(plagin version) and I need make photos transparent. Photos are on hud. Here is some code:
g_canvasInfoPict = o3djs.canvas.create(g_pack, g_hudRoot, g_hudViewInfo);
alphaParam = g_canvasInfoPict.transparentState_.getStateParam("o3d.AlphaReference");
alphaParam.value = 0.5;
alphaParam = g_canvasInfoPict.transparentState_.getStateParam("o3d.BlendAlphaEquation");
alphaParam.value = g_o3d.State.BLEND_SUBTRACT;
alphaParam = g_canvasInfoPict.transparentState_.getStateParam("o3d.SourceBlendFunction");
alphaParam.value = g_o3d.State.BLENDFUNC_ONE;
paramOne = g_canvasInfoPict.transparentState_.getStateParam("o3d.DestinationBlendFunction");
paramOne.value = g_o3d.State.BLENDFUNC_DESTINATION_ALPHA;//or BLENDFUNC_SOURCE_ALPHA or BLENDFUNC_SOURCE_ALPHA_SATUTRATE or BLENDFUNC_ONE or BLENDFUNC_ZERO
g_fullPictCanvas = g_canvasInfoPict.createXYQuad(paddingX, paddingY, -14, g_fullPictTexture.width, g_fullPictTexture.height, true);
g_fullPictCanvas.canvas.drawBitmap(g_fullPictTexture, 0, g_fullPictTexture.height);
g_fullPictCanvas.updateTexture();
But it doesn't work. When setting paramOne.value = BLENDFUNC_ZERO photo displays (non-transparent)
paramOne.value = BLENDFUNC_ONE photo isn't displayed (full transparent)
So how to achive intermediate result?
Given that the O3D plug-in is deprecated in favor of the WebGL-based O3D, is it an option for you to migrate to the latter?
If so, you can inquire in the discussion group about the transparency issue (if it still exists under O3D-WebGL). The developers are very responsive.
Related
I'm trying to set up a background in my game, and I want it to support multiple resolutions. I've tried using the scale trigger, but I'm pretty sure it multiplies the dimensions by the value. I need to resize the background by the resolution, so that won't work. Here's my code right now:
bgImage = new FlxSprite();
bgImage.loadGraphic(AssetPaths.SP_LevelBG__png, false, FlxG.width, FlxG.height);
bgImage.width = FlxG.width;
bgImage.height = FlxG.height;
add(bgImage);
Thanks in advance.
Use scale: https://snippets.haxeflixel.com/sprites/scale/
bgImage.scale.x = 10;
bgImage.scale.y = 10;
I have some discrepancies in terms of brightness, saturation and hue when using a jpg picture in Manim.
I have a picture which color profile/space is Adobe RGB. I create it, edit it and save it that way. All of my apps previewing the picture are more, or less consistent with the original (enough to be acceptable). Including a movie export test from After effects. Even the image previewer of VS Code shows the image correctly. But when I render it with Manim, it's no good. Way too bright, oversaturated with a slight shift in hue and as if it was downgraded in terms of quality (some subtle but weird color artifacts are showing). You can tell something is off.
Granted, the picture I try to use is an abstract background with subtle gradients of color and light but still. The overall difference and loss in quality are sufficiently there not to be acceptable.
I know that managing color spaces and profiles is a bit tricky and is an art in and on itself but the problem here is that the image is consistent everywhere so far but in Manim's rendered MP4 file.
The only thing I've seen in the doc related to color spaces is this parameter "image_mode". I tried to set it both to RGB and RGBA (only two options available) in the Manim script but it doesn't change anything.
I suspect it's a feature that is more related to the renderer (Cairo) or the MP4 export parameters than Manim itself or maybe it downgrades jpg to gif/png before it renders the picture in Mp4 ? I don't know and I don't know what to do with that anyway since I don't know how to parameter any of this within Manim itself. I can't see any parameters that allow to edit any of this in the doc.
Maybe a plugin could add some functionalities or something ?
Any help would be appreciated.
PS: the picture is 4k and I render it in 4k in Manim, so it should be a pixel to pixel match.
Here is my Manim script:
from manim import *
class Graph(Scene):
def construct(self):
bg = ImageMobject("media/background/13.jpg")
self.add(bg)
self.wait()
And here are the relevant parts of my manim.cfg
[CLI]
write_to_movie = True
format = mp4
save_last_frame = False
write_all = False
save_pngs = False
save_as_gif = False
preview = False
background_color = #212021
background_opacity = 1
renderer = cairo
use_webgl_renderer = False
webgl_renderer_path =
use_opengl_renderer = False
enable_gui = False
gui_location = 0,0
fullscreen = False
window_size = default
window_monitor = 0
force_window = False
use_projection_fill_shaders = False
use_projection_stroke_shaders = False
movie_file_extension = .mp4
frame_rate = 60
frame_size = 3664,1980
pixel_height = 1980
pixel_width = 3664
max_files_cached = 100
flush_cache = True
disable_caching = True
disable_caching_warning = False
enable_wireframe = False
dry_run = False
tex_template =
plugins =
TL;DR: Some random pointers, but no answer to the question.
I have no clue about manim, so I just went searching for "JPEG" in its source code. That brought me to https://github.com/3b1b/manim/blob/3c7a38660af41478e1561073a5319b23fb6b7787/docs/source/documentation/custom_config.rst#L59 which says
The directory for storing raster images to be used in the code (including .jpg, .jpeg, .png and .gif), which will be read by ImageMobject.
Okay, what's ImageMobject? Another search found the place where it loads images and apparently this just uses the Python library PIL to call PIL.Image.open: https://github.com/3b1b/manim/blob/669182944da040c227ccfd018250ee2bbc49649d/manimlib/mobject/types/image_mobject.py#L31
Okay, so does this support color profiles? I don't know. What does this question even mean? You are loading some color image that contains a color profile and it ends up being part of a movie... Should the movie now use that color profile?
Another random pointer that I found is PIL/Pillow decode icc profile information but that didn't really help. All I can say is: The manim code that I found doesn't do anything fancy with color profiles.
I am able to open a 3DS file in MeshLab and when I export to Collada DAE format the textures are visible but they are not being projected onto the mesh in the same way as the preview in MeshLab. For example, the front/back faces of a cube would have the proper texture (suppose it's a polka dot) but the top and bottom have a striped look. How can I apply a single texture and have it appear as intended on all faces, like the imported model before I convert it?
This problem is a result of the end software being used to view the DAE file. It's not a problem with MeshLab.
For example, if loading the file into Away3D be sure to handle the texture materials using the TextureMaterial class instead of the simpler SinglePassMaterialBase such as what you might find in their example code. Here is what I use now, and it displays texture properly:
var material:TextureMaterial = cast(asset, TextureMaterial);
material.ambientColor = 0xffffff;
material.lightPicker = _lightPicker;
material.shadowMethod = new FilteredShadowMapMethod(_light);
material.lightPicker = _lightPicker;
material.gloss = 30;
material.specular = 1;
material.ambient = 1;
material.repeat = true;
I re-programmed a HTML5 game (using createJS) to match StageGL, but it turned out all text fields disappear. Switching back to Stage solved this specific problem (see code example below).
Does anyone know a workaround to this?
Example code:
canvas.width = stageWidth;
canvas.height = stageHeight;
stage = new createjs.StageGL(canvas); // <= text does not work with GL???
stage = new createjs.Stage(canvas); // <= text works fine
var textTest = new createjs.Text("Hello World");
textTest.x = 10;
textTest.y = 20;
stage.addChild(textTest);
Thanks in advance for your comments!
Text will not work without being cached, as the Text/Vector canvas APIs are not supported by StageGL.
Caching is pretty easy:
var bounds = text.getBounds();
text.cache(bounds.x, bounds.y, bounds.width, bounds.height);
When the text changes, you will need to recache the text.
Cheers,
I've noticed that the OM Script gets commented when I add a bitmap in either the Icon/Diagram View.
I'm using OpenModelica 1.9.1+dev (r18667) (RML version)
Code for reference
model Test
annotation(Diagram(coordinateSystem(extent = {{-100,-100},{100,100}}, preserveAspectRatio = true, initialScale = 0.1, grid = {2,2}), graphics = {Bitmap(origin = {0.12,-0.47}, extent = {{-99.77,99.65000000000001},{99.77,-99.65000000000001}}, fileName = "modelica://Test/C:/Users/MSK/Desktop/Capture.PNG")}));
end Test;
This may be a bug. Hence I've reported it
OpenModelica bug reports should be reported at: https://trac.openmodelica.org/OpenModelica/newticket
And yes, it is a bug so it does not really belong on stackoverflow.