D3D Scripts

User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

D3D Scripts

Post by clintonman »

I was looking for a way to make an Unreal Engine 4 material for trueSpace workspace and found the fx files in the scripts folder. I did a test and altered the bloom effect. I modified it so it only blurs horizontally.

Image below shows the result, the default blur and bloom unchecked. It may be possible to add post process effects like blur, glow, distortions, fog
horizblur.jpg
fullblur.jpg
noblur.jpg
I also found what I was looking for in the cook-torrance fx file. I made a copy gave it new description, name and guid. Can load it via script command
D3DView.ImportBrick("C:\\trueSpace761Std\\Scripts\\MaterialEditor\\Bricks\\Compound\\CookTorrance3.Brick.xml",Space.CurrentScene());

For this one I would liek to add an environment reflection and maybe alter it to use the newer GGX instead of Beckmann distribution
Clinton Reese

http://clintons3d.com
User avatar
Draise
Captain
Posts: 3198
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

Re: D3D Scripts

Post by Draise »

Oh Beautiful!

Yeah, I was thinking and started documenting what I would need to create a PBR shader - or how I would make a script to make cubemap or spherical reflection probles to the environment map using the camera projection trueSpace comes with.

I also was experimenting on Micro Normal maps to alter the "roughness" of reflections and things. I can see potential in trueSpace, because a micronormal map is really small and you can tile it to the thousands, ultimately creating the diffused roughness you would see on most PBR materials. I haven't sat down and developed anything at all - but I'm SO happy that you too have similar ideas and that you actually ARE making something happen with it!

Love the new bloom/blur effects you are doing.
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: D3D Scripts

Post by clintonman »

Thanks, I looked at the bloom and it looks like only the final image is available by bloom time and there's no way to add more controls. So I think the final bloom will have options for alpha, blur and glow by using the existing controls with filtered values so a value of 100.1 will become a value of 0.1 and the 100 will mean "do alpha pass".
Here's the alpha I came up with. It doesn't work with the background color so there is a sphere with alpha value surrounding the scene. Funny that the wireframe grid shows and you can see the semi-transparent navigation widget.
alpha.jpg
I think for non-metals the PBR will be "easy". There is a youtube video for showing how it's done with Blender.
https://www.youtube.com/watch?v=8HMS1MG ... WL&index=3" onclick="window.open(this.href);return false;
PBR is useful for matching Unreal, but also good for matching rendermans pixar shaders.
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: D3D Scripts

Post by clintonman »

Here it is, the final result.

Post Process settings:

set Scene Intensity to 100 to get only the bloom, which is really a blur
Bloom Intensity, Smoothness and Downsample are still active

set Scene Intensity to 200 to get alpha values as gray color

any Scene Intensity value below 100 will behave the same as before


Installation:

copy or rename
C:\trueSpace761Std\Scripts\D3D\RsD3DBloomFilter.fx so you have the option of going back to the original behavior
unzip and copy the new RsD3DBloomFilter.fx in it's place
restart truespace
Attachments
RsD3DBloomFilter.zip
(1.29 KiB) Downloaded 243 times
Clinton Reese

http://clintons3d.com
User avatar
Draise
Captain
Posts: 3198
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

Re: D3D Scripts

Post by Draise »

Wow, nice.. So..... do you think the same blurry Postprocess can be plugged into a Camera Texture Projector?
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: D3D Scripts

Post by clintonman »

Draise wrote:Wow, nice.. So..... do you think the same blurry Postprocess can be plugged into a Camera Texture Projector?
I think that would work using HLSL shader bricks.
Here's a picture using the blur from my compositing nodes. It runs too slow and is a bit finicky. The tS post process also uses a simplified faster blur. HLSL using the faster blur should work well.
blurcamera.jpg
Clinton Reese

http://clintons3d.com
User avatar
Draise
Captain
Posts: 3198
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

Re: D3D Scripts

Post by Draise »

I have used your blur HLSL brick before, it can be a bit slow yes. I guess the post-process brick could be replaced with your new one that you just made for the faster blur.
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: D3D Scripts

Post by clintonman »

Draise wrote:I have used your blur HLSL brick before, it can be a bit slow yes. I guess the post-process brick could be replaced with your new one that you just made for the faster blur.
Almost...
The post process lives outside truespace in .fx file, so it only works with the bloom. The good news is that the commands in the fx file are close to what's needed to make a HLSL brick. My blur node doesn't use HLSL code, it's C++. I think an HLSL will be faster because it runs on the gpu. We'll see, I plan to throw together a blur script now.
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: D3D Scripts

Post by clintonman »

Not as easy as I thought. The fx file can process the image in passes, meaning it can feed the resulting image into the next step. The HLSL brick only does one pass. If the full image can be stored in HLSL then simulating multiple passes is possible otherwise it isn't. Next I'll see if I can adapt my blur node code from C++ to HLSL.
Image shows blur in horizontal. A second pass in vertical is needed to complete the effect.
halfblur.jpg
A blurplane mesh is attached here. Add to a scene and hook up the image. No UI, not user friendly and no clue what good values can be used yet.
Attachments
BlurPlane.zip
(26.58 KiB) Downloaded 250 times
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: D3D Scripts

Post by clintonman »

First results of "pbr" material. Left sphere has a little bit of roughness and the right has more. The material uses 16 samples of the image at each pixel and runs slowly. I tried 64 samples and tS couldn't handle it. For comparison the source code I found had 128 samples and another had 1024 samples. The code isn't designed for speed. The roughness randomizer also uses very slow code, but it may not be possible to increase it's speed in HLSL so some other solution or hack will be needed. Precomputing some values and storing them in a image is one method of speedup outside of the roughness calculations.
pbr1.jpg
Clinton Reese

http://clintons3d.com
Post Reply