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


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


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

I would implement it as a multipass algorithm, a bit similar to shadow maps. You render the character to a frame buffer, color(RGBA) and depth(Z). Now you simply apply the frame buffer to the regular buffer (with depth). Then you render the watter, you sample from the frame buffer. If the value A=0, you render the watter normally. If A!=0 and Z>=current ...


2

Your code is only sampling the corner texels, so is only valid for a 2x2 filter. Sample all the texels within your filter shape to achieve correct results.


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


1

I think the problem is that your pixel shader returns a structure, so each element of that structure need to have an SV_TARGET semantic and not the whole struct, so: struct PS_OUTPUT { float4 PosWorld : SV_TARGET0; //changed sematic float4 NormalWorld : SV_TARGET1; //changed sematic }; PS_OUTPUT main(PS_INPUT input) ...


1

Answer: Added the vertexIDs in a second uv(set x value to the id) channel in the mesh(from my c# code), and then in the shader I could use the ids as I needed, example: void function(inout appdata_full v) { int vertexID = v.texcoord1[0]; ... }


1

The shader was fine. But when I tried to use other shaders I realized what was wrong. It was the C++ code that was lacking lines (rrr!! This is the reason why I hate shaders! It's so complicated to make a link in your head between every line you write in one file and what must be written in the other for it to be recognized!). In the display function, I ...


1

Yes, accessing memory can always be substantially slower than not accessing memory. Particularly in a for loop that's executing 2000 times inside a shader. I don't think there's anything particularly surprising, here -- breaking the task up into smaller steps that can each be executed in parallel and using smaller amounts of data should definitely help.



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