- Apr 3, 2020
- 62
- 77
How can i create transparent images that give a blur effect (glass) with photoshop?
Could you suggest me some codes?I don't think such a thing is possible. Blur works by moving pixels around and no image can do that when shown over another image.
I assume you want this for renpy, I think I've seen some script for blur effect on it's forum, alternatively you can take a small screenshot and show it big, it gives you a kind of blury effect.
image myBlurredImage :
contains:
"myImage.jpg"
contains:
"myImage.jpg"
xoffset -1 yoffset -1
alpha 0.3
contains:
"myImage.jpg"
xoffset 1 yoffset 1
alpha 0.3
contains:
"myImage.jpg"
xoffset -2 yoffset -2
alpha 0.3
contains:
"myImage.jpg"
xoffset 2 yoffset 2
alpha 0.3
default toBlur = None
image myBlurredImage :
contains:
"[toBlur]"
contains:
"[toBlur]"
xoffset -1 yoffset -1
alpha 0.3
[...]
label whatever:
$ toBlur = "images/oneImage.jpg"
show myBlurredImage
"blablabla"
"bliblibli"
$ toBlur = "images/nextImage.jpg"
"bloblo"
hide myBlurredImage
Thanks, but in the end I solved it like this:Globally speaking, the default blur is done by diffusing the colors. You remember when you were young and had painting in school ? You were proud of what you drawn, until few water drops hit the paper and messed with the colors ; this is the default way to blur an image.
Therefore, you can simulate something like this with Ren'py, by mixing the image with altered copy of itself. Something like :
[wrote on the fly]
Just play with the value until you get the best result.Code:image myBlurredImage : contains: "myImage.jpg" contains: "myImage.jpg" xoffset -1 yoffset -1 alpha 0.3 contains: "myImage.jpg" xoffset 1 yoffset 1 alpha 0.3 contains: "myImage.jpg" xoffset -2 yoffset -2 alpha 0.3 contains: "myImage.jpg" xoffset 2 yoffset 2 alpha 0.3
TheYou must be registered to see the linksATL (You must be registered to see the links) statement tell Ren'py that what's in its bloc is to add immediately. This by opposition to the default behavior of an ATL block, where new image replace the previous one. Which permit you to blend all the copy of the image together.
Copy that use are shifted byYou must be registered to see the linksandYou must be registered to see the links, then defined as transparent withYou must be registered to see the linksto not just hide what was under them.
Edit:
If you want something more universal, you can benefit from the text substitution in image, using a variable instead of a hardcoded name for the image :
The image will automatically change when the value of "toBlur" will be changed.Code:default toBlur = None image myBlurredImage : contains: "[toBlur]" contains: "[toBlur]" xoffset -1 yoffset -1 alpha 0.3 [...] label whatever: $ toBlur = "images/oneImage.jpg" show myBlurredImage "blablabla" "bliblibli" $ toBlur = "images/nextImage.jpg" "bloblo" hide myBlurredImage
image 1 = Composite( (gui.width, gui.height),
(0, 0), "/bed.png",
(0, 0), "/M.png")
image 1 blur = Composite( (gui.width, gui.height),
(0, 0), im.Blur("/bed.png", 3),
(0, 0), im.Blur("/M.png", 3))
show image 1 with blur
imagedissolve()
(
imagedissolve()
with an B&W image given the look of soap bubbles to transition between the two versions of your image.... hell, I dunno, it'd probably look terrible... but I wonder it could be made to work for you).Now you sound like a true programmer, "could it be better?"But, since it seems wasted to "create" 2 identical images (but one with a blur effect).
i was wondering if you can use a better way. eg:
Python:show image 1 with blur
I need it in a scene where I first look at an object in the distance, then look at the cell phone. therefore the rest becomes blurred.Dumb question... but what are you trying to achieve?
I get your aiming to avoid having 2 versions of the same image (one clear, one blurred) - but to what end?
Someone waking up, first thing in the morning?
Someone looking from a distance through a telescope or binoculars and failing to get the focus sharp?
Someone looking at someone with their glasses on and glasses off?
Edit: Just noticed your original post talks about glass... So pretty sure my idea (which was mainly aimed at a frosted glass/water on glasses style effect) won't be appropriate.
I doubt it matters as finding a solution to the "blurred" image solution - but maybe someone could offer an alternative that you perhaps haven't considered?
(I'm thinking something likeimagedissolve()
(You must be registered to see the links) that uses a static image with varying shades of a black and white image to transition between two images. If those two images were the same identical image, but with one shown with a very low alpha/high transparency against a white background to give a "looking through tracing paper" washout effect using the same source picture and RenPy's Composite() image maging... then useimagedissolve()
with an B&W image given the look of soap bubbles to transition between the two versions of your image.... hell, I dunno, it'd probably look terrible... but I wonder it could be made to work for you).
On the more practical side... if you're worried about image sizes... just how many "blurred" images are you planning to have in your game? 1:1 would be a lot of blurs and I can see why you'd what to find a more economic solution. But if it's only 1 in 200 or more, then sod it... Just have two versions of the same image and eat the tiny amount of extra disk space. If you're really worried about space, then save the blurred version as a low quality .JPG file - the lack of image quality shouldn't matter to much for a blurred image, and will save reduce the file size significantly.
So it's just a single use?I need it in a scene where I first look at an object in the distance, then look at the cell phone. therefore the rest becomes blurred.
it doesn't happen they are in one scene, but in many. in all cases the mobile phone is the same but the background is different.So it's just a single use?
A possible 2 (maybe 4) images in a game that will likely have hundreds of other pictures?
If that's the case... as I said earlier, I think you're looking for a highly technical solution (RenPy) to a very simple problem. Render your scene, fire up your graphics package of choice (Photoshop if you have it,You must be registered to see the linksif you want almost identical functionality for free)... Load your scene, hit the "Blur" button a dozen or so times, copy paste your hand/cellphone into the foreground and then use "Save as...".
Alternatively, if you're using something like Daz - Render your scene without the cellphone, add the cellphone to the scene, alter the "depth of field" and "F/Stop" settings for the camera so only the cellphone is in focus and render the new scene. This has the advantage of honoring any shadowing or reflections on the phone itself. If you don't already know how, search YouTube for "daz3d depth of field".
You're trying to treat the two pictures as being a single picture that can be stitched together with blur. But the reality is that they really are two separate images, so it's not really "wasted" disk space and they aren't "identical images", because one is blurred and has a cellphone in the foreground and the other doesn't. Or to rephrase my original point, it seems like you're spending a lot of time and effort trying to save 500KB to 2MB of disk space in a world where disk space is dirty cheap.
Don't get me wrong, as a programmer - I've gotten lost down that same sort of rabbit hole a lot of times in the past. Plus I barely know how to use Daz. But sometimes the simplest solution really is the best. Render it twice (with DOF and FSTOP) and don't worry about the ultimate file sizes.
screen
that overlays whatever happened to be on the screen at the time (in this case the 4th image) to show the user something that looks like the 5th.Now I don't use renpy so I don't know their API, but from the above example, I would guestimate 3 is referring to the blur radius. I don't know how renpy organizes its execution, but you could probably make 3 a variable, and instead of asking it to do,Python:image 1 blur = Composite( (gui.width, gui.height), (0, 0), im.Blur("/bed.png", 3), (0, 0), im.Blur("/M.png", 3))
you could just define blur = some number, and noBlur = 0, and set the variable to blur or noBlur. But that assumes that image is recalculated each Time before being shown, but I don't know since I don't use the renpy API. Python is slow so they are probably using some trick in renpy to avoid unnecessary recalculations. If however, this does work, what you could also do is execute a parallel function that fades between the two values, that way the blur fades in rather that suddenly jumping from on to off, giving the impression as if the viewer is adjusting their field of view to focus on the phone. While this would be perfectly fine in C, C++, C#, Java, Javascript, normal python, gml, gdscript, mono,monogame framework, HTML (executing java or something) etc, because I don't know how the renpy system works I can't say how the image would actually be handled. I could google how renpy works, but it is 5 in the morning, I ain't doing jackPython:show image 1 with blur
im.Blur()
even existed. Good call.scene
?screen
, overlaid with a picture of a cellphone (probably further overlaid with character stats, etc)... it strikes me that if im.Blur()
could be applied to "the latest scene image" - without actually defining it each and every time - then things become really interesting.screen
could be passed the image name as a parameter and the im.Blur()
applied to it in real time?I'll try ta awake my brain, but no guaranty.(I'm looking at you anne O'nymous )
Not natively, but it's possible to tweak Ren'py in such way that you'll always know what was the last image displayed. When you look at the configuration variables, you foundIs it possible to access which image was last used as ascene
?
renpy.scene
isn't the strict equivalent for the scene
statement ; it is limited to it without image, therefore to the cleaning of the screen. But in fact it's not a problem, because the scene
statement is in fact a combination of renpy.scene
and renpy.show
.renpy.show
to keep track of the image :init python:
def keepShow( name, **kwargs ):
store.lastImage = name
renpy.show( name, **kwargs )
config.show = keepShow
default lastImage = None
name
isn't the path to the image, but the name of the displayable.Yes, no, maybe. I see what you're saying. Something like :Failing that, perhaps thescreen
could be passed the image name as a parameter and theim.Blur()
applied to it in real time?
def keepShow( name, **kwargs ):
if isBlured: BlurTheIamge( name )
renpy.show( name, **kwargs )
name
is the name of a displayable, therefore you have to create a new displayable, or replace a generic one, all this by using a displayable as input.I agree on this.But it "feels" possible...
Also, after browsing the Renpy Quickstart guide, this is what I can conclude.The image statement is run at init time, before the menus are shown or the start label runs. When not contained inside an init block, image statements are run as if they were placed inside an init block of priority 500.
But it still offer a full direct access to the Python interpreter. It's the main problem of Ren'py, too much of an hybrid...However, based on my quick review of the quick start guide and the "Displaying images" page, Renpy is like a game engine, where you have to code it in its own special language, but it is not a true programming language or a true python interpreter because it's missing some key features (such as not having direct access to data).
They aren't issues, but they need knowledge that most of the indie devs don't have. You can address directly PyGame, and with it you can access directly every single pixel of the image you'll display. Therefore, you could build your own blur function if you wanted it. In fact, you even don't need to go this far, since Ren'py's API already offer you the possibility to apply a matrix to the image.So this poses some issues, and I don't have any suggestions.
Once again, technically you can. It would be difficult because either you limit to one platform or have to build the module for all of them, but nothing prevent you to build a Python module in whatever compiled language you want, then use Python to create a Ren'py statement that will let you use it directly in Ren'py language.I would say, however, how things might have worked if you had low-level access or were programming in a true language.
Like you can imagine once you reach this part of my answer, I wouldn't say that But still you aren't wrong at all. It's just that the limitation don't come from Ren'py itself, but from the dev.python and renpy seem to force you to make a games in a particular way, in a limiting way.
great stuff! I'll book mark this for later.But it still offer a full direct access to the Python interpreter. It's the main problem of Ren'py, too much of an hybrid...
Honestly I never were able to correctly describe Ren'py... Simply because it's kind of an abnormality in the world of game engines. It have this "cheap side" (relatively speaking) that you can found in GameMaker or Tyrano Builder by example, while having the behavior you expect from the professional game engines that are Unity or Unreal.
It have a language to build the game, like any other game engine, but unlike most of them, it's not an existing language, but a dedicated one created solely for it (and derived from Python).
It also have a whole API you can interface to, but for this you need to use the language that build the engine ; this part being the same that building a plug-in for Unity or Unreal.
And finally there's the less used feature, yet the most wonderful one, the possibility to extend its dedicated language by adding your own statement without the need to hack the core.
Talking about the last one, I let you imagine the whole world that it open. I remember having explained it once here, saying how easily (relatively speaking of course) you can build a scrolling kill'm'all game this way with Ren'py. Explained in terms never used for Ren'py, you just need to build the plug-in for it, then you'll use the new Ren'py statements to configure the game ; defining what the sprites will be, what will be their trajectory and so on.
They aren't issues, but they need knowledge that most of the indie devs don't have. You can address directly PyGame, and with it you can access directly every single pixel of the image you'll display. Therefore, you could build your own blur function if you wanted it. In fact, you even don't need to go this far, since Ren'py's API already offer you the possibility to apply a matrix to the image.
But how many among the devs who make adult games can effectively do it ? I'll even go further, how many effective devs here, whatever if they works on a game, or are just players like me, can effectively do it ? It's not because our job is to write lines of code, that we all remember how matrix works, or that we all know how to manipulate images. This in the exact same way than a chef able to cook an amazing meal while struggle if you ask him to make some pastry ; it's not what he usually do, if he learned the basis he forgot them long ago.
That's the limit of indie development. One can't know about everything, therefore one limit to what he's sure to achieve... more or less. And in the same time few have an income high enough to pay the guy that will know, solely to do it.
Once again, technically you can. It would be difficult because either you limit to one platform or have to build the module for all of them, but nothing prevent you to build a Python module in whatever compiled language you want, then use Python to create a Ren'py statement that will let you use it directly in Ren'py language.
Like I said above, Ren'py is kind of an abnormality... It's the kind of behavior you expect from a professional game engine, yet you can do it with Ren'py.
Like you can imagine once you reach this part of my answer, I wouldn't say that But still you aren't wrong at all. It's just that the limitation don't come from Ren'py itself, but from the dev.
Ren'py is an easy to use game engine which come with an easy to use BASIC-like language... and which offer you the same power than a professional game engine ; minus the computation power limitation obviously. Technically there's nothing preventing you to make a realtime 3D game with Ren'py. Python already have all the modules needed for realtime 3D, and there's even, somewhere deep in the abandoned game list, an attempt of realtime 3D VR game in pure Python that was smooth enough. Therefore, technically speaking any recent computer could play smoothly a game like The Twist powered by Ren'py.
But Ren'py imply two problems...
Firstly, it need a knowledge that 99,99% of the indie devs don't have, and that probably 99% of the devs who are members here don't have either. [I start a poll right here, who among us would be able to write a realtime 3D game if provided the rights 3D API that come with the language they'll use ? Is there even one ]. You don't have to just provide the models, skeleton and path for the bones, you need to interface them to the API in a way or another.
It can be done in Ren'py, really. As said above, you can have a "load model FILE VARIABLE" statement, an "attach skeleton MODEL FILE" one, a "move MODEL BONE AXE VALUE" one, a "startAnim MODEL ANIM_NAME" one, and so on... It would make the game easy to write in Ren'py.
Well... this as long as you found someone that will write the code behind the statements, the code that will effectively load the model and declare it by using the right function of the right Python module...
And here come the second problem... Why someone who know how to do this would use Ren'py in the first place ? Why would he bother writing the interface between Ren'py and the Python 3D modules, when he can use Unity or Unreal and not have to write this interface ?
And this apply for more or less every unused part of Ren'py effective power. I said it, you can write a scrolling kill'm'all in Ren'py, but why doing it with Ren'py when a game engine like GameMaker, to not even talk about Unity/Unreal, is more suitable for this ? Why write a RPGMaker-like game with Ren'py, which is also possible, when you can directly use RPGMaker ?
Therefore, people using Ren'py limit themselves to Visual Novel, sometimes going a little further by adding Free Roaming features, and don't do really more. And the more there's game which don't go further, the more there's devs who limits themselves to this, thinking that it's all that the engine can do.
Sometimes, I dream of a game mixing Ren'py Visual Novel aspect, and RPGMaker walking part. You know, a game where the map isn't the usual "click here" you see in a Ren'py game, but a RPGMaker map. Then once you've reach the destination, you fall back to the usual Visual Novel presentation of Ren'py.
It's totally possible to do this, but first it need someone with the right knowledge to write the code that later every single new dev will use in hope that his game will become a hit ; like it happen every time that something new is added in Ren'py games
TL;DR: Ren'py is more powerful than it looks, but not "professional enough" (aka in a compiled language using a compiled language to write the game) for its power to be effectively used.
You're probably not the only one, I exaggerated a little on this part to not feel too oldanswering your poll. I don't need an API, I could code my own using openGL (I made my own engine for a html/javascript game). But I see your point, it is like the 80 20 rule or so.
Well, technically it's possible since Python is the new Pascal. I don't have stats on this, but it's the main language used in universities/colleges, so I assume that at least 4 out of 5 peoples who followed this curriculum since the early 00's learned Python. But I agree with the difficulty. While it's good to teach all the "good practices" and the basis of algorithms, it have a structure so different to almost all other languages, that it's surely difficult to pass to lower level languages without a teacher to help you. In fact it's probably difficult to pass to any other language without some help. But the opposite is relatively easy, it's what you already know, minus most of the constraints.That and since I started with lower languages and worked my up to higher languages, I can't even imagine what newer programmers are going through as they start with python and then have to work their way down to understand any other programming language concepts.
show
statement will display an image, cool. But without a knowledge in "more advanced language" you'll never be able to tweak it in such way that you'll make it depend of something else. Not because you're dumb, but because for you it stay something magic.