Tag Info

New answers tagged

2

The answer to this question here should help explain how to use the GetData function. Basically, the data is stored in the return array from the GetData call is formed by reading the 2D texture from left to right, top to bottom, transforming it as follows: AAAA BBBB => AAAABBBBCCCCDDDD CCCC DDDD To determine where a given pixel in the 1D array is, we ...


2

From your original equation a_position.x = a_position.x + amplitude * sin(phase + a_position.x); We'll just be taking at look at the sin portion as this is where this effect comes from sin(phase + a_position.x); Let's look at the sin function over a half of a period for different positions (phase is in degrees) Position 1 - a_position.x = 0 sin(0 + 0) ...


2

What exactly is the difference between Tiling the material and Offset of material? Those parameters set by the inspector are used inside the shader to scale the texture coordinates. A uniform float4 in the shader with the name of the texture and _ST suffix is populated with those values. For example considered the main texture: float2 scaled_uv = ...


1

Documentation on the website which also happens to be the first search result for the term SetTextureOffset or mainTextureOffset seems to sum up the issue nicely. Material.SetTextureOffset function SetTextureOffset (propertyName : String, offset : Vector2) : void Description Sets the placement offset of texture propertyName. Common texture names used by ...


0

You can use GUILayout which is from before the 4.6 beta to accomplish this. I would create a new area in the top right corner, then have a flexible space inbetween the left bound and the last heart. You can create a new row by having a vertical area. This is how I'd make the hierarchy -BeginArea | -BeginVertical | | -BeginHorizontal | | | -FlexibleSpace | | ...


1

You can use Texture2D.GetData() to copy texture pixel data to a Color[] in XNA. Texture2D texture=Content.Load<Texture2D>("asd"); Color[] tcolor=new Color[texture.Width*texture.Height]; texture.GetData<Color>(tcolor); After you have your Color array, you can do whatever you want with it, for example you could change certain colored pixels to ...


1

You can use the inbuilt GLSL lessThan() and greaterThan() functions (supported in all GLSL versions). These give two boolean vectors as a result. https://www.opengl.org/sdk/docs/man/html/greaterThan.xhtml http://www.opengl.org/sdk/docs/man4/html/lessThan.xhtml Then, you can use 'equal' (https://www.opengl.org/sdk/docs/man/html/equal.xhtml) on those ...


1

How about: vec3 delta = abs(textureColor - vec3(0.85, 0.85, 0.85)); // Get delta from middle vec3 if (delta.r <= 0.05) && (delta.g <= 0.05) && (delta.b <= 0.05) Performance needs to be profiled, but it's sure shorter to write


0

It is a problem of baking in 3D software. Just increase the number of texture seams and second it is all about in Unity selecting texture and Mip on and off. You will see seams will go, but better to see you texture in game with your main camera.


2

You need to combine texture atlas techniques with your existing triplanar shader so that you can easily switch the "textures" being used based on the terrain type in the voxel. One technique if you are using shared vertices between voxels might be to use vertex color or UV coords to encode all the terrain types associated with a particular vertex, then you ...


0

You could try triplanar mapping. A variation I use is I iterate through vertices and look at the normal of the vertex, find the direction the normal faces most(component of normal vector with the largest absolute value) and use the position components of the vertex vector orthogonal to that direction. and example would be a vertex [1, 2, 3] with a normal ...


1

You are going to have background rendered either way. OpenGL redraws the whole frame each time. So what does it matter for performance where are you drawing it from? :) It does not matter, unless you are doing some heavy computations to generate the background on CPU. What you probably do is just updating the background location each frame (position, ...


0

I think I understand what you are trying to do. You want the sum of all layers' alpha to be 1 so that there the total color is overdrawn. You are on the right track. But your error seems in the way you compute the alphas. Take for example this starting point: 1: 0.7 2: 0.3 3: 0.0 Now you apply 0.5 on layer 3, the result should look something like: ...


0

Depends whether you use indices(elements) or not (arrays). niether, you should use gl.glVertexPointer(3, GL.GL_FLOAT, stride, (const GLvoid *) offsetOfFirst), unless you lib overrides it ofcourse. no idea, sorry, I use attributes means you pass wrong UVs. To shader you pass only sample location. (make sure UVs are in range 0.0 - 1.0) you really should ...


0

You could always use Screen.currentResolution or Screen.width/Screen.height if you're trying to switch based on the resolution of the version. If you want to get the exact version of iOS use SystemInfo.operatingSystem on Unity 4.3+ and iPhoneSettings.systemVersion on older versions


1

You could do this: Create a texture holding all the colors you want. For the actual button geometry, set the texture coordinates to the appropriate region of the color texture (they can all be the same value, in fact).


0

If by rotating in a circle you mean WALKING on top of the circumference of a circle, then I guess any of the answers correctly answered your question. So here is my add: You can continue loading you texture with texture = new Texture(Gdx.files.internal("1325603701_wordpress.png")); but it is extremely recommended that you use the AssetManager. About it ...


-1

Do it like this 1. Load your image into AssestLoader class and store it in sprite sprite=new Sprite(AssestLoader.1325603701_wordpress); 2.Then set its size , position and color like this sprite.setColor(1, 1, 1, 1); sprite.setSize(sprite.getWidth(),sprite.getHeight()); sprite.setPosition((w / 2) - (sprite.getWidth() / 2), (h / 2) - ...


6

Basically, I think what you do is first of all create a tile for each of your terrain types that seamlessly tiles with itself. As you said there are many tutorials available on how to do this. Once you have those tiles, you can draw variants as well as transitions between different types of terrain by modifying copies of them. The only thing you need to ...


0

The best way would be to create your textures manually in an image editing program, then adding them to the game as textures. You would need a separate image for the different conditions (buttonPressed/buttonUnpressed). If you append both images into one, you can easily use animation to change the appearance of the button when it is selected / pressed. You ...


1

You get the black boxes because you have to enable blending in OpenGL: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); This because the textures drawn by Slick have transparency.


0

Now I am no unity expert (I opened it once two years ago), but I hope this helps. First you would want to find the width of the string (in pixels). Something along these lines: var textDimensions = GUI.skin.label.CalcSize(new GUIContent("text")); //textDimensions.x contains the width in pixels. Now you are going to want to see if that fits. If it doesn't ...


2

To apply different textures based on height the general method is to, in a pixel shader; Find the height of the geometry at the current pixel position. Perform a texture lookup on the heightmap that defines the geometry or just find the position of the current geometry as you would for lighting and find the y component. Supply your shader with some kind ...



Top 50 recent answers are included