Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Shader Problem; Rubbish on screen
Topic Started: Sep 23 2007, 06:59 AM (360 Views)
$pecter
Member Avatar
Elite Member
[ *  *  *  * ]
I am working on adding a preview window to show the shader create in my shader creation program. When a new shader is created the old shader is cleared from the program and the new one is applied. However, rubbish is coming up on screen.
What could the problem be? (I have set the U3D window to fit into my interface)
Posted Image
The shader object's code is
CREATE
Code:
 
vertex_shader="TestShader.vsh";
pixel_shader="TestShader.psh";
priority=-1;
CreatePostScreenShader();

DESTROY
Code:
 
Destroy();
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
The cause of this problem may be that Ultimate 3D will never load the same shader effect twice. Let's say your vertex shader file has the location "effects/Effect.vsh" and the pixel shader has some similar file name. If you load this shader for the first time it will actually create a new shader from the data in the file. If you have modified the shader and load it again it won't create a new shader and won't react to the changes, because it already has that shader file in memory.

Ultimate 3D is not designed for the use for editors like this and this problem could actually be a bit hard to solve. Of course the easiest solution would be renaming the shader file after every change. But then Ultimate 3D would create a new shader object after every change and there's a limit of 200 different vertex shaders/pixel shaders. I could add in a little function to release shaders to some later version, just for this purpose, but you had to wait for quite a long time then.
Offline Profile Quote Post Goto Top
 
$pecter
Member Avatar
Elite Member
[ *  *  *  * ]
Somehow, I don't think that it is that.
Because even when I first apply the shader rubbish comes up (sometimes the rubbish is jumbled images of other programs if that helps).

If you wish, I will pm you the source.
Offline Profile Quote Post Goto Top
 
silverfire56
Forum God
[ *  *  *  *  *  * ]
what if you make 20 shaders for the changes made , (undo) then unload u3d and reload it?
or a clear cashe button that unloads u3d
what is required to access graphics memory anyway?
Offline Profile Quote Post Goto Top
 
$pecter
Member Avatar
Elite Member
[ *  *  *  * ]
Right now, I've just got it so the game restarts and loads the previous values from an ini when a new shader is made.

However, this does not appear to be the problem...
Quote:
 
Because even when I first apply the shader rubbish comes up (sometimes the rubbish is jumbled images of other programs if that helps).
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Have you made sure that your pixel shader sets r0.a to 1 at the end? If it doesn't the resulting output will be totally transparent, so Ultimate 3D won't draw anything at all to the screen. For that reason the last line in absolutely every post screen shader should be the following and c0.a should be set to 1.
Code:
 
+mov r0.a, c0
Offline Profile Quote Post Goto Top
 
$pecter
Member Avatar
Elite Member
[ *  *  *  * ]
Code:
 

ps.1.1
def c0, 0f, 0f, 0f, 1f
tex t0
sub r0.rgb, t0, c0
+mov r0.a, c0

Like this, yes?
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Yeah, that's right. Is that what you were already dong :huh: ?
Offline Profile Quote Post Goto Top
 
$pecter
Member Avatar
Elite Member
[ *  *  *  * ]
Yes, for more information you can download the source in my graphics forum topic.
Theres no rush, so take care of the other topics first. I'm going to bed soon anyway.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply