jnonline / ogstudio

Automatically exported from code.google.com/p/ogstudio
0 stars 0 forks source link

Research: OSG soft shadow mapping + normal mapping #585

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We need the following list of techs in graphics:
* soft shadow mapping
* bump mapping
* heightmap
* animated meshes
* particles, particle effects

Find out how they cooperate in plain OSG before implementing them in MJIN2.

Original issue reported on code.google.com by korn...@gmail.com on 10 Nov 2012 at 8:08

GoogleCodeExporter commented 9 years ago
Another tech to test: Screenshots, Ubershots issue 554

Original comment by korn...@gmail.com on 11 Nov 2012 at 5:01

GoogleCodeExporter commented 9 years ago
While re-arranging all ogstudio issues assigned to me, I've found out we need 
quite a bit more of OSG techs to test, not only these. May be it's necessary to 
separate/delegate them, and for me to proceed on more higher level issues.
Think.

Original comment by korn...@gmail.com on 11 Nov 2012 at 7:41

GoogleCodeExporter commented 9 years ago
I'm not quite sure how to be with bumpmapping and soft shadow mapping, because 
there must be single shader, not 2 different ones. Shaders cannot be 
"accumulated".
Ask at the mailing list how to be in such cases.

Original comment by korn...@gmail.com on 12 Nov 2012 at 8:01

GoogleCodeExporter commented 9 years ago
Asked, although can't see my question mirrored to the forum.

Original comment by korn...@gmail.com on 12 Nov 2012 at 8:16

GoogleCodeExporter commented 9 years ago
Looks like there's some 'shader composition'.

Original comment by korn...@gmail.com on 12 Nov 2012 at 8:25

GoogleCodeExporter commented 9 years ago
I got answered to compose shaders myself, though, have a look at shader 
composition first.

Original comment by korn...@gmail.com on 12 Nov 2012 at 3:43

GoogleCodeExporter commented 9 years ago
It's not reasonable to try out all OSG techs we need, it will take too long.
Instead, find out how to combine soft shadow mapping with bump mapping. Other 
techs will be studied later and/or in parallel.

Original comment by korn...@gmail.com on 13 Nov 2012 at 6:04

GoogleCodeExporter commented 9 years ago

Original comment by korn...@gmail.com on 13 Nov 2012 at 6:06

GoogleCodeExporter commented 9 years ago
Tested soft shadow map with different texture sizes. Size of 128 produces 
cartoon-like effect. Values lesser than 2048 may not look good enough.
See if it's easy to try out other shadow maps since there's self shadowing 
jitter here in soft one.

Original comment by korn...@gmail.com on 13 Nov 2012 at 6:25

GoogleCodeExporter commented 9 years ago
OSG 3.0.1 has the following shadow maps (include files):
* LightSpacePerspectiveShadowMap
* MinimalCullBoundsShadowMap
* MinimalDrawBoundsShadowMap
* MinimalShadowMap
* ParallelSplitShadowMap
* ProjectionShadowMap
* SoftShadowMap
* StandardShadowMap

Original comment by korn...@gmail.com on 13 Nov 2012 at 6:31

GoogleCodeExporter commented 9 years ago
Read about them.

Original comment by korn...@gmail.com on 13 Nov 2012 at 6:33

GoogleCodeExporter commented 9 years ago
http://www.openscenegraph.org/projects/osg/wiki/Support/ProgrammingGuide/osgShad
ow

Original comment by korn...@gmail.com on 13 Nov 2012 at 6:34

GoogleCodeExporter commented 9 years ago
I need to try all of them and see which one gives the best results. Also see 
what it takes to change shadow techniques. May be we can give the choice to a 
user.

Original comment by korn...@gmail.com on 13 Nov 2012 at 12:28

GoogleCodeExporter commented 9 years ago
Changing jitteringScale on SoftShadowMap didn't prettify the shadow. It doesn't 
look nice close.

Original comment by korn...@gmail.com on 13 Nov 2012 at 12:42

GoogleCodeExporter commented 9 years ago
Add shadow selection to the sample, since it's hardly visible from osgShadow 
example.

Original comment by korn...@gmail.com on 13 Nov 2012 at 12:54

GoogleCodeExporter commented 9 years ago
Soft shadow mapped did the best results with default values. Although I should 
ask about jittering since setting to 0 doesn't stop it from 'moving'.

Original comment by korn...@gmail.com on 13 Nov 2012 at 1:23

GoogleCodeExporter commented 9 years ago
Record the video and ask how to get rid of it.

Original comment by korn...@gmail.com on 13 Nov 2012 at 1:23

GoogleCodeExporter commented 9 years ago
Asked at the mailing list.

Original comment by korn...@gmail.com on 13 Nov 2012 at 1:37

GoogleCodeExporter commented 9 years ago
The problem is probably due to self shadowing.

Original comment by korn...@gmail.com on 14 Nov 2012 at 4:14

GoogleCodeExporter commented 9 years ago
Study soft shadow map shaders.

Original comment by korn...@gmail.com on 14 Nov 2012 at 4:15

GoogleCodeExporter commented 9 years ago
Shaders don't look like being a problem for integrating normal mapping.
I should see how SSM + NM looks like in our Room, may be it's a whole different 
story.

Original comment by korn...@gmail.com on 14 Nov 2012 at 5:04

GoogleCodeExporter commented 9 years ago
I wonder if we can have several lights for normal mapping.
For the record: 
http://www.geeks3d.com/20091019/shader-library-bump-mapping-shader-with-multiple
-lights-glsl/

Original comment by korn...@gmail.com on 14 Nov 2012 at 7:33

GoogleCodeExporter commented 9 years ago
OSG's shadow mapping uses single light, too.

Original comment by korn...@gmail.com on 14 Nov 2012 at 8:22

GoogleCodeExporter commented 9 years ago
shader composition example is weird.

Original comment by korn...@gmail.com on 15 Nov 2012 at 8:05

GoogleCodeExporter commented 9 years ago
see into its code to find out what it does.

Original comment by korn...@gmail.com on 15 Nov 2012 at 8:11

GoogleCodeExporter commented 9 years ago
osgViewer::Viewer::Window::getState::setShaderCompositionEnabled didn't become 
any clearer, but looks like it's some not-so-easy tech of OSG.
Anyway, try to combine ssm with nm with OSG's shader composition.

Original comment by korn...@gmail.com on 15 Nov 2012 at 9:45

GoogleCodeExporter commented 9 years ago
i should change camera location, because default one is inconvenient.

Original comment by korn...@gmail.com on 15 Nov 2012 at 2:29

GoogleCodeExporter commented 9 years ago
I need:
trans -7.66976 42.8298 -13.0977
rot 0.015239 0.453942 0.875093 -0.167081
But it's set after viewer's start. Can't set at the start.

Original comment by korn...@gmail.com on 15 Nov 2012 at 2:48

GoogleCodeExporter commented 9 years ago
Asked at the mailing list, totally out of ideas.

Original comment by korn...@gmail.com on 15 Nov 2012 at 3:19

GoogleCodeExporter commented 9 years ago
I've been answered to check for manipulator overriding my setup before each 
frame. I should see into TrackballManipulator's code probably, may be it has 
necessary methods. Or at least find out how it overrides my setup.

Original comment by korn...@gmail.com on 16 Nov 2012 at 2:48

GoogleCodeExporter commented 9 years ago
Positioned it. Had to use get/setTransformation of the manipulator instead of 
the camera.
Now I can proceed with NM addition to SSM.

Original comment by korn...@gmail.com on 16 Nov 2012 at 3:53

GoogleCodeExporter commented 9 years ago
The easiest way seems to be to simply copy-paste OSG's shader and then edit it 
to add NM, because I can't get my head around how to compose shaders inside 
SoftShadowMap.
Go the easier way.

Original comment by korn...@gmail.com on 16 Nov 2012 at 3:59

GoogleCodeExporter commented 9 years ago
Continue with ssmnm.frag.

Original comment by korn...@gmail.com on 16 Nov 2012 at 4:55

GoogleCodeExporter commented 9 years ago
Using ssmnm.frag with ssm copy pasted text only produces distorted image. Weird!

Original comment by korn...@gmail.com on 16 Nov 2012 at 6:00

GoogleCodeExporter commented 9 years ago
I should build getting source code of ssm from that file instead of hard coded 
text.

Original comment by korn...@gmail.com on 16 Nov 2012 at 7:55

GoogleCodeExporter commented 9 years ago
Got it. Just had to print what I read. Turned out file reading was done without 
new lines and so the whole shader code just got concatenated.
Now it's ok with ssmnm.frag file, the image is fine.
Continue with ssmnm.vert.

Original comment by korn...@gmail.com on 16 Nov 2012 at 8:15

GoogleCodeExporter commented 9 years ago
Btw, I wonder how to have some objects with ssm + nm and others with just ssm.

Original comment by korn...@gmail.com on 16 Nov 2012 at 10:10

GoogleCodeExporter commented 9 years ago
Will they be ignored if no texture provided?

Original comment by korn...@gmail.com on 16 Nov 2012 at 10:14

GoogleCodeExporter commented 9 years ago
May be that's where shader composition comes into play? To help blend?

Original comment by korn...@gmail.com on 16 Nov 2012 at 10:24

GoogleCodeExporter commented 9 years ago
I can add shader to StateSet of a group, e.g. So I guess we can have default 
SoftShadowMap shaders on all of the scene. And SSM + something on specific 
objects/groups of objects.

Original comment by korn...@gmail.com on 16 Nov 2012 at 11:58

GoogleCodeExporter commented 9 years ago
First I should try to setup one object with SSM + single colour fragment shader 
to find out if shader code injection has anything to do with shader composition 
in OSG or if I don't need to enable anything for the described scheme to work.

Original comment by korn...@gmail.com on 16 Nov 2012 at 12:01

GoogleCodeExporter commented 9 years ago
Export the table from Room into the scene.

Original comment by korn...@gmail.com on 16 Nov 2012 at 12:05

GoogleCodeExporter commented 9 years ago
Table looks weird, the textures are wrong.
Made a box in Blender with general texture as unit 1, and normal map as unit 4.

Original comment by korn...@gmail.com on 16 Nov 2012 at 1:06

GoogleCodeExporter commented 9 years ago
Create StateSet on a node doesn't help with custom shader.

Original comment by korn...@gmail.com on 16 Nov 2012 at 1:28

GoogleCodeExporter commented 9 years ago
Asked at the mailing list.

Original comment by korn...@gmail.com on 16 Nov 2012 at 1:44

GoogleCodeExporter commented 9 years ago
I've been told to look at osgshader example.

Original comment by korn...@gmail.com on 16 Nov 2012 at 4:21

GoogleCodeExporter commented 9 years ago
Any screenshots?

Original comment by Kai.Saerthen.Darker on 16 Nov 2012 at 7:49

GoogleCodeExporter commented 9 years ago
At the moment, it's the same as in 'shivering video': 
https://dl.dropbox.com/u/12634473/ssmjittering.ogv

Original comment by korn...@gmail.com on 17 Nov 2012 at 3:01

GoogleCodeExporter commented 9 years ago
Wow, I removed receive/casting shadow masks from nodes, and that shivering is 
gone! The soft shadow map is now very-very mild.

Original comment by korn...@gmail.com on 17 Nov 2012 at 3:49

GoogleCodeExporter commented 9 years ago
Fixed the shader for the box. Turned out it had an error. I found it out after 
I setup OSG to print errors to stdout. Wasn't looking at the log.

Original comment by korn...@gmail.com on 17 Nov 2012 at 4:20