Composition dummy

texugo

19-01-2009 02:34:30

Hi bros

I did'nt undestood how to Compositor works. In special the samples :

## Calculate gaussian texture offsets & weights
deviation = 3.0
texelSize = 1.0 / self.mBloomSize

## central sample, no offset
self.mBloomTexOffsetsHorz[0] = 0.0
self.mBloomTexOffsetsHorz[1] = 0.0
self.mBloomTexOffsetsVert[0] = 0.0
self.mBloomTexOffsetsVert[1] = 0.0
self.mBloomTexWeights[0] = Ogre.Math.gaussianDistribution(0, 0, deviation)
self.mBloomTexWeights[1] = self.mBloomTexWeights[0]
self.mBloomTexWeights[2] = self.mBloomTexWeights[0]
self.mBloomTexWeights[3] = 1.0

## 'pre' samples
for i in range (8):
self.mBloomTexWeights = 1.25 * Ogre.Math.gaussianDistribution(i, 0, deviation)
self.mBloomTexWeights = self.mBloomTexWeights
self.mBloomTexWeights = self.mBloomTexWeights
self.mBloomTexWeights = 1.0
self.mBloomTexOffsetsHorz = i * texelSize
self.mBloomTexOffsetsHorz = 0.0
self.mBloomTexOffsetsVert = 0.0
self.mBloomTexOffsetsVert = i * texelSize
## 'post' samples
for i in range (8,15):
self.mBloomTexWeights = self.mBloomTexWeights[(i-7)*self.x+0]
self.mBloomTexWeights = self.mBloomTexWeights
self.mBloomTexWeights = self.mBloomTexWeights
self.mBloomTexWeights = 1.0

self.mBloomTexOffsetsHorz = -self.mBloomTexOffsetsHorz[(i - 7)*self.x+0]
self.mBloomTexOffsetsHorz = 0.0
self.mBloomTexOffsetsVert = 0.0
self.mBloomTexOffsetsVert = -self.mBloomTexOffsetsVert[(i - 7)*self.x+1]

What is the central, pre and pos samples? where Are they in screen?
Thanks

bharling

19-01-2009 09:20:31

All the stuff in the code you've posted is to with setting parameters on the bloom shader that is part of the bloom compositor.

There's a lot that makes up a compositor ( as I've just discovered when doing the depth of field effect ), and they are quite difficult to explain unfortunately. However here is a brief outline of how it works in case it helps.

1) Compositor script -
This sets up a number of render targets, each of which will render the whole scene, or part of it using a specific material. You can also specify material schemes so that your objects all get rendered a certain way. You can also create a compositor in code without using a script.

2) Material Script -
Each target pass in the compositor may have a material added to it. This defines any effect ( such as blur ) that is added to the whole scene ( by this point the scene has already been rendered to a texture )

3) Shaders ( GLSL, Cg, etc ) -
A shader script can be added to a pass in a material, and this is usually what does the actual effect ( again like blurring the image ). You can control the in real time by setting shader parameters, which is what that code is doing

Hope that helps, sorry but it will take a very long time to explain all of this properly, you're better off reading the ogre manual and the wiki.