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 / set cube mapping on: how to use it in my shader?

Author
Message
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 28th Apr 2012 19:06 Edited at: 29th Apr 2012 14:13
"set cube mapping on": why it doesn't work?

***

PROBLEM SOLVED!
edit: ACTUALLY NOT

Order of commands is very important, here it is:

1. texture object 1,0,1 `texture layer 0
2. set object effect 1,1 `apply your shader
3. set cube mapping on 1,1,2,3,4,5,6 `texture layer 1

«It's the Shader, shader me this, shader me that»
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 29th Apr 2012 10:57 Edited at: 29th Apr 2012 10:58
Problem solved I said? Hell no. It's much complicated than I thought.

I have a shader with two stages:
0 - camera image
1 - set cubemapping on 1,2,3,4,5,6

ACCIDENTELY it works yesterday (as previous post said).

Today layer 1 is just black. No errors. Also, I've (luck with me) found an interesting solution:

instead of

Quote: "texture cubeTexture : ENVIRONMENT < string ResourceName = ""; >;
samplerCUBE cubeSample = sampler_state
{ texture = <cubeTexture>; };"


works this

Quote: "texture cubeTexture < string ResourceName = ""; >;
samplerCUBE cubeSample:register(s1) = sampler_state
{ texture = <cubeTexture>; };"


why? [environment] always works before. who can tell me about this sampler registers?

«It's the Shader, shader me this, shader me that»
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 29th Apr 2012 14:15 Edited at: 29th Apr 2012 14:15
notice: work version has 3 stages: base, cube and camera. new version has 2 stages: camera, cube AND not working.

anyone?

«It's the Shader, shader me this, shader me that»
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Apr 2012 17:36
There are bugs in the way DBPro handles cube mapping and shaders. It's one of those on the most annoying bugs list.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 29th Apr 2012 17:49
So it will be correct if I manually set register(s0),register(s1)... for samplers in every shader in my app?

«It's the Shader, shader me this, shader me that»
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 29th Apr 2012 19:02
I don't know. I'm surprised you didn't need:



instead of:



mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 29th Apr 2012 19:55 Edited at: 29th Apr 2012 19:55
actually i have



«It's the Shader, shader me this, shader me that»
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 29th Apr 2012 22:30
it figures out that
string ResourceName = "";
needed anyway

but not sure about
string Type = "CUBE";
and
: ENVIRONMENT

«It's the Shader, shader me this, shader me that»
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th Apr 2012 00:08
Quote: "texture cubeTexture <>;"


That's irrelevant. That's just a variable name. You could use



instead as long you changed the name used in the sampler as well, i.e.



mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 30th Apr 2012 10:49 Edited at: 30th Apr 2012 10:50
Quote: "texture greenGandalf <>;"

As I said before I found situation [in same shader again] when this line caused black texture (sampler2D). It's like with ENVIRONMENT, most shaders works ok, mine not. Why? Duno.

What does string Type = "CUBE"; ? Iam not using it and shader works ok. Also I excluded :ENVIRONMENT

«It's the Shader, shader me this, shader me that»
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th Apr 2012 14:56
We need more details - a complete (small ) project would help.

Quote: "Iam not using it and shader works ok"


Are you sure?
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 30th Apr 2012 15:29 Edited at: 30th Apr 2012 15:30
Yep, I am sure.

You can see complete shader here:
http://forum.thegamecreators.com/?m=forum_view&t=179740&b=8&msg=2342918#m2342918

«It's the Shader, shader me this, shader me that»
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th Apr 2012 19:54
I'm puzzled. This works fine in your shader:



and so does this:



No need to refer to the registers explicitly as far as I can see.

I guess you don't need to specify the texture type because the image is a cube map and you're using the texCUBE sampling function. I always include the string type for cube maps and volume textures just in case. It's possible it's needed on some machines and not others so I usually add that.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 30th Apr 2012 20:56
Quote: "This works fine in your shader:"

As I said before, cubemap is missed because of wrong register. It's a bug or something with my card.

Quote: "and so does this:"

Nope. All textures are missed.

I only not sure about :ENVIRONMENT - what it does? I'll test it's needness later.

«It's the Shader, shader me this, shader me that»
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th Apr 2012 22:23
Quote: "It's a bug or something with my card."


I can't help you with that unfortunately.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 2nd May 2012 20:48
tested ":ENVIRONMENT" - it seems to be not affecting shader by it's presense. I'll try to search web for any further info - maybe it's a extra feauture for some cards' compatibility, whynot. stay tuned

«It's the Shader, shader me this, shader me that»
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd May 2012 20:57
No, that's a semantic which is used by the application, i.e. DBPro.

I vaguely recall seeing it in some Dark Shader examples but if you don't need it, don't use it. I've managed without it.
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 2nd May 2012 20:59
Hmm... Could you name other "special" semantics? I think it may be useful for compatibility! No?

«It's the Shader, shader me this, shader me that»
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd May 2012 23:12
It would probably take an inordinate number of pints of

Guinness

before Lee will divulge the details.

Others may be bribed more easily. Any takers?

[Exercise for the reader: spot the weird link.]
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 3rd May 2012 14:57


Btw, found an interesting shader.

So my cube sampler will be like this + register (alas... DBP has some bugs with cubes)

«It's the Shader, shader me this, shader me that»
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 7th Aug 2012 14:23
Well, it's been a while since our discussion.
I have stumbled upon this article:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb944006(v=vs.85).aspx
Point of interest was part about samplers. Here it says:
Quote: "Samplers can be initialized with textures and sampler state as shown here:

sampler s = sampler_state
{
texture = NULL;
mipfilter = LINEAR;
};

Here's an example of the code to sample a 2D texture:

texture tex0;
sampler2D s_2D;

float2 sample_2D(float2 tex : TEXCOORD0) : COLOR
{
return tex2D(s_2D, tex);
}"

Although, in web there are plenty of examples like this:
Quote: "texture skyTexture;
sampler2D skySampler = sampler_state
{
Texture = skyTexture;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
}"

Although, sampler's texture could be
Quote: "sampler2D S0 = sampler_state {Texture = myTexture;}
sampler2D S0 = sampler_state {Texture = (myTexture);}
sampler2D S0 = sampler_state {Texture = <myTexture>;}"

Sooo, what's the problem...
My shaders won't sample from texture (i.e. shader has no errors!) until texture declaration is like this:
Texture base <string Name="";>;
or this:
Texture base <string ResourceName="";>;

Why? Why DBP need this line? There is nothing about it in msdn.

Login to post a reply

Server time is: 2026-07-07 12:26:35
Your offset time is: 2026-07-07 12:26:35