Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Darkshader help

Author
Message
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 15th Mar 2009 14:01
I have just started using darkshader and i have imported a coroma fx file but it asks me to useother textures when it doesnt really use textures that i know of, so i used some randoms and sphere primitive but theeffect and the sphere do not show in the preview...

any idea whats going on here?

and if it is impossible to fixmaybesomebody could help me tocreat apost corona effect for a sun that can have the color and brightness changes in DBP...
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 15th Mar 2009 23:32 Edited at: 15th Mar 2009 23:36
I've experienced some troubles trying to import HLSL shaders from other sources into DBPro as well. I think DBPro just has some "idiosyncrasies" that make new shaders require a bit of tweaking before they can be used.

Anyhoo, I'd never done this kind of shader before, so I decided to give it a whack. Here's a very basic shader that gives a sphere a simple corona effect. It looks nice on a sphere with 40 rows and columns.

The shader takes two textures: a diffuse texture, which will be displayed on the opaque part of the sphere, and a dynamic background texture, so the corona can fade out to nothing. The textures are mapped to stages 0 and 1 respectively.

I guess you're using Dark Shader, so there are three variables thus far you can tweak. First, the color of corona fade color is red by default. Second, you can change the amount of the fade color vs the diffuse texture to display, and finally, you can change the amount of the sphere to display as opaque.

Right now, there's no brightness setting, but feel free to add it in.

I don't know how familiar you are with HLSL, but this shader might help you learn the ropes a bit if you're interested.

Feel free to ask if you have any questions about modifying, implementing, or anything about the shader.

Edit: Oops, wrong attachment. It's fixed now.

Attachments

Login to view attachments
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 16th Mar 2009 00:26 Edited at: 16th Mar 2009 01:38
ok im very new to shaders and dont really know anything about them, but i was able to use it in a little snippet and it looked like a good start, but im more worried about the one i have..

i will upload it if anybody wants to take a look, but i think im going to need to learn a bit of shader language and how it actually works before i can move forward anymore with this...

EDIT1: I just looked through the code and its trying to include a file "Quad.fxh" could that be the problem..

I tried compiling it and it couldnt find that file...

Attachments

Login to view attachments
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 16th Mar 2009 02:39 Edited at: 16th Mar 2009 02:41
Wow, I feel that shader is far more complicated than I could make sense of at the moment. But you are correct, it's throwing an error because it can't find Quad.fxh. Later on, it also needs noise_3D.fxh. Those files should be in your FX Composer project's folder under HLSL/include. At least, I'm assuming that's where you got the shader.

Anyhoo, I think that twisting your shader hard enough so it works with DBPro is going to be a rather huge task.

Edit: Another thought, if you could post a screen shot of what the shader is supposed to look like, we might be able to find a workable alternative...
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 16th Mar 2009 05:37 Edited at: 16th Mar 2009 05:39
Here is the Image of the effect

pretty much all i want is a dynamic shader (can change color and brightness easily [preferably in DBP]) that will simulate the surface of the sun or another star....

Attachments

Login to view attachments
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 17th Mar 2009 00:21
Alright, well I've come up with another shader that does all of that and somewhat resembles the screen shot you posted.

The only real differences between this one and the last one, are that this one provides a brightness setting, and uses Perlin noise to generate the texture on it, which looks a lot like what yours is doing.

So now, you can change the high and low colors of the noise, along with the fade color. Additionally the brightness of the star along with it's size is also customizable. Finally, the size and speed of the noise generated can be changed too.

The shader requires two textures: a dynamic background texture for the translucent corona, and a random texture for generating pseudo-random numbers with the noise. I've included a "random.dds" in the attachment that you should use for the random texture.

This shader is a little taxing on a system as I'm sure any noise generating shader is. It also requires pixel shader version 3. You can check yours and that of your users with the get maximum pixel shader version() command.

The only problem with this shader is in the noise generation. There are these annoying lines colored seemingly opposite to the noise gradients all over the sphere. I struggled with this problem until 5:00am last night and couldn't determine why they're there or how to get rid of them. I'll continue to fiddle with it, and any help from anyone who knows a bit about HLSL shaders would be greatly appreciated. I shant rest.

Sorry if this problem is too much to be ignored, I'm sure there are ways around it...

Attachments

Login to view attachments
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 17th Mar 2009 01:06
omg thats almost perfect..

is there a way to generate the noise so that it doesnt take up too much cpu

thanks soo much for this...
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 17th Mar 2009 10:18
Alllrighty. So, I've gotten rid of the lines. And oh man, should I have fixed it sooner.

MipFilter= ...you ready for this? None;

There. That was the ONLY problem with it. Something so little shouldn't have set back so much.

Anyhoo, I've attached the fixed shader and all.

Hm, I'd really like to generate noise with less of a resource tax, but I don't know how possible that would be using a shader. The only real problem I run into is the generation of pseudo-random numbers. The only way I could solve it was to read them out of a texture. If anyone knows a better way, I'm open for enlightenment.

Hope this helps.

Attachments

Login to view attachments
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 18th Mar 2009 03:39
ok i tried using it in a new snippet



but it turned up without the texture, si applied it and it looks really weird...

what can i do to fix this..

and will it scalle when i make it bigger..
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 18th Mar 2009 04:09
Here, I've written up a little snippet to demonstrate how to use a shader that requires a transparency texture as well as more than one texture.



Just replace the paths of the shader and the random texture to the ones you used in your snippet and it should work fine.

The shader will scale if you want it to. However, if you only scale the object, the noise will look smaller and smaller. You need to change the size of the noise in the shader as well as change the size of the object.

Hm, everything works nicely until you get close to the star... the frame rate drops rather dramatically the more of the screen the star takes up...

I suppose I could fiddle around with other ways to generate noise, but I'm pretty sure options are limited. Again, if anyone else reading this knows an alternative for creating noise, please say something.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 18th Mar 2009 04:32
how would i change the size of the noise...
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 18th Mar 2009 04:39
The easiest way would probably be to change the value using the slider in Dark Shader, and then to right click on the shader and select Export .fx.

Another way would be to open up the shader itself and to change the value of NoiseSize;

It's important to keep in mind that the size of the noise is constant independent of the size of the sphere it's on. The default primitive sphere in Dark Shader is of size 100, I believe. Keep that in mind when deciding how big to make the noise for the size of sphere you'll be using.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 18th Mar 2009 05:00
is there a way to change it in DBP, in the hep files it mentions something about it (in darkshader)..


i will probably be using this with different objects of different sizes and colors.
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 18th Mar 2009 05:15
Here's the same snippet as before, but I added in a bit of code demonstrating how to change different types of values:



Here are the changeable values for this shader and their types:

Name - Type

HighColor - vector
LowColor - vector
FadeColor - vector
ColorFadeAmount - float
Brightness - float
SunSize - float
NoiseSize - float
NoiseSpeed - float

A note about changing colors: you might have noticed that colors are defined with numbers 0-1 for each channel: red, green, blue, and alpha. In this particular shader, the alpha channel is completely useless, so just set it to 0 or something. Other than that, you pick a color you like with some image editor, and then take each of the RGB values and divide them by 255 to get the number you should give the shader. Like in my snippet, I set the color to (0,1,1,0) (cyan) which translates to (0,255,255,0).
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 18th Mar 2009 05:54
ok so i need to enter in the other constants and floats like the ones you put in...
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 18th Mar 2009 05:57
Only if you think the default value needs to be changed. If you don't set your own value, it'll continue using the default. This section of code defines all the defaults:

lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 18th Mar 2009 07:08
cool thanks for that heaps..

if only i could get the frames back up..

also what causes the shader to be version 3......
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 18th Mar 2009 07:17
Yeah, the frame rate's a bit of a bummer...

Well there are certain features in HLSL available with newer shader versions. In fact, try viewing the shader code in Dark Shader and then scrolling all the way to the bottom where it says "ps_3_0" and change it to "ps_2_0" which will try to compile the pixel shader with version 2.0 and look at the error message it shows in the preview window.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 18th Mar 2009 07:21
ok cool...

is it possible to generate the noise and save it, then the shader can use the noise as a texture
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 18th Mar 2009 07:38
I've been trying to come up with ways of doing that, but haven't been very successful. The problem is, that doing so would have to be done outside of the shader. Secondly, the noise currently generated is not scrolled, it's actually generated "throughout" the sphere. If you'll notice, in the positive and negative x,y,z direction the noise looks like it's coming out of or going into the sphere as opposed to just scrolling a texture all around.

So basically, if we used an outside texture, we'd gain the frame rate back, but we'd lose a lot of quality.
lucifer 1101
15
Years of Service
User Offline
Joined: 26th Jan 2009
Location: Melbourne, Australia
Posted: 18th Mar 2009 07:47
i think we need green gandalf to help us here...

im learning from this so thanks again...
Kira Vakaan
15
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 18th Mar 2009 07:52
Ah yes, I'd agree.

However, I think in the UK it's almost 6am... in fact, it's just about 2am here, so I think I'll call it a night.

Good luck.

Login to post a reply

Server time is: 2024-11-24 11:34:10
Your offset time is: 2024-11-24 11:34:10