water shader 4 irrlicht nearly completed

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
omaremad

water shader 4 irrlicht nearly completed

Post by omaremad »

hello people

ive nearly made a water shader but i have one problem

in hlsl
how do u acesses time when in irrlicht

i mean in render monkey all u do is type this

time_0_X

to get the time

how do u do it in irrlicht

plz help


@m-nite
plz don t say this is :D irr :D elevent or has been answered
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

well I have no idea, but I was so excited by your post that I did have a quick look in the source engine's source, and found this in IMaterialRenderer.h

Code: Select all

	virtual void setBasicRenderStates(const SMaterial& material, 
		const SMaterial& lastMaterial,
		bool resetAllRenderstates) = 0;
	//! Sets a constant for the vertex shader based on a name. This can be used if you used
	//! a high level shader language like CG or HLSL to create a shader. Example: If you
	//! created a shader which has variables named 'mWorldViewProj' (containing the 
	//! WorldViewProjection matrix) and another one named 'fTime' containing one float, 
	//! you can set them in your IShaderConstantSetCallBack derived class like this:
	//! \code
	//! virtual void OnSetConstants(video::IMaterialRendererServices* services)
	//! {
	//! 	video::IVideoDriver* driver = services->getVideoDriver();
	//! 
	//! 	float time = (float)os::Timer::getTime()/100000.0f;
	//! 	services->setVertexShaderConstant("fTime", &time, 1);
	//! 
	//! 	core::matrix4 worldViewProj;
	//! 	worldViewProj = driver->getTransform(video::ETS_PROJECTION);			
	//! 	worldViewProj *= driver->getTransform(video::ETS_VIEW);
	//! 	worldViewProj *= driver->getTransform(video::ETS_WORLD);
	//! 	services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16);
	//! }
hope it helps :)
omaremad

Post by omaremad »

cool gr8 snippet thanx

it works by doing some sine anc cosine waves on a texture

(i only started learning hlsl yesterday)so dont excpect anthing jaw dropping thanx it will help me progrss alot
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

"devicepointer->getTimer()->getTime();" should return the time in milliseconds.
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
omaremad

Post by omaremad »

first batch of alpha shots


Image

Image

Image
thanx for the help

ill relese the code once i figure out how 2 do proper refelctions

post advice and critical opinion now
Guest

Post by Guest »

i think its too transparent for beeing water and it should have a color like greenblue or something like that :) or can this be set in your code?

but besides that it looks great man :) !
omaremad

Post by omaremad »

is that what u want gfx

Image

it look uglier when it moves

btw could the guy that achieved real reflections with render 2 tex reply how he did it
omaremad

Post by omaremad »

how about this
a sin and cosine waves on the x and y axes lol

look at how fancy it is

plz say which 1 is more real

Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

wow! :)
i think i prefer the first ones, I can't really see that last one it's too dark

I'd love to see a tutorial on how you did it when you've finished, the wiki's shader section is empty
omaremad

Post by omaremad »

ok ill wiki it when its done

any way thanx for ur snippet it did all the work

@NIKO/SHADER EXPERTS

CAN HLSL LOAD TEXTURES FROM THE HLSL CODE?

or CAN IRRLICHT ASSIGN A TEXTURE TO A RESGITER?

oops caploack

thanx for ur support

the water looks to artificial since the wave pattern repeats so im gonna us a noise texture for random stuff (reason for above q)
omaremad

Post by omaremad »

wow this is thread one thousand in the advanced section

happy mellenium irrlicht :D

btw here is some thing random

my real name is:
omar emad abd el aziz hussien aly shahin........ramses2......a caveman.....adam.
omaremad

Post by omaremad »

@niko

i know sampler2D tex0; would call th texture on a mesh

would sampler2D tex1; call the 2nd texture on that mesh?

thanx bye
omaremad

Post by omaremad »

i thought people wanted this any one want to help

:cry: :cry: :cry: :cry: :cry:
omaremad

Post by omaremad »

can any one then tell me a function in hlsl that generates perlin noise

dont say the noise() function all it does are dots :oops:
lantis
Posts: 64
Joined: Thu Jun 17, 2004 2:46 pm

Post by lantis »

omaremad very nice water ;)
Can you post source code? ;-)
Post Reply