Game Development Community

Parallax Shader

by Emmanuel Nwankwo · in Torque Game Engine Advanced · 03/31/2005 (3:48 am) · 40 replies

Hi,

Help, been trying to create a parallax shader fro TSE with little to no success.
has any done this and is willing to share the code

thx
Page «Previous 1 2
#1
03/31/2005 (5:49 am)
I've been trying with the help of community members to do this for a while, however, I'm unclear as to how to connect/supply additional textures (such as the height map) from TSE to the shader.

There was a great thread on connecting other variables, but not additional textures as inputs, so if anyone can shed any light on that one aspect, that would help greatly.

I found it very exciting that Brian Ramage was working on a resource to assist in taking shaders from RenderMonkey, so I hope I can glean some general information as to how to connect various input-types to TSE. I also hope this information will create a flood in the availability of shaders ported into TSE by the community.

I think a reference that spells out some basics on possible HLSL vertex/pixel inputs/outputs and how to map each input type to a TSE variable would be extremely valuable. There is obviously a finite set of these input types. It could include all the pre-defined constants that are available from the engine and what they contain.

Additionally, for shaders like the "parallax shader", it would be nice for someone to spell out what would need to be changed in the engine code for a community member to provide a new procedural shader as a resource.

BTW, I love the directness of this thread's title. I would love to see more threads like this that challenge the TSE community to port a specific shader (whether it be written from scratch, Cg, HLSL, GLSL, etc.) into TSE and provide it as a community resource. TSE has such great potential to be dazzling and to expand the community based on the "wow that's cool"-factor, once this TSE-"getting started" information is available to less experienced TSE/HLSL people like me.

I'll certainly continue to post any shaders that I get working in TSE and thanks to everyone for their help. This is an excellent community.

Cheers -- Tim.
#2
03/31/2005 (3:10 pm)
Wow Tim, you're getting ME exciting about the resource ;) I'm setting up a testbed right now to bring in some RenderMonkey shaders and see what precisely needs to be done. I'll hopefully have something ready next week.
#3
03/31/2005 (6:06 pm)
Thanks Brian, I'm just brimming with enthusiasm for this engine and so I should be. I would just love to see a library of shaders that come out of the box with TSE (whether procedural or custom) and I just know the talent pool in this community can make that happen. Resources like yours surely cannot fail to ignite the creation of such a library. This year is going to be sooo cool.
#4
04/02/2005 (10:40 am)
I've gotten i parallax mapping shader working. Has a small flaw with very sharp-edged height maps, but it works. Here is an example

Without the shader:
img194.exs.cx/img194/3830/noparallax3jv.jpg
and with:
img194.exs.cx/img194/5932/parallax0tc.jpg
Notice the polygon in the middle, how it sort of doubles. Thats the flaw i mentioned.

The reason the floor color changes is cause the shader only uses ambient light of the sun and doesn't receive any interior lighting or shadowing. Im sure someone else could get it to do that too though. If you like, i'll gladly post it here.
#5
04/02/2005 (11:56 am)
Yes post it! and i'll trow the lightmap stuff in it ....or try at least..:)
#6
04/02/2005 (12:27 pm)
K. The only thing you'll need extra is to add a new texture in the material datablock, your heightmap texture. Also its 2.0 version.
I used this code off a free shader i found on the net. Just ripped out the parallax coord calculation then worked the rest it. Was actually really easy once i got an idea of what i was lookin at. I just added the other guy's code into a plain diffuseBump shader i found in the shader folder of TSE.

Anyhow, here ya go:
www.planetgargoyle.com/dm/parallaxP.hlsl
www.planetgargoyle.com/dm/parallaxV.hlsl
#7
04/02/2005 (3:00 pm)
Thanx Jacob..heres my meager addition to grab the lightmap

ParallaxV.hlsl

//add @ line 23
 float2lightmap	:	  TEXCOORD4;

//add @ line 55
 OUT.lightmap = IN.lmCoord;

parallaxP.hlsl

//

//add @ line 10
 float2 TEX1 : TEXCOORD4;

//add @ line 34
 uniform sampler2D lightMap       : register(S3),

//replace line 42 with

OUT.col = tex2D(diffuseMap, modified_texcoord)* tex2D(lightMap, IN.TEX1);


materials.cs
//add this after heightmap
  texture[3] = "$lightmap";

that seems to work.. someone correct me if its wrong :)

edit:
fixed ..
#8
04/03/2005 (1:32 am)
Wow kick ass guys :)
#9
04/03/2005 (9:14 am)
OMG PIX PLZ!!!

(No, seriously... I wana see how it looks with the lightmapping. :)
#10
04/03/2005 (12:11 pm)
I tried that lightmapping thing kevin posted, didn't work right.. I musta done somethin wrong, so im gonna go back through.. I did it right after i woke up so.. ya. ;)

Ya, that was the problem, was too tired when i did it. Just did it again, no prob. Ima try to get a couple pics, but unfortunatly i don't have any interiors.
#11
04/03/2005 (2:19 pm)
That looks pretty hot! Nice work, guys.
#12
04/03/2005 (3:28 pm)
Amazing Stuff Guys, wow what a response to the thread, the GG Forum is the best.

I have been playing around with the posted code, trying to understand how it works as well as trying to add diffuse lighting

here are some preliminary results, not quite sure if this looks correct
was having trouble getting the lightmap additions to work.

www.jahdiel.co.uk/imgs/pr2.jpg
www.jahdiel.co.uk/imgs/pr3.jpg

will post some code shorthly, thanks a million guys
#13
04/03/2005 (3:53 pm)
Ya, theres one flaw in the posted lightmap changes. OUT.lightmap = IN.lmTex; should actually be OUT.lightmap = IN.lmCoord;
#14
04/04/2005 (12:07 am)
Parallax mapping rules!

Great work, I love the team community effort here, very sweet.
#15
04/04/2005 (12:20 am)
That's one sweet shader. I'd sure like to see parallax mapping added to the procedural shaders.
#16
04/04/2005 (3:11 am)
Heh, wow. I did something people like. :D
#17
04/04/2005 (5:45 am)
I also just wanted to pass on deepest thanks to Jacob and Kevin for their effort in getting this shader connected to TSE. Awesome teamwork guys!!

I agree with Josh that there's surely no doubt that this needs to be standard feature of the procedural shaders. I'm sure it can be done by following in the footsteps of the "bumpTex". Perhaps Ben, Timothy, or Brian could just throw out the various source files that need to be considered to give this feature the procedural support it's begging for. i.e. "heightTex".

Also, I believe the part of the solution to this shader was adding the code block into one of the existing procedural shaders, so to make this a little easier, how would one go about including the material name into the generated shader file as a comment and as part of the file name. I would assume that regardless of the purpose of the datablock, that its name is available somewhere though. If it's not available easily then I guess it could always be added as a new variable in the Material datablock.

Let's not let this effort end here. I just know this thread was the catalyst needed to get the TSE "just-gotta-have-it" juices flowing. Certainly, there are just tons of easily obtainable quality HLSL-compatible shaders out there just yearning to be connected to TSE. It's clear to see that the more shaders that are posted here that show how they are re-worked and connected to TSE, the more powerful this engine will become.

If I could go back, I would rename this thread to "Shader Feature: Parallax" (or similar) and ask that any other shader feaures should also have their own threads i.e. "Shader Feature: HDR Lighting", but that's just my 2 cents. It amazing to me that so much was gained and such a deep response was generated from such a simple direct question. I know all shaders are perhaps not so easily connected to TSE, but I propose we make it our business to always endeavour to be one of the first shader-engines to implement the latest graphics features. Perhaps even a monthly TSE/shader demo competition.

I just can't get over this effort and over a weekend to boot. Just awesome. What a team!! What a team!!
#18
04/04/2005 (7:46 am)
I've looked thru the procedural shader builder code and it's not very difficult to add new features to it. If my 2.0 shader card wasn't broken i'd add it and submit the patch.
#19
04/04/2005 (12:30 pm)
I actually was going to do it myself, but other things ended up commin up and i never got around to it. Im sure it would be quite easy though as the parallax code is really not much of an addition.

I had this shader built prolly a month or so back, but i never got around to posting it. Didn't think there would be such a positive responce for it. ;)
Anyhow, once i finish up more work im doin, my next hope is to try somethin like a fur shader if i can find a good one to work off. I've always liked the looks of fur shaders and i'd kill to get one workin. :D
#20
04/05/2005 (1:46 am)
Be sure to keep us posted Jacob! :)
Page «Previous 1 2