Tag Info

Hot answers tagged

13

For perfectly reflective surfaces Phong-model makes sense. However, where does the n in (R.V)^n of Phong-model for approximating rougher surfaces come from? Where is the theory that you have to raise the result of the dot product to the power except that it just appears to empirically give the proper result? For Blinn-model there's physically based ...


8

You should consider shader programs as similar part of the state as textures. Changing the state is expensive, so you may be able to get away with combining several textures to one to avoid texture changes; the same applies to shaders - you may be able to combine several shaders to avoid state changes. Similarly to combining textures, combining shaders ...


7

There are a few tricks you can do: Z-buffer After you have rendered all other objects, for each unit render a transparent circle of smaller size with max Z value. Then render selection circles decals on the ground. Since they are below in Z-order, they will be discarded when under units. Being fully transparent means that the circle gets written only to ...


4

Actually, I think you yourself listed the reasons why Blinn is the default over Phong. Each reason you listed there is, in fact, an area where Blinn proves superior to Phong. Taken as a whole, all of these lead to Blinn being a better default than Phong. Is Blinn perfect? Is it better than Phong? No. But it is a reasonable default. Feel free to ...


3

I'd go for a second shader that accepts two textures and does the desaturation. Performance loss will be minimal. uniform sampler2D tex; uniform sampler2D texA; void main() { vec4 texelColor = texture2D(tex, gl_TexCoord[0].xy); vec4 maskColor = texture2D(texA, gl_TexCoord[1].xy); vec4 desatColor = texelColor * vec4(0.3, 0.59, 0.11, 1.0); // ...


3

It's best to keep things as simple as possible. Duplicating the same shader for every object is unnecessary and will quickly get bloated. You also don't want one giant shader that covers every possible use-case, as this causes unnecessary overhead. There are several opinions on shader management and no "optimal" way to approach this. I've even seen some ...


2

Yes it is possible. And it is called texture. Textures are not just pictures - it can be any kind of data*. Another option would per-vertex data - if you dont mind smooth border between (un)explored. Or just as other post suggested - pass it as per-tile uniform. * Ofcourse, you need to stay in reasonable array size, defined by maximum texture size. ...


2

I'd simply provide a uniform per tile. For example a simple float that indicates the transparency. Before you render the tile, you simply set the uniform. If that's not possible, try using vertex attributes (also using a simple float).


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 = ...


2

You can use your texture coordinates, and set a uniform that tells you the aspect ratio of your rect, and the desired width of your border. Then, you can just check to see if your pixel falls within the bounds of your rectangle. (0, 0) (1, 0) ------------------------------------- | (0.1, 0.1) Border (0.9, 0.1) | | ...


1

Solution 1: Texture Atlas where you can tweak the UV coords in your mesh to specify a subsection of the texture to use for a portion of your map. This solution requires that each "tile" of the map be a separate quad so you can control the UV coords of each corner... sharing verticies at the corners of a tile will not work right. Solution 2: if you are doing ...


1

This is the shader I use to push my pre-built HUD texture to the full display window. I compile it using the VS_4_0 and PS_4_0 profiles which I'm not sure will work right with DX9. The mesh I use with this shader is a simple quad ranging from (-1,-1,0) to (1,1,0) (note the zeros for Z -- there is no depth involved... the -1 to 1 range maps to the corners of ...


1

I think that it is impossible to solve your problem just by using a pair of tricky fragment and vertex shaders. That is why: You select a set of UV points in 2D space. Then, using the function you have defined, you can get another "linked" set of UV points. But you still have to get somehow 3D coordinates from the surface UV coordinates. So your problem can ...


1

Yes, indeed, some ES implementations don't support non-const indexing of arrays, which complicates code quite a bit. 1D textures are also not supported on GL ES 2.0 or lower. You can certainly overcome this by using a 2D texture with a height of 1 pixel. It will effectively behave like a 1D array. Another approach might also be computing the value ...


1

One way to accomplish this would be to use an FBO (Frame Buffer Object) and multiple depth buffers and/or depth textures. A basic use case is shown on the Wiki at OpenGL.org. Another possible method, maybe applicable to old or very low end hardware could be copying the depth buffer, which you can find an example of using PBOs (Pixel Buffer Objects) here.


1

There are many ways to handle this kind of logic in a shader: Use dynamic branching: Plain ifs are not that slow on modern hardware. Test and profile it. If it doesn't slow down your application, this is probably the most straightforward and flexible solution. Use shader subroutines: This is a new GLSL feature. It is supposed to be faster than dynamic ...


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 ...



Only top voted, non community-wiki answers of a minimum length are eligible