I wanted to create a landscape material, but when I blend the two textures, the preview is just black.
Related
I have a scene need to display a 3d module to ui layer, so i use a secondary camera to render it to a RenderTexture, but when i set a background to the ui layer ,i found that the content is wrong, because the alpha channel is not what i expect
In order to describe my problem more clearly, I created a demo
the content: in the center has the backgorund color, this is what i don't want, i want the center is fully white
the 3d object: a cube with opaque material and sphere with transparent material
the renderTexture's alpha channel:
I tried use colormask to disable alpha output, but the ui layer background size is smaller than my 3d model's content, so where there is no background it is invisible.
Update at 2023-2-15-17:49
this is the problem in my project, the character's hair has some transparent part, i use a camera with renderTexture to display it on Ui layer, but the hair's transparent part make some mistake
Solution:
Set the RenderTexture's Color Format to ARGB32.
Make sure the background of the UI layer is fully opaque.
Enable Alpha Clipping in the material of the 3D object, and set the Alpha to the desired value.
Set the RenderTexture's Clear Flags to "Depth Only", so that the background color will not be taken into account.
I want to apply a brighten effect above my scene.
My scene contains tiles, and I want to perform white flash for a few frames by code.
I have already tried this code:
private Tilemap tm;
...
tm = GetComponent<Tilemap>();
tm.color = new Color(0.5f,1.0f,1.0f,1.0f);
This code darkens the scene by a certain color amount, but I wish to brighten it.
Your code is not working because in Unity if you render an image (in your case tile) the original color of the image is when its color is white (255,255,255,255).
It means that if you change the color of an image it will add this color to this image.
For instance, if you set the color of an image to red, the image colors will become more similar to red than the original image.
As I see it you have 2 ways to perform the white flash:
A) Add another image of a white rectangle that covers all the screen and set it's alpha color to a low number (the lower the number the lighter flash effect).
In the editor disable this object's renderer and when you want to perform a flash effect enable this object from the code (You can improve this with animations or code to get a smooth flash animation).
B) Install the package "2D Light". This is an experimental package that allow you to render 2d light.
This package contains a lot of components that allow you to stimulate light.
I have found a way to do this.
I created a new PNG that only contains white shapes on a transparent background.
There are about 20 pieces that match the shapes of my level tilemap.
Now I just create a new (white) tilemap above the level tilemap in the shape of the highlight.
Then I set the alpha of the white tilemap in code.
It works :)
I have to write some text on a custom CGRect with a highly textured in a CGContext.
This has work for dark and for light images. The texture has to be visible at the debossed letters.
Current approach
calculate avg. color of background image
darken (related to the luminance) the color
CGRect.drawText... with the ID with color of 2.
add a darker ouster shadow to text
add a light inner shadow to text
done.
Problem
My current approach works for dark, slightly textured backgrounds but it does not work for dark strong textured backgrounds.
Example usecase
Render license plates with an embossed ID for a car app.
or
Dog tags (see wikimedia)
It was a rough play with background color of the material, background color of the embossed thing and 4 different shadows.
All in all I have (sorry for that) no 'how to do it' solution. Thanks for your help.
I currently have a texture serving a font, that is on the topmost (last) render in OpenGL for the iPhone. The texture is white glyph with a transparent surround. My aim is to have another color overlayed on the texture, effectively changing the font color.
Using the code below I can make a solid color on the texture, provided the alpha is set to 255. My aim is to have a progressive color fade out, so my aim is to display the color (0,0,255,127). This should be a partially transparent blue. However I have tried many times with glTexEnv() settings and cannot seem to make a non-solid color overlay.
glBlendFunct(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fontTexture);
glColorub(0,0,255,255);
...
glDrawElements(...);
I have tried the suggestions at the OpenGL wiki page http://www.opengl.org/wiki/Texture_Combiners, under the title of "Example : Blend tex0 and tex1 based on alpha of tex0". Also I have tried the idea found here OpenGL ES 1.1: How to change texture color without losing luminance?.
If there any setup I can get to make the color (0,0,255,127) present, without losing the outline of the font/character?
PS. Another idea was to pass a pre-multiplied alpha color (such as (0,0,255*(127/256),127)) for the preceding example, but this seems not too elegant.
EDIT: Just to clarify, I intend for the character texture to retain full opacity, just to color overlay to change. Thus the example should change from full blue to full white.
I think you have to change glBlendFunc parameters (BTW there is a typo in glBlendFunct).
Take a look at this:
http://pyopengl.sourceforge.net/documentation/manual/glBlendFunc.3G.html
For me setting it to:
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
works.
Hope it helps...
This is a follow-up of this question on here
http://iphonedevelopment.blogspot.com/2010/02/drawing-hud-display-in-opengl-es.html
It tackles on the HUD (heads up display) which is based on this tutorial >
OpenGL ES displaying HUD display has no color on top of textured 3D objects
I wanted to set the "Text" in color BLACK, but it is more complicated than what I thought.
Setting it to some other color other than black "glColor4f(0.0, 0.0, 0.0, 1.0);" is just fine.
I assume that the culprit must be in the Blending function "glBlendFunc (GL_ONE, GL_ONE);"
I experimented a lot of combinations with no luck. Has anyone experimented on this one on top of textured 3D in the backgrounds working?
The answer is here!
Change in the Texture2D classes and change stuff like Gray into RGB and the sizes of the allocations, plus a shawdow capability
http://majicjungle.com/blog/?p=191