3 registered members (Ayumi, Akow, AndrewAMD),
1,505
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: shade-c : lite-c shader project (HDR,DoF,etc)
[Re: mpdeveloper_B]
#190016
03/24/08 08:45
03/24/08 08:45
|
Joined: Aug 2001
Posts: 2,320 Alberta, Canada
William
Expert
|
Expert
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
|
Thank you very much for releasing this! I tried out a few of the shaders already. Although, I am having problems with a few that require the depthmap. For some reason I think it is rendering my depthmap as pretty much all black. In the DOF shader, the entire screen is blurred to the max, same with the haze shader. So I tried substituting the rendered depth map for one I made quickly in PS, to make sure this was a depth map problem, and it worked fine(white showed no blur, blacked showed much). But I need the depthmap to be rendered real-time. I foudn that if I change this line to this in the s_rDepth.fx: technique Depthmap { pass Pass0 { cullmode = none; alphablendenable=true; zwriteenable=true; // Lighting = true; fogEnable = false; VertexShader = compile vs_2_0 ShadowMapVertexShader(); PixelShader = compile ps_2_0 ShadowMapPixelShader(); } } It will render the depthmap partly better. All my texture are 32bit .tgas on my models in the test scene. But either way, no matter how much I mess with these variables: Code:
//DOF // my.skill90 = 1 => object will always stay sharp var s_bDOF = 1; //activate/deactivate dof var s_dofBits = 32; // 16/32/64 dof bitdepth var s_dofParams[3] = {55450, 420, 2.5}; //x = focal plane depth "area of sharpness" | y = focal plane pos | z = blurstrength //
//VOLUMETRIC LIGHT // my.skill89 = 1 => object is affected by volumetirc light //
var s_maxDepth = 55400; //Sets the scene depth. Setting this to a higher or lower value has no effect on the shaders except rendering the // scenedepth of course. If you write a custom shader and need a depthmap, change this value according to your needs. // This will most likely be used by the ambience occlusion shader in the future (if i ever get it done, that is ;) ) I cannot seem to get a DOF effect that is sharp in the front, and blurry in the back. It's just a blurry screen, or a blurry screen with some sharpness in an odd area... is there any way to output the depthmap, to see exactly what it's rendering? Or maybe it's something else? My models in my scene are very large, and are constructed a long way from their origin in MED, I don't know how a Depth Map is rendered or if this would be a problem...
|
|
|
Re: shade-c : lite-c shader project (HDR,DoF,etc)
[Re: DoC]
#190018
03/25/08 12:09
03/25/08 12:09
|
Joined: Mar 2006
Posts: 1,993 Karlsruhe
PadMalcom
Serious User
|
Serious User
Joined: Mar 2006
Posts: 1,993
Karlsruhe
|
I need a pro... :'( @Doc: The earlier you get used to Lite-C the faster you'll start to prefer it Same happend to me.
|
|
|
Re: shade-c : lite-c shader project (HDR,DoF,etc)
[Re: William]
#190019
03/25/08 13:10
03/25/08 13:10
|
Joined: Jun 2004
Posts: 655 to your left
BoH_Havoc
OP
User
|
OP
User
Joined: Jun 2004
Posts: 655
to your left
|
Quote:
It seems that you are storing data in these skills. Though, saying the user that these skills are unavoidable used by shade-C
makes a bitter taste on the tongue :-) I was in same situation some weeks ago: for a customer I made a plugin. At first there
were only 6 skills I needed, after some development iterations I used over 30 skills to save and log running data which very
necessary and not able to be reduced anymore. So I created a struct which holds the data and write the adress of the struct
into only one skill. The co-routine which works on that entity with this data than restores by casting each frame a pointer to
that datastructure. To remove the entity I wrote a special function which checks if the linking skill is != 0. If yes, the
entity is using that plugin and the linked datastructure, so it removes it first and after that ent_remove is called. Easy,
isnt it?
I only understood half of it, but i will have a look at it again when i'm less dizzy Reducing the needed skills to 1 is a must!
Quote:
Quote:
I'll have a look at it, but it shouldn't be to much work. But not today, i'm too tired.
Thanks!
Alright here goes: For HDR you have to create 6 views (or less if you only blur it once or twice). 1st view => s_hdrDownsample.fx : applies a 4x downsample 2nd view => s_hdrHighpass.fx : does a highpass for getting the bright parts of the scene 3rd view => s_hdrBlur.fx : blurs the highpass 4th & 5th view => s_hdrHBlur.fx & s_hdrVBlur.fx : blurs it even more 6th view => s_hdrTonemap.fx : upsamples the bloom (we did that in the last 5 views), combines it with the original scene and does tonemapping
the size of view 1-5 has to be a power of 4 (256x256, 512x512, depends on your game's resolution). view1-5.bmap also needs to be a power of 4 (same as size)
s_hdrHighpass.fx vecskill1.x => sets the bloomstrength (range: 0-1) s_hdrBlur.fx & s_hdrHBlur.fx & s_hdrVBlur.fx vecskill1.x => sets the blurstrength s_hdrTonemap.fx vec.skill1.xw => x: applies gamma correction w: size of view 1-5
camera.stage = view1; . . view5.stage = view6;
that should be it (for HDR)
DoF: 4 views for dof + 1 view rendering the depthmap (s_rDepth.fx) 1st view => s_dofDownsample.fx : 4x downsample, you know the drill 2nd & 3rd view => s_dofHBlur.fx & s_dofVBlur.fx : blur it and apply anti edge bleeding 4th => s_dof.fx upample the blurred view, combine it with the original scene using the depthmap
again, view 1-3 have to be a power of 4 and 256² oder 512² in size/bmap.
s_dofHBlur.fx & s_dofVBlur.fx vecSkill1.x => blurstrength s_dof.fx vecSkill1.w => size of view1-3 | texture TargetMap; //Blurred Scene texture mtlSkin1; // original Scene texture mtlSkin2; // Depthmap
s_rDepth vecSkill1.xyz => x = focal plane pos | y = focal Plane depth / area of sharpness | z = if you set this to 1, the object will be rendered white (=sharp) all the time. The DoF-Depthmap gets rendered to .a ! s_rDepth also outputs a "normal" depthmap to rgb. you can set its values with vecSkill5.xy (x maxDepth | y focal plane)
camera.stage = view1; . . view3.stage = view4;
and thats it for dof. I hope i didn't forget something.
Quote:
edit: i noticed that you kinda did it with the toon shader, but maybe witout bloom it would look better
Yeah, i have HDR and DoF activated on this shot. If you deactivate them there won't be any bloom But thanks for pointing it out, i will write a note after "Cartoonshader" on the site and also upload a new picture.
Quote:
I need a pro... :'(
I don't even have A7 Pro myself. All you need is A7 Com
@William: I have no idea whats happening here. Could you try setting s_dofParams to something like this: var s_dofParams[3] = {900, 80, 2.5};
and then calling s_dofDynFocus(30,10000,1); after s_initShaders()? If everything works out, every object you look at should become sharp.
To output the Depthmap you can use this: open up s_showRT.fx, find this line float4 Color = tex2D(smpSource,(Tex.xy)); and insert this after it Color.rgb = Color.a;
Now call this after s_initShaders(); s_ppe(1,"s_showRT.fx",nullvector); s_ppeTex(1,1,s_bmap_depth);
This should output the DoF-Map. Also please make sure you have set s_bDoF = 1 before callign s_initShaders(). If you don't want to set s_bDoF, please call s_initDepth() so the depthmap gets rendered.
cheers and thanks for all the feedback. I see i have lots to improve
|
|
|
Re: shade-c : lite-c shader project (HDR,DoF,etc)
[Re: BoH_Havoc]
#190020
03/25/08 13:16
03/25/08 13:16
|
Joined: Mar 2006
Posts: 1,993 Karlsruhe
PadMalcom
Serious User
|
Serious User
Joined: Mar 2006
Posts: 1,993
Karlsruhe
|
As long as Conitec doesn't lower the prices for students I will keep my Extra! But Shaders are so great that I'm really thinking about investing now Thanks again for the code, it helps a lot to understand the use of shaders! P.S. The directX dll is missing in your sample project...
|
|
|
Re: shade-c : lite-c shader project (HDR,DoF,etc)
[Re: BoH_Havoc]
#190021
03/25/08 17:27
03/25/08 17:27
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Thanks for working it out. I will tell ya when I have figured out something. Here is a snippet how to associate datastructures with entities: Code:
// some random datastructure
typedef struct ZUZU { char frame [128]; var speed; var mode; } ZUZU;
// associate datastructure
ENTITY* ent = ent_create(...); ZUZU* dingDong = ... ent->skill[10] = (long)((void*)dingDong); //link datastructure with skill
// retrieve datastructure
ZUZU* fooBar = (ZUZU*)(ent->skill[10]);
|
|
|
Re: shade-c : lite-c shader project (HDR,DoF,etc)
[Re: BoH_Havoc]
#190022
03/25/08 21:53
03/25/08 21:53
|
Joined: Aug 2001
Posts: 2,320 Alberta, Canada
William
Expert
|
Expert
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
|
I checked out the depthmap and noticed that all particles render as black. So I turned off particles -
s_view_Depth.clip_near = 0; set(s_view_Depth,NOSHADOW); set(s_view_Depth,NOPARTICLE);
and I can see that the depthmap is completely black if in the shader it is like this -
technique Depthmap { pass Pass0 { cullmode = none; //alphablendenable=true;
VertexShader = compile vs_2_0 ShadowMapVertexShader(); PixelShader = compile ps_2_0 ShadowMapPixelShader(); } }
or completely rendered white if it's like this -
technique Depthmap { pass Pass0 { cullmode = none; alphablendenable=true;
VertexShader = compile vs_2_0 ShadowMapVertexShader(); PixelShader = compile ps_2_0 ShadowMapPixelShader(); } }
I don't know what the cause of this is... I'm pretty sure I had a depthmap shader working in my project before. But I can't seem to figure out this one, I turned of fog too, but that doesn't seem to be the problem. Changing the values for the dof effect don't seem to do anything.
|
|
|
Re: shade-c : lite-c shader project (HDR,DoF,etc)
[Re: BoH_Havoc]
#190024
03/27/08 08:11
03/27/08 08:11
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
Joined: Mar 2006
Posts: 3,538
WA, Australia
|
if you're using a floating-point depthmap, perhaps William's problem is hardware incompatibility.
julz
Formerly known as JulzMighty. I made KarBOOM!
|
|
|
|