Ah! Thanks, I see you pointed the arrow at the problematic spot in your first post, I didn’t look at it carefully enough OK, I see the problem and I understand what you want (from the movie),
As for:
→ these settings are definitely controlled by the RenderOptions
mentioned above. You can set equivalent settings by
RenderOptions.BlendingSourceFactor
=bsSrcAlpha
RenderOptions.BlendingDestinationFactor
=bdOne
But indeed this, as of itself, will not give you the desired effect. The alpha of your image is not ready for this.
To make it work, you need to implement the 2nd setting you show, where from a quick glance the critical thing is “grayscale value of source primitive’s pixels will be used as an alpha value”. The way to solve this:
-
I would recommend you just process your images to set the desired alpha channel of them.
You can write a simple application using CGE TCastleImage (like castle-engine/examples/images_videos/image_convert/image_convert.dpr at master · castle-engine/castle-engine · GitHub ) that would convert images from old → new. The goal would be to set alpha in your image to grayscale value of color of the relevant pixel. You can calculate grayscale of pixel using GrayscaleValue function in CGE.
-
Alternatively, if you really want to simulate an effect at run-time like the engine you show on the screenshot, you can write a simple “shader effect” in CGE that derives “effective” texture alpha from texture RGB color.
For a general idea how to do this, follow examples/viewport_and_scenes/shader_effects code and links from README. But in this case you need to apply the effect to the texture, and use
PLUG_texture_color
to modify effective alpha we read from texture.This got involved to explain, so I decided to write an example doing it See Add a shader effect that sets effective texture alpha from grayscale derived from texture RGB colors · GitHub . This is a modification of your project attached in the 1st post. To
gameviewmain.pas
I added a code that adds an effect to the scene (seeTViewMain.Start
with local procedureSceneEffectAlphaFromGrayscale
, and new methodTViewMain.AddTextureEffectAlphaFromGrayscale
). You also need to add a new file,effect_alpha_from_grayscale.fs
, todata/
subdirectory.It works as intended, I believe, here are screenshots and movie. As you can see in
effect_alpha_from_grayscale.fs
, the possibilities to customize it are endless :), you can tweak the effective texture value in any way.