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.

DarkBASIC Professional Discussion / [STICKY] Learning to write Shaders

Author
Message
cjb2006
17
Years of Service
User Offline
Joined: 20th May 2006
Location:
Posted: 31st Dec 2008 19:31
I guess I'm dumber than I thought because I have no idea what that means.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Dec 2008 19:55 Edited at: 31st Dec 2008 19:57
Doesn't make you dumb... look at the attached bitmap - it has a texture and a normal for it. Two separate files - just slammed together so I could upload one easy to view image.

--Jason

[edit] the normal map - often called dot3, uses the rgb channels to describe the normals, often the alpha channel is used to describe the specular - and most people over-do the specular making everything look wet and shiny. this is usually the basis for paralax/bump mapping - I don't know which really is which and don't care - I think of it as bump mapping, others saw relief shading I dunno.... but it looks cool.[/edit]

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Dec 2008 19:57
Quote: "I guess I'm dumber than I thought because I have no idea what that means."


I guess he means you should be using a standard normal map - but I guess you are doing that already, but you might not be of course.

I've had a quick look at the shader and at first glance something vital has been commented out. Rather than try to correct or re-write it, you might like to try the attached demo of mine, and adapt it as necessary.

Attachments

Login to view attachments
cjb2006
17
Years of Service
User Offline
Joined: 20th May 2006
Location:
Posted: 31st Dec 2008 20:42
Thanks GG. No adaptation necessary - works fine as is and was the easy fix I knew had to be there. I just can't wrap my head around the relationship of the world , view and projection matrices or I wouldn't have to waste time with these basic questions.
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 31st Dec 2008 20:47
And me... chopped liver? LOL - Glad you got it bro.
--Jason

dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 31st Dec 2008 20:57 Edited at: 31st Dec 2008 21:00
[edit] Err, seems I was looking at the wrong page .

cjb2006
17
Years of Service
User Offline
Joined: 20th May 2006
Location:
Posted: 31st Dec 2008 21:02
Well dc,

from what I saw before you took it down - that was the right answer. LOL.
The Viking
15
Years of Service
User Offline
Joined: 21st Oct 2008
Location: Asgard
Posted: 31st Dec 2008 21:17
Does anyone know why the lighting is not coming from the same side on my previous pictures? If you need the texture and normal map, i will provide them. Thanks again
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Dec 2008 21:35
Quote: "Does anyone know why the lighting is not coming from the same side on my previous pictures? If you need the texture and normal map, i will provide them. Thanks again "


Better still, could you post a complete simple demo, i.e. dba file plus all media (not the exe file)? Or email it to me if you prefer.
Swamp donkey
16
Years of Service
User Offline
Joined: 29th Dec 2007
Location: Gothasoft
Posted: 1st Jan 2009 05:18 Edited at: 1st Jan 2009 05:20
Quote: "That is SWEET! You keeping that one under wraps (understandable) or will you release that one? "


Well the shader is really tied deeply into the tree engine. It handles alot of stuff, rotations, eyevector fading, ambient toning, Uv rotation and gradient color templates. Unlikely it would do much of anything outside of what it was created for. But if your looking for a simple shader to allow ya to adjust the AlphaRef value and set transparency(opaque) values via db code then i could probably strip out those sections of the sahder and post it.

- vista / 4gb / 8800gts
jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 1st Jan 2009 07:59 Edited at: 1st Jan 2009 07:59
Thank You. Don't Bother... I might wait to see how your Tree Engine progresses... and then maybe apply it to DarkGDK - say if you make a pay/free package with it. It Looks REALLY Awesome. I do appreciate that offer of yours, but I wouldn't be as stoked unless it looked like your gorgeous trees!

You did awesome on that one in my opinion!

--Jason

Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 1st Jan 2009 23:19 Edited at: 1st Jan 2009 23:21
Just finished the first draft of my painterly rendering shader...

The code is very unoptimised, but still get ~30FPS on my computer, which has integrated graphics.

Should be able to get it up to 60FPS with a simple scene like this.
The nice thing about this shader is it looks nice even at 15FPS, the frames are blurred together and the whole thing has a nice dream like quality.

Also need to refine the style a bit, it's not quite right. Anyway, I am pleased with how it's going.

Here is Colonel Z from Media, inside an empty room.


-= Out here in the fields, I fight for my meals =-

Attachments

Login to view attachments
Math89
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 2nd Jan 2009 09:03
Waw, this shader looks great.

Mike Inel
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Sa upuan ko po...
Posted: 2nd Jan 2009 09:43
Wow, awesome! It really looks like an oil paint!

jason p sage
16
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 2nd Jan 2009 14:18
Yeah Chris K - I don't much about shaders yet - but I'm impressed!

--Jason

Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 2nd Jan 2009 16:02 Edited at: 2nd Jan 2009 17:14
Quote: "Wow, awesome! It really looks like an oil paint!"


Yeah, this one did come out a lot like an oil painting, with almost opaque strokes and quite thick.

The good thing about this shader, is that the rendering style should be quite easy to change, ie, you can convert it to chalk drawing, pencil sketch etc.

I am just working now on picking which lines to paint, which means I will get much more detail for the same amount of time.

You can see in this picture here that if you have a high density of thin strokes you can really pick out the shape of the cheeks/nose etc...


^ You can see that there is a higher density diamond in the middle of the screen

=================================

@ GG, or anyone else in the know...

What's the deal with intermeadiate render targets?
At the moment I have one camera that looks at the scene, and outputs an image of it, then this gets textured to a plain with another camera looking at, that makes the normal map, then THIS gets textured to a plain with ANOTHER camera looking at it that blurs it horizontally, the *THIS* gets textured to a plain with *ANOTHER* camera looking at it that blurs it vertically.

Surely this can be done better?

I just want to give something an image and have it give me back a blurred normal map of that image...

-= Out here in the fields, I fight for my meals =-

Attachments

Login to view attachments
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jan 2009 19:36 Edited at: 3rd Jan 2009 12:05
Quote: "What's the deal with intermeadiate render targets?
At the moment I have one camera that looks at the scene, and outputs an image of it, then this gets textured to a plain with another camera looking at, that makes the normal map, then THIS gets textured to a plain with ANOTHER camera looking at it that blurs it horizontally, the *THIS* gets textured to a plain with *ANOTHER* camera looking at it that blurs it vertically.

Surely this can be done better?

I just want to give something an image and have it give me back a blurred normal map of that image..."


I expect the answer is yes - but I'm not sure how many intermediate render target stages you can have. You might like to look at the attached demo which performs blurring by doing separate horizontal and vertical passes via an intermediate render target. The demo uses some of the new commands that come with Dark Shader which might be another test of your setup.

It's possible that the demo could be refined further along the lines you describe - and also by making use of some commands that have recently been added to DBPro.

Edit Improved the demo by using paste image instead of a screen quad (thanks to Chris K) - and added Chris K's simplified demo using sprites.

Attachments

Login to view attachments
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 2nd Jan 2009 19:39 Edited at: 2nd Jan 2009 19:45
That runs fine for me! No idea what is wrong with Dark Shader...

What are the new commands you are talking about?

----------

Nevermind, the camera effect ones. I see. This is great, cheers!

-= Out here in the fields, I fight for my meals =-
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jan 2009 21:02
Quote: "Nevermind, the camera effect ones. I see."


No, I was thinking of commands like set screen effect, probably introduced in U7.0 - not sure because I jumped from U6.8 to U7.1 so I haven't got the upgrade details (either that or I deleted them ).
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 2nd Jan 2009 21:11
I really don't understand how the camera effect and screen effect stuff works, would you mind explaining...?

What arguments do all those functions take?
How can you specify the dimensions of an image produced with a camera effect?

Thanks a lot

-= Out here in the fields, I fight for my meals =-
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jan 2009 21:28
Quote: "I really don't understand how the camera effect and screen effect stuff works, would you mind explaining...?"


I'm not sure either. I'll post back when I've refreshed my memory - but it might need a re-boot (and a bit less beer - New Year's Day lasts several days in this house).

Actually I was wrong in my previous post - the new commands do seem to be part of U7.1. I think they are:



These all look useful but I haven't tried them yet. Looks like it's time for Dark Coder to jump in with a demo.
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 2nd Jan 2009 21:41 Edited at: 2nd Jan 2009 22:18
Ok, I have stripped down your demo to the absolute basics-



No confusing Quad stuff going on now.
Still can't find any way of reducing the resolution of the image that camera 1 is spitting out...

It is not going to be helpful if it is rendering at the screen resolution.

--------------------

Is there any way of using intermeadiate render targets in an object shader?

Just checked and you can edit the resolution with set camera view - but I am not convinced that it makes it any faster...
EDIT: In fact, I think I am convinced that it doesn't make it any faster

-= Out here in the fields, I fight for my meals =-
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jan 2009 01:06
Quote: "Ok, I have stripped down your demo to the absolute basics-"


Nice work. I was about to try something similar. No need now.

Quote: "Still can't find any way of reducing the resolution of the image that camera 1 is spitting out..."


Neither can I - but brain is tired.

I tried reducing the resolution by a quarter in the shader - but that just gave the same size image consisting of blocks of 4x4 identical pixels. Didn't check the effect on speed though.

Quote: "Is there any way of using intermeadiate render targets in an object shader?"


I can't remember. If you can, then you can get your reduced resolution easily using the "old" way via set camera to image etc.

Looks like I've found yet another reason not to tidy the garden this weekend.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jan 2009 12:01
I've simplified my blur demo about 6 posts back (thanks for the nudge Chris K ) and also included Chris K's version which uses sprites. My revised demo uses paste image.

The screen quad is probably only needed if you want to do some further processing of the image - but could this be done using an extra pass in the original shader? Food for thought.

Anyone up for the challenge?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 3rd Jan 2009 12:57
Ok, so I understand - you can reduce the resolution of the intemeadiate steps by setting float2 ViewportRatio = { , } in all the samplers.

Still can't find any way of reducing the final output of the camera shader - but as this is the simplest possible shader, I don't think it matters that much.

-= Out here in the fields, I fight for my meals =-
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jan 2009 14:17 Edited at: 3rd Jan 2009 14:20
Quote: "Ok, so I understand - you can reduce the resolution of the intemeadiate steps by setting float2 ViewportRatio = { , } in all the samplers."


Yes.

Quote: "Still can't find any way of reducing the final output of the camera shader "


No, it seems to assume you're outputting to the screen and uses that resolution. I agree a bit of extra flexibility would be useful - unless we've overlooked something.

Edit Have you tried the intermediate render target idea with the usual set camera to image route?
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 3rd Jan 2009 14:46
I'm not really sure how you could do that. You would have to then apply a shader with intermeadiate render targets to an object, and I don't think you can do that, at least I haven't been able to get it to work.

-= Out here in the fields, I fight for my meals =-
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jan 2009 15:47
Quote: "I don't think you can do that, at least I haven't been able to get it to work"


I think that was what I decided - but I've mislaid the demo I was using and didn't record my findings.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 5th Jan 2009 11:32 Edited at: 5th Jan 2009 11:35
All render targets must be the same size and bit depth. I believe if you capture the screen as an image and feed it into a shader, and use the color0 sematic it is going to either write to the backbuffer, or your currenly selected render target. If you want to write to multiple targets at the same time. you need to use color0, color1, etc. but you can only write in order and cant skip from around say from color1 to color0. I just wrote a deferred shading system in DX and C++, and coming from dbp, to that, I learned that basicaly the set camera to image is just somehow redirecting the screen write.

DBP is doing something that I dont understand and can render to more than 4 targets at once as demonstrated by the following code. I dont understand how this is possible. One thing I can think of is that there is some kinda swap going on. Perhaps its rendering everything more than once? I know for a fact you can only render to 4 targets at once. Its clearly stated in the DX 9 docs. Maybe they are using some kinda swap chain, in which case it still doesnt explain how its doing it.



Well either way I dont know how dbp handles render targets. I dont even know if its even using them or handling these issues in some other way. Oh well if this dont make sense to anyone then I guess I need to work on my explining skills. lol.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Jan 2009 12:05
Quote: "I know for a fact you can only render to 4 targets at once."


Perhaps DBP renders the cameras in sequence? In other words the "sync" in your snippet is equivalent to



Hence each "sync" is only rendering to ONE render target - and these can be of different sizes of course. However, like you, I don't know for certain.

Quote: "Well either way I dont know how dbp handles render targets."


Neither do I. It would be nice if Lee or Paul came to our help here.

Quote: "Oh well if this dont make sense to anyone then I guess I need to work on my explining skills."


Your comments make perfect sense to me - we just both need to be better informed by those in the know.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 5th Jan 2009 15:37
Quote: "All render targets must be the same size and bit depth"


Only if rendering to multiple render targets in a single pass, dbpro doesn't do this as far as I know. It renders each camera one at a time to a different render target (image).

Quote: "I really don't understand how the camera effect and screen effect stuff works"


The ShaderData commands, as I call them, basically wrap up the whole process of set camera to image, draw to quad, set to image again, draw quad again, and do the same thing but behind the scenes, using the settings specified in the shader (as you found the viewport keyword changes the texture size). I couldn't make it completely automatic as I ran into a problem trying to draw the final screen quad image to the screen, that's why the last screen quad is always done manually in DarkShader examples, and doesn't do any processing.

Quote: "then THIS gets textured to a plain with ANOTHER camera looking at it that blurs it horizontally, the *THIS* gets textured to a plain with *ANOTHER* camera...

Surely this can be done better?"


Surprisingly not, to get the graphics card to process an image it has to be textured to something and it can only process so much in one pass, so this process of texturing quads and repeatedly sending them through the render cycle is, to the best of my knowledge, how all fullscreen shaders are done.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 5th Jan 2009 17:52
That's pretty smart really. That way you can have as many render targets as you like and you get the added benefit that it will also run on older hardware thats don't support MRT's. Well the only obvious drawback would be rendering the scene multiple times.

I think that you have to send something to the rasterizer. I've always sent something so I've actually never tried not sending things?
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 8th Jan 2009 23:37 Edited at: 8th Jan 2009 23:45
I'm still not understanding how the new commands are to be used for bypassing the need for intermediate processing plains.

It seems like the "Set Screen Effect" command is simply used to apply a single technique to whatever is shown on screen. This may be able to bypass the need for a single intermediate processing plain, but what about when you want to use 3 or 4 techniques on the screen, like Bloom??


The one and only,


Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 12th Jan 2009 12:07
Congrats on your little flag GG!

Deserved.

-= Out here in the fields, I fight for my meals =-
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 12th Jan 2009 19:55
GG: Very well deserved indeed, congratulations. I`ve never seen one before(been on the internet, mainly this site, a little over a couple of years) - are you the first?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Jan 2009 21:23 Edited at: 12th Jan 2009 21:24
Thanks.

I thought I'd woken up in a parallel universe when I made my first post this morning. Something seems to have happened overnight. Either that or my powers of observation have reached an all-time low.

Quote: "I`ve never seen one before"


Neither have I - but that probably just means that my powers of observation have been at an all-time low for some time.

Actually, "Valued Member" is a bit of a worrying title on several counts especially in view of the following thread

bounty hunters

More seriously, it seems to be a slight against everyone else who fits the description. And there are many - modellers, programmers, artists, game creators, etc, throughout this site, many of whom have given much to the community.

All the same, I appreciate the title.

Quote: "are you the first?"


I really don't know. It was a total surprise to me.

I suppose I'd better be on my best behaviour from now on.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Jan 2009 22:44
Quote: "More seriously, it seems to be a slight against everyone else who fits the description. "


Rest assured, things will evolve over time.

cjb2006
17
Years of Service
User Offline
Joined: 20th May 2006
Location:
Posted: 13th Jan 2009 01:58 Edited at: 13th Jan 2009 02:19
Here's a viewspace math-ish question for the group. In the shader I posted here:

http://forum.thegamecreators.com/?m=forum_view&t=143208&b=1

I used a fudge factor I called "straif" to compensate for a visual screen effect I encountered. If you place an object in the center of the screen at a known distance from the camera and then rotate it around the camera in a perfect circle, as the object nears the edge of the screen it starts to elongate in width. I think it has to do with perspective but does anyone know the actual math that applies?

Edit:

Some code:

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jan 2009 15:24
Quote: "I think it has to do with perspective but does anyone know the actual math that applies?"


Yes, but no time to explain now. I think I posted something about this about a year ago and it surprised me too. I eventually realised it's an unavoidable consequence of projecting a 3D scene onto a flat plane (the screen) - draw yourself a picture and you'll see the problem. If you position your eyes at the right distance from the screen the effect should almost disappear. In your case try moving slightly closer to the screen - or reduce the camera FOV.
cjb2006
17
Years of Service
User Offline
Joined: 20th May 2006
Location:
Posted: 13th Jan 2009 18:54
Quote: "In your case try moving slightly closer to the screen - or reduce the camera FOV. "


Or ............ wait for it .............. apply a compensation like "straif". I have an approximate solution, I was just asking if there is an exact one.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Jan 2009 19:18
Quote: "I have an approximate solution, I was just asking if there is an exact one."


So do I.

I'm 99% certain there isn't an exact solution - you just introduce a different distortion into the projection of your scene.

The best solution is in fact to sit at the correct distance from the screen in relation to the screen size and the camera FOV - I guess the default FOV is based on some guess at the distance users are likely to sit. But then again it could be the first number that popped into someone's head.

I know of no other solution.
Irradic
17
Years of Service
User Offline
Joined: 1st Jul 2006
Location:
Posted: 16th Jan 2009 05:19 Edited at: 16th Jan 2009 09:25
Hi...could somebody please take a look at this shader ?

It is a normal map shader which is supposed to have the diffuse,normal map and spec on the 1st uv and a lightmap, dirtmap on a second uv.
Now I don't achieve any desired results, as soon as I change IN.uv to IN.uv1 for the lightmap and dirtmap, the textures are no longer displayed properly. Having all set to uv displays them correctly however I do need 2 different sets.
Could one of the shader gurus please take a look at the shader...So I would know if the problem lies with the shader or the mode itself (maybe the 2nd coords didn't get exported ?)
Thanks in advance, all help would be greatly appreciated.

Edit:
OK solved my own problem, it was indeed the model. The exporter didn't export the second uv set. Sorry !

mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 4th Feb 2009 01:03 Edited at: 4th Feb 2009 01:04
Hi,
there's two simple questions i would like to ask -
1/ how does the 'clip' command works? if it is true command )
2/ it's complicated for me to explain...
Hmm...so, I want to load my scene and then,
using 'cubemap' commands, render 20-30
static (aka pre-rendered) cubemaps for
20-30 objects but using just one! cubemap.
Is it avaliable?
Many thanks for any explanation

A door is a door is a door. Even a swinging one. =0
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Feb 2009 13:19
Quote: "1/ how does the 'clip' command works? if it is true command )"


If the argument is negative then the pixel is not displayed. If it is positive then the pixel is displayed. You'll have to experiment to see what happens when it's zero.

Try the following simple shader and dba code:





Press "c" or "d" to change the clipping level.

Notice how the green letters gradually disappear as you increase the clipping level towards 1. Can you see why that happens?
mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 4th Feb 2009 20:24
Many thanks GG!
Its too good to be just example!

BTW, does clip command any effect on perfomance?
for example if all of object pixels are clipped

Umm and can you give any advise about cubemap question?

A door is a door is a door. Even a swinging one. =0
mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 4th Feb 2009 20:24 Edited at: 4th Feb 2009 20:28
Double post!

EDIT
btw, congratulations with 'valued member' title!

A door is a door is a door. Even a swinging one. =0
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 4th Feb 2009 23:22 Edited at: 4th Feb 2009 23:27
Quote: "BTW, does clip command any effect on perfomance?"


I don't think so. I believe, but am not certain, that the pixel shader code is still executed after the clip command but the results just don't get rendered so the effect on performance is minimal (something else for me to check ).

Quote: "Umm and can you give any advise about cubemap question?"


Not sure I understood the question. Do you mean you have a single cube map such as a skymap and you want to apply it to several objects in the scene? For example, you might want several reflective spheres which all reflect the same fixed "environment"? If that's what you mean, then yes. I'm sure there's a demo like that on the first few pages of this thread. I'll try to find it and give a more specific location.

Edit It's this one on the first page:

Quote: "Posted: 26th Oct 2006 13:16


--------------------------------------------------------------------------------
Here's a simple reflection shader plus demo program people might like to play with. The cube map was made from images taken with cameras in another DBP application.

You can move around using the up/down keys and mouse to change direction. "


Quote: "btw, congratulations with 'valued member' title!"


Thanks. I seem to be getting more than my fair share of attention at the moment.
mr Handy
16
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 5th Feb 2009 10:38
I have explained not good i think.
So, i wanted to make smth like this fake code:


A door is a door is a door. Even a swinging one. =0
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Feb 2009 11:11
OK. I understand now.

I'll look at this after work this evening. I don't have Dark Shader or DBP here so I can't check the details yet.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Feb 2009 17:45 Edited at: 6th Feb 2009 20:14
mrHandy

I've tried to answer your latest question with a simple demo, but I don't know what you mean by "somehow copy it" in

Quote: "for f = 1 to 100
apply [same] dynamic cubemap to [another] sphere
render it
somehow copy it
next f
"


I attach what I've produced so far.

You'll need Dark Shader of course.

Edit I should have explained what the demo is supposed to do. It calculates a dynamic cube map of the scene once every sync (or once every 12 syncs if you use the commented out bit instead). This cube map is the texture that is applied to the moving spheres. The shader then simply applies the cube map texture and removes the blue component from the rendered pixel at the same time. Since the cube map is mostly blue with yellow spots the spheres end up looking black with yellow spots. In certain positions you can see the spheres themselves faintly appearing in the cube map - but it's only small yellow dots that are visible.

I'm also uncertain about what you mean by "render it" in the quoted bit of your code. The "render" in my code takes place in two steps:

1. The initial render of the whole scene onto the cube map using a temporary camera positioned at the origin.

2. The final render to the screen using camera 0 at its position and the updated cube map.

If you "render" inside the loop as your code suggests you will slow your application down to a standstill.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-17 11:22:43
Your offset time is: 2024-05-17 11:22:43