0

Just implemented the idea with multiple lights (idea without multiple lights is here 360 FOV depth buffer by topology and 2D shadows), however i'm not sure if its correctly rendered http://www.youtube.com/watch?v=bFhDiZIHlYQ , i just render each scene to the screen with GraphicsDevice.BlendState = BlendState.Additive; with respect to a light, so scenes just added to each other.

And the question - is it seemed correct or not ?

Community
  • 1
  • 1
Oleg Skripnyak
  • 301
  • 2
  • 13

1 Answers1

0

To answer the question. Sorry no, but I have been corrupted, let me explain.

The human eye is logarithmic. To perceive something as twice as bright we need to square the amount of light coming into our eyes. The same goes for sound.

Yet the RGB values of the screen are linear RGB 128,128,128 is twice as bright as 64,64,64. It has to be linear or our shading algorithms would not work. The fall of would be too quick.

Well no our calculations are wrong but the people who manufacture our screens know this and correct it as best they can..

Rather than me explaining watch this Youtube Computer Color is Broken

So to get the correct mix you need to create the correct mix between the two renders.There is not blend state to solve this so you will have to create a custom pixel shader to do the job. output.color = sqrt( pow ( input1.color , 2 ) + pow ( input2.color , 2) );

It is very subtle, but change the two light source's colours and then switch between linear and logarithmic blending and you will wonder how you ever put up with the broken rendering output in the first place.

I do all rendering and lighting calculations as photon counts, squaring input colours and square rooting output colours.

What about alpha? yep? i am not sure.

Blindman67
  • 51,134
  • 11
  • 73
  • 136
  • Thanks for explanation ! And i can do it in the pixel shader actually, however its good that you don't see other artificats like "edged shadows" (in the real world they should be vanished, as photons passed an edge of an obstacle, they should turn in the shadow direction randomly), or that light power calculated linearly, but should be calculated by square root of distance. Just thinking how to resolve 1st problem, and as always have no idea :( [link](http://www.youtube.com/watch?v=lz_JuB1Ri64) maybe stencil buffer can help... – Oleg Skripnyak Nov 07 '15 at 11:10
  • I had another look at the YouTube demo. I don't have access to the fastest internet so first view was in low res. I looked again at demo at high res. You seem to have something else strange going on I cant quite work out. For the blurring, a cheat for that shadow map is to blur the edge of a shadow by light intensity, the lower the light the more the blur. Its not perfect but not overdoing it will make the edges better., – Blindman67 Nov 07 '15 at 11:28
  • actually there is no blur as we do in post processing by summurising pixels, but a trick in pixel shader - i know the angle between a pixel position and light position by atan2, but also know first and second verticies angles of line which drop shadow, so i just check if the pixel in the blured range of 0.1 degrees and calculate the color by expression minAngle <= 0.1 ? (0.1 - minAngle) * 10 : 0. But the problem is that when there 2+ obstacles like on 0:05 in the video (its shadow buffer), each obstacle don't shadow inner space, they work as separate obstacles and do their blur :( – Oleg Skripnyak Nov 07 '15 at 15:18
  • Well, i've solved most of the the problems :) Had to render to the depth & blur buffer twice (with different blendings, by masking channels), so now these lines of the VS buffer rendered 4(!) times. Ofcourse, i could render to different render targets with one VS pass, however then in PS (where i render shadow map) i would access 2 different textures. There alot of logic happened in VS, but PS made as simple as possible. Here is the not optimized .fx [link](https://yadi.sk/i/eGUr951ykSoLf) – Oleg Skripnyak Nov 13 '15 at 23:32