New answers tagged

1

A guess (too long to put in a comment): If spotFactor becomes 0.6 at a specific pixel, from this float spotFactor = dot(lightDirection, spotLight.direction); then color goes negative here (as you said spotLight.cutoff is 0.71): color = calcPointLight(spotLight.pointLight, normal) * (1.0 - (1.0 - spotFactor)/(1.0-spotLight.cutoff)); will ...


1

There is at least one serious problem in the code. In calcLight(), the test below is invalid. Calling pow with a negative first argument is undefined behaviour, so you need to test specularFactor sooner. float specularFactor = dot(directionToEye, reflectDirection); specularFactor = pow(specularFactor, specularPower); if(specularFactor > 0) ...


4

Unexpectedly black pixels sometimes indicate that you've got an infinity or NaN in the shader somewhere. For example normalize(vec3(0,0,0)) will generate a NaN. To me, the most obvious candidate in the above shader is the reflectDirection variable, but I could be wrong. GLSL has isinf() and isnan() functions that you can use to detect those cases. If that ...


1

BTW, I ended up solving this using a lightmap. My process was as follows: Generate a UV map for the mesh by packing all the triangles together using a simple scanline algorithm. Render the scene directly to the UV map instead of to the screen. This way, pixels are 1:1 related to texels. Render the scene again to the screen, this time using the generated UV ...


4

I believe that might be related to "shadow acne." Try lowering the bias of your directional lights. http://answers.unity3d.com/questions/925812/unity-5-real-time-lights-cast-shadows-with-gaps-li.html


0

Use hard shadow instead of soft shadows.


0

Increase Range. If looks too bright decrease Intensity. Range 130, Intensity 1.3, Anti aliasing 8x multi, Shadow Res Very high. Distance between light and shadow receiver 30 Unit. Distance between light and shadow caster 25 Unit. Point light is not usually used for distant lighting. Use a Spot light instead. Result will be better.


0

I don't want to take anything away from @Draco18s' answer, but I went with his suggestion (combining the two) and ended up putting together a demonstration video on how it's done (for those interested) at https://www.youtube.com/watch?v=Cabl0LMmlgY In addition to the quick sketch that he added, I ended up using normal maps on each "face" of the wall so that ...


0

This technique consists of three main steps. 1.) Render your light source only, but occluded by the scene geometry to a black texture. This could be done by rendering the light source against the scene's depth-stencil buffer and performing depth-tests or stencil tests to only keep visibe pixels of the light source. 2.) You need to perform a radial blur ...


2

There's no good way to detect different data formats from each other in shader code. In general you should always give the same kind of data to your shaders. You need to pre-process your data before drawing with it. Pick one format and convert all data to that, and then write your shaders to use that format. One other way is to detect the format before ...


1

The cubemaps used in Image Based Lighting should only contribute to the scene once because they don't represent light coming from a single light source like your point lights for example, but from every direction from the environment. This means that they should be added to the light buffer only once, which you could do in either of these passes: In the ...


2

This is what we're doing and the results look somewhat like they do in Ori. You need a texture for your light shaft that loops vertically. This is from our project (hence the watermark, sorry) You add it to a particle material, and add the material to a Plane primitive. It should look nice and glowy. Two more steps. One, you stretch the plane really ...


5

Use stretched particle to get the effect. In Renderer, choose "Stretched Billboard". Change Length Scale as you need. This can be used in both 3D and 2D scenes. If you are actually into effect stuffs learn Shader. Mostly vertex and fragment shader. Drawing things is not always a solution. Build size increases due to extra artworks. Talking about overall ...


7

You mention you're using Unity so you can use their official "Sun Shafts" feature; it's built right into the engine: You can read these Unity Docs to get a good idea of what they're capable of and this YouTube video can walk you through implementing it. By the way, you'll need to download the Unity Standard Assets in order to use then.



Top 50 recent answers are included